Skip to content

Commit de9bafd

Browse files
authored
Fix TestInactiveLogicalCluster flake (#3941)
The update adding/removing the inactive annotation is never retried. That isn't a problem as long as there isn't anything else modifying the lc before the test moves to the logical cluster annotation. If however another reconciler modifies the object before that happens the test fails because of the RV mismatch, and since it doesn't retry the entire test fails. Hence it flakes in CI. Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
1 parent 74e1dc8 commit de9bafd

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

test/e2e/workspace/inactive_test.go

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ func TestInactiveLogicalCluster(t *testing.T) {
4848
kubeClient, err := kcpkubernetesclientset.NewForConfig(cfg)
4949
require.NoError(t, err)
5050

51-
t.Log("Get the logicalcluster")
52-
lc, err := kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Get(t.Context(), "cluster", v1.GetOptions{})
53-
require.NoError(t, err)
54-
55-
t.Log("Mark the logicalcluster as inactive")
56-
lc.Annotations[filters.InactiveAnnotation] = "true"
57-
lc, err = kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Update(t.Context(), lc, v1.UpdateOptions{})
58-
require.NoError(t, err)
51+
kcptestinghelpers.Eventually(t, func() (bool, string) {
52+
lc, err := kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Get(t.Context(), "cluster", v1.GetOptions{})
53+
if err != nil {
54+
return false, err.Error()
55+
}
56+
lc.Annotations[filters.InactiveAnnotation] = "true"
57+
_, err = kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Update(t.Context(), lc, v1.UpdateOptions{})
58+
if err != nil {
59+
return false, err.Error()
60+
}
61+
return true, ""
62+
}, wait.ForeverTestTimeout, time.Millisecond*100)
5963

6064
t.Log("Verify that normal requests fail")
6165
kcptestinghelpers.Eventually(t, func() (bool, string) {
@@ -67,9 +71,18 @@ func TestInactiveLogicalCluster(t *testing.T) {
6771
}, wait.ForeverTestTimeout, time.Millisecond*100)
6872

6973
t.Log("Remove inactive annotation again")
70-
delete(lc.Annotations, filters.InactiveAnnotation)
71-
_, err = kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Update(t.Context(), lc, v1.UpdateOptions{})
72-
require.NoError(t, err)
74+
kcptestinghelpers.Eventually(t, func() (bool, string) {
75+
lc, err := kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Get(t.Context(), "cluster", v1.GetOptions{})
76+
if err != nil {
77+
return false, err.Error()
78+
}
79+
delete(lc.Annotations, filters.InactiveAnnotation)
80+
_, err = kcpClient.Cluster(orgPath).CoreV1alpha1().LogicalClusters().Update(t.Context(), lc, v1.UpdateOptions{})
81+
if err != nil {
82+
return false, err.Error()
83+
}
84+
return true, ""
85+
}, wait.ForeverTestTimeout, time.Millisecond*100)
7386

7487
t.Log("Verify that normal requests succeed again")
7588
kcptestinghelpers.Eventually(t, func() (bool, string) {

0 commit comments

Comments
 (0)