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

🐛 Small test fix. Remove OwnerReference & Check for Finalizers being empty #3178

Merged
merged 2 commits into from
Sep 2, 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
17 changes: 15 additions & 2 deletions controllers/vspherecluster_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
"sigs.k8s.io/cluster-api-provider-vsphere/internal/test/helpers/vcsim"
Expand Down Expand Up @@ -137,7 +138,7 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
if err := testEnv.Get(ctx, key, instance); err != nil {
return false
}
return len(instance.Finalizers) > 0
return ctrlutil.ContainsFinalizer(instance, infrav1.ClusterFinalizer)
}, timeout).Should(BeTrue())

// checking cluster is setting the ownerRef on the secret
Expand All @@ -146,7 +147,12 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
if err := testEnv.Get(ctx, secretKey, secret); err != nil {
return false
}
return len(secret.OwnerReferences) > 0
for _, ref := range secret.OwnerReferences {
if ref.Name == instance.Name {
return true
}
}
return false
}, timeout).Should(BeTrue())

By("setting the VSphereCluster's VCenterAvailableCondition to true")
Expand Down Expand Up @@ -277,6 +283,13 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
Expect(testEnv.Create(ctx, instance)).To(Succeed())
key := client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}

Eventually(func() bool {
if err := testEnv.Get(ctx, key, instance); err != nil {
return false
}
return !ctrlutil.ContainsFinalizer(instance, infrav1.ClusterFinalizer)
}, timeout).Should(BeTrue())

// Make sure the VSphereCluster exists.
Eventually(func() bool {
err := testEnv.Get(ctx, key, instance)
Expand Down
Loading