@@ -534,6 +534,22 @@ func testStop(t *testing.T, ksWorkflow, cells string) {
534534 t .Run ("Stop" , func (t * testing.T ) {
535535 // Create a new VDiff and immediately stop it.
536536 uuid , _ := performVDiff2Action (t , false , ksWorkflow , cells , "create" , "" , false )
537+
538+ // Ensure the state to be either completed or started
539+ isStartedOrCompleted := false
540+ maxRetries := 5
541+ for i := 1 ; i <= maxRetries ; i ++ {
542+ _ , output := performVDiff2Action (t , false , ksWorkflow , cells , "show" , uuid , false )
543+ jsonOutput := getVDiffInfo (output )
544+ isStartedOrCompleted = jsonOutput .State == "started" || jsonOutput .State == "completed"
545+ if isStartedOrCompleted || i == maxRetries {
546+ break
547+ }
548+ t .Logf ("VDiff state expected to be started or completed, got: %s, retrying (attempt %d of %d)" , jsonOutput .State , i , maxRetries )
549+ time .Sleep (vdiffRetryInterval )
550+ }
551+ require .True (t , isStartedOrCompleted , "VDiff state should either be started or completed" )
552+
537553 _ , _ = performVDiff2Action (t , false , ksWorkflow , cells , "stop" , uuid , false )
538554 // Confirm the VDiff is in the expected state.
539555 _ , output := performVDiff2Action (t , false , ksWorkflow , cells , "show" , uuid , false )
0 commit comments