Skip to content

Commit

Permalink
test(e2e): Find specific CRS when checking if resource is applied
Browse files Browse the repository at this point in the history
Check the relevant ResourceSetBinding to see if the resource is
applied. If multiple ClusterResourceSets match a cluster, the
ClusterResourceSetBinding will have multiple bindings and so only the
relevant ResourceSetBinding should be checked.
  • Loading branch information
jimmidyson committed Feb 24, 2024
1 parent 34b0b1d commit 01cc1b5
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test/e2e/clusterresourceset_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,28 @@ func waitForClusterResourceSetToApplyResources(
continue
}

// Fix a bug from upstream to check all bindings.
resourceApplied := false
for _, binding := range binding.Spec.Bindings {
if binding.IsApplied(resource) {
resourceApplied = true
break
}
}
if !resourceApplied {
// Check relevant ResourceSetBinding to see if the resource is applied. If no ResourceSetBinding is found for
// the specified ClusterResourceSet, the resource has not applied.
resourceSetBinding, found := getResourceSetBindingForClusterResourceSet(
binding,
input.ClusterResourceSet,
)
if !found || !resourceSetBinding.IsApplied(resource) {
return false
}
}
return true
}, intervals...).Should(BeTrue())
}

func getResourceSetBindingForClusterResourceSet(
clusterResourceSetBinding *addonsv1.ClusterResourceSetBinding,
clusterResourceSet *addonsv1.ClusterResourceSet,
) (*addonsv1.ResourceSetBinding, bool) {
for _, binding := range clusterResourceSetBinding.Spec.Bindings {
if binding.ClusterResourceSetName == clusterResourceSet.Name {
return binding, true
}
}
return nil, false
}

0 comments on commit 01cc1b5

Please sign in to comment.