Skip to content

Commit

Permalink
test: fix flaky test (#14713)
Browse files Browse the repository at this point in the history
Need to wait for Stop evals to be processed before you can expect
subsequent RPCs to see the alloc's DesiredStatus=stop.
  • Loading branch information
schmichael authored Sep 27, 2022
1 parent cc8e624 commit 3bab1cd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nomad/job_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ func TestJobEndpoint_Register_NonOverlapping(t *testing.T) {
var stopResp structs.JobDeregisterResponse
must.NoError(t, msgpackrpc.CallWithCodec(codec, "Job.Deregister", stopReq, &stopResp))

// Wait until the Stop is complete
testutil.Wait(t, func() (bool, error) {
eval, err := state.EvalByID(nil, stopResp.EvalID)
must.NoError(t, err)
if eval == nil {
return false, fmt.Errorf("eval not applied: %s", resp.EvalID)
}
return eval.Status == structs.EvalStatusComplete, fmt.Errorf("expected eval to be complete but found: %s", eval.Status)
})

// Assert new register blocked
req.Job = job.Copy()
must.NoError(t, msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp))
Expand Down

0 comments on commit 3bab1cd

Please sign in to comment.