From 28e6ad081e02b665b7e0aa73d9adcd1ca36dafde Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 13:42:00 +0530 Subject: [PATCH] CI: Fix `VDiff2` flaky e2e test (#18494) Signed-off-by: Noble Mittal --- go/test/endtoend/vreplication/vdiff2_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/go/test/endtoend/vreplication/vdiff2_test.go b/go/test/endtoend/vreplication/vdiff2_test.go index 504c2a80841..7f4d55e7757 100644 --- a/go/test/endtoend/vreplication/vdiff2_test.go +++ b/go/test/endtoend/vreplication/vdiff2_test.go @@ -541,6 +541,22 @@ func testStop(t *testing.T, ksWorkflow, cells string) { t.Run("Stop", func(t *testing.T) { // Create a new VDiff and immediately stop it. uuid, _ := performVDiff2Action(t, ksWorkflow, cells, "create", "", false) + + // Ensure the state to be either completed or started + isStartedOrCompleted := false + maxRetries := 5 + for i := 1; i <= maxRetries; i++ { + _, output := performVDiff2Action(t, ksWorkflow, cells, "show", uuid, false) + jsonOutput := getVDiffInfo(output) + isStartedOrCompleted = jsonOutput.State == "started" || jsonOutput.State == "completed" + if isStartedOrCompleted || i == maxRetries { + break + } + t.Logf("VDiff state expected to be started or completed, got: %s, retrying (attempt %d of %d)", jsonOutput.State, i, maxRetries) + time.Sleep(vdiffRetryInterval) + } + require.True(t, isStartedOrCompleted, "VDiff state should either be started or completed") + _, _ = performVDiff2Action(t, ksWorkflow, cells, "stop", uuid, false) // Confirm the VDiff is in the expected state. _, output := performVDiff2Action(t, ksWorkflow, cells, "show", uuid, false)