@@ -202,15 +202,26 @@ func TestWorkflowReRun(t *testing.T) {
202202 output , err := cmdWorkflowRun (appID , "SimpleWorkflow" , "--instance-id=foo" )
203203 require .NoError (t , err , output )
204204
205- // Wait for the workflow instance to be registered and queryable before
206- // attempting rerun operations. On slow CI runners 3s is not enough.
205+ // Wait for the workflow instance to reach a terminal state before
206+ // attempting rerun operations. Rerun requires the instance to be in a
207+ // terminal state (COMPLETED/FAILED/TERMINATED).
207208 require .Eventually (t , func () bool {
208209 out , err := cmdWorkflowList (appID , redisConnString , "-o" , "json" )
209210 if err != nil {
210211 return false
211212 }
212- return strings .Contains (out , "foo" )
213- }, 30 * time .Second , time .Second , "workflow instance 'foo' did not appear in list" )
213+ var list []map [string ]interface {}
214+ if err := json .Unmarshal ([]byte (out ), & list ); err != nil {
215+ return false
216+ }
217+ for _ , item := range list {
218+ if item ["instanceID" ] == "foo" {
219+ status , _ := item ["runtimeStatus" ].(string )
220+ return status == "COMPLETED" || status == "FAILED" || status == "TERMINATED"
221+ }
222+ }
223+ return false
224+ }, 60 * time .Second , time .Second , "workflow instance 'foo' did not reach terminal state" )
214225
215226 t .Run ("rerun from beginning" , func (t * testing.T ) {
216227 output , err := cmdWorkflowReRun (appID , "foo" )
0 commit comments