Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 17, 2022
1 parent f1ad02e commit 03a9b4a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/allocrunner/alloc_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,11 @@ func TestAllocRunner_MoveAllocDir(t *testing.T) {
ar.Run()
defer destroy(ar)

require.Equal(t, structs.AllocClientStatusComplete, ar.AllocState().ClientStatus)
testutil.WaitForResult(func() (bool, error) {
return ar.AllocState().ClientStatus == structs.AllocClientStatusComplete, nil
}, func(_ error) {
t.Fatalf("expected alloc to be complete")
})

// Step 2. Modify its directory
task := alloc.Job.TaskGroups[0].Tasks[0]
Expand Down Expand Up @@ -1241,7 +1245,11 @@ func TestAllocRunner_MoveAllocDir(t *testing.T) {
ar2.Run()
defer destroy(ar2)

require.Equal(t, structs.AllocClientStatusComplete, ar2.AllocState().ClientStatus)
testutil.WaitForResult(func() (bool, error) {
return ar.AllocState().ClientStatus == structs.AllocClientStatusComplete, nil
}, func(_ error) {
t.Fatalf("expected alloc to be complete")
})

// Ensure that data from ar was moved to ar2
dataFile = filepath.Join(ar2.allocDir.SharedDir, "data", "data_file")
Expand Down

0 comments on commit 03a9b4a

Please sign in to comment.