Skip to content

Commit b1ae9fc

Browse files
committed
helmrepo: Fix test flake in type update test
In TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter, when the type of HelmRepo is updated and immediately checked for the object to be ready, if the check happens before the client cache is updated, it results in observing the object to be ready in the previous generation. This results in status check failure: ``` [Check-FAIL]: [Ready condition must be False when the ObservedGeneration is less than the object Generation, Ready condition must be False when any of the status condition's ObservedGeneration is less than the object Generation: [Ready ArtifactInStorage]] ``` Explicitly look for the object with the next generation to prevent such failure. Signed-off-by: Sunny <[email protected]>
1 parent 55a594a commit b1ae9fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

controllers/helmrepository_controller_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,11 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing.
11661166
Name: secret.Name,
11671167
}
11681168

1169+
oldGen := obj.GetGeneration()
11691170
g.Expect(testEnv.Update(ctx, obj)).To(Succeed())
1171+
newGen := oldGen + 1
11701172

1171-
// Wait for HelmRepository to be Ready
1173+
// Wait for HelmRepository to be Ready with new generation.
11721174
g.Eventually(func() bool {
11731175
if err := testEnv.Get(ctx, key, obj); err != nil {
11741176
return false
@@ -1178,8 +1180,8 @@ func TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter(t *testing.
11781180
}
11791181
readyCondition := conditions.Get(obj, meta.ReadyCondition)
11801182
return readyCondition.Status == metav1.ConditionTrue &&
1181-
obj.Generation == readyCondition.ObservedGeneration &&
1182-
obj.Generation == obj.Status.ObservedGeneration
1183+
newGen == readyCondition.ObservedGeneration &&
1184+
newGen == obj.Status.ObservedGeneration
11831185
}, timeout).Should(BeTrue())
11841186

11851187
// Check if the object status is valid.

0 commit comments

Comments
 (0)