Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions test/fv/fv_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand Down
16 changes: 8 additions & 8 deletions test/fv/stale_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down