Skip to content

Commit 30da399

Browse files
author
Gemini CLI User
committed
fix(integration): Use kubectl wait for etcd readiness in OLM test
The 'validateOlmAddon' integration test was using a custom retry loop with 'retry.Expo' to check if the etcd operator's CSV had been successfully installed. This could lead to intermittent failures (flakes) in CI. This change replaces the custom Go retry loop with a single, more idiomatic 'kubectl wait' command. The command waits for the CSV's status phase to become 'Succeeded', using 'kubectl''s built-in polling mechanism. This makes the test more robust and less prone to flakiness.
1 parent cdfdf97 commit 30da399

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

test/integration/addons_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -513,23 +513,9 @@ func validateOlmAddon(ctx context.Context, t *testing.T, profile string) {
513513
t.Logf("etcd operator installation with %s failed: %v", rr.Command(), err)
514514
}
515515

516-
want := "Succeeded"
517-
checkOperatorInstalled := func() error {
518-
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "csv", "-n", "my-etcd"))
519-
if err != nil {
520-
return err
521-
}
522-
if rr.Stderr.String() != "" {
523-
t.Logf("%v: unexpected stderr: %s", rr.Command(), rr.Stderr)
524-
}
525-
if !strings.Contains(rr.Stdout.String(), want) {
526-
return fmt.Errorf("%v stdout = %q, want %q", rr.Command(), rr.Stdout, want)
527-
}
528-
return nil
529-
}
530516
// Operator installation takes a while
531-
if err := retry.Expo(checkOperatorInstalled, time.Second*3, Minutes(10)); err != nil {
532-
t.Errorf("failed checking operator installed: %v", err.Error())
517+
if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "wait", "csv", "--all", "-n", "my-etcd", "--for=jsonpath={.status.phase}=Succeeded", "--timeout=10m")); err != nil {
518+
t.Errorf("failed waiting for etcd operator to be installed: %v", err)
533519
}
534520
}
535521

0 commit comments

Comments
 (0)