Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): Find specific CRS binding when checking if resource is applied #391

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading