Skip to content

Commit

Permalink
Merge pull request #3178 from erwin-kok/main
Browse files Browse the repository at this point in the history
🐛 Small test fix. Remove OwnerReference & Check for Finalizers being empty
  • Loading branch information
k8s-ci-robot committed Sep 2, 2024
2 parents c14a875 + 034926b commit 3a99f4b
Showing 1 changed file with 15 additions and 2 deletions.
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

0 comments on commit 3a99f4b

Please sign in to comment.