diff --git a/test/fv/fv_suite_test.go b/test/fv/fv_suite_test.go index 9fe74dea..735a5fc9 100644 --- a/test/fv/fv_suite_test.go +++ b/test/fv/fv_suite_test.go @@ -190,6 +190,13 @@ func verifyCAPICluster() { if currentLabels == nil { currentLabels = make(map[string]string) } + + // Early return only if BOTH conditions are already satisfied + val, exists := currentCluster.Labels[key] + if exists && val == value && !isTrue(currentCluster.Spec.Paused) { + return nil + } + currentLabels[key] = value currentCluster.Labels = currentLabels paused := false @@ -200,6 +207,10 @@ func verifyCAPICluster() { Expect(err).To(BeNil()) } +func isTrue(b *bool) bool { + return b != nil && *b +} + func verifySveltosCluster() { clusterList := &libsveltosv1beta1.SveltosClusterList{} listOptions := []client.ListOption{ diff --git a/test/fv/stale_resource_test.go b/test/fv/stale_resource_test.go index 4ce57162..233abd6a 100644 --- a/test/fv/stale_resource_test.go +++ b/test/fv/stale_resource_test.go @@ -202,6 +202,14 @@ var _ = Describe("Stale Resources", func() { return false }, timeout, pollingInterval).Should(BeTrue()) + Byf("Verifying Service %s is not created the workload cluster", incorrectServiceName) + Consistently(func() bool { + currentService := &corev1.Service{} + err = workloadClient.Get(context.TODO(), + types.NamespacedName{Namespace: configMapNs, Name: incorrectServiceName}, currentService) + return err != nil && apierrors.IsNotFound(err) + }, time.Minute, pollingInterval).ShouldNot(BeNil()) + for _, serviceName := range []string{service1, service2, service3} { Byf("Verifying Service %s is still in the workload cluster", serviceName) Consistently(func() error { @@ -211,14 +219,6 @@ var _ = Describe("Stale Resources", func() { }, time.Minute, pollingInterval).Should(BeNil()) } - Byf("Verifying Service %s is not created the workload cluster", incorrectServiceName) - Consistently(func() bool { - currentService := &corev1.Service{} - err = workloadClient.Get(context.TODO(), - types.NamespacedName{Namespace: configMapNs, Name: incorrectServiceName}, currentService) - return err != nil && apierrors.IsNotFound(err) - }, time.Minute, pollingInterval).ShouldNot(BeNil()) - By("Updating ConfigMap to reference also a fourth Service") service4 := randomString() Expect(k8sClient.Get(context.TODO(),