Skip to content

Commit e1b6bf9

Browse files
authored
test: fix flake in TestResourceGroupApplyStatus (#1877)
After adding the diff logging, it looks like the root cause for this test flake is due to a watch event ordering issue. Namely, the test begins waiting for the resourceVersion to not change before the r-g-c has actually updated the status. The fix is to add a resourceVersion check to the prior wait condition, such that it does not pass prematurely on a stale watch event.
1 parent b8b5b1a commit e1b6bf9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

e2e/testcases/resource_group_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,20 @@ func TestResourceGroupApplyStatus(t *testing.T) {
527527
rg = &v1alpha1.ResourceGroup{}
528528
nt.Must(nt.KubeClient.Get(rgNN.Name, rgNN.Namespace, rg))
529529
rg.Status.ResourceStatuses = nil
530+
// track resourceVersion to make sure the watch doesn't accept a stale object
531+
resourceVersion := rg.ResourceVersion
530532
nt.Must(nt.KubeClient.UpdateStatus(rg))
531533

532534
nt.T.Log("Wait for the ResourceGroup controller to update the ResourceGroup status")
533535
nt.Must(nt.Watcher.WatchObject(kinds.ResourceGroup(), rgNN.Name, rgNN.Namespace,
534536
testwatcher.WatchPredicates(
535537
testpredicates.ResourceGroupStatusEquals(expectedStatus),
538+
testpredicates.ResourceVersionNotEquals(nt.Scheme, resourceVersion),
536539
)))
537540

538541
rg = &v1alpha1.ResourceGroup{}
539542
nt.Must(nt.KubeClient.Get(rgNN.Name, rgNN.Namespace, rg))
540-
resourceVersion := rg.ResourceVersion
543+
resourceVersion = rg.ResourceVersion
541544

542545
nt.T.Log("Wait 60s to validate that the ResourceGroup controller doesn't make any more updates (no resourceVersion change)")
543546
err := nt.Watcher.WatchObject(kinds.ResourceGroup(), rgNN.Name, rgNN.Namespace,

0 commit comments

Comments
 (0)