Skip to content

Commit f8d873e

Browse files
committed
fix: reduce flaky test by avoiding redundant Cluster updates
The suite test was experiencing flakiness due to intermittent Conflict errors. Added an early-return check within the RetryOnConflict loop. The logic now verifies both the label existence/value and the Spec.Paused status before attempting an update.
1 parent c92a2d3 commit f8d873e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/fv/fv_suite_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ func verifyCAPICluster() {
190190
if currentLabels == nil {
191191
currentLabels = make(map[string]string)
192192
}
193+
194+
// Early return only if BOTH conditions are already satisfied
195+
val, exists := currentCluster.Labels[key]
196+
if exists && val == value && !isTrue(currentCluster.Spec.Paused) {
197+
return nil
198+
}
199+
193200
currentLabels[key] = value
194201
currentCluster.Labels = currentLabels
195202
paused := false
@@ -200,6 +207,10 @@ func verifyCAPICluster() {
200207
Expect(err).To(BeNil())
201208
}
202209

210+
func isTrue(b *bool) bool {
211+
return b != nil && *b
212+
}
213+
203214
func verifySveltosCluster() {
204215
clusterList := &libsveltosv1beta1.SveltosClusterList{}
205216
listOptions := []client.ListOption{

0 commit comments

Comments
 (0)