Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4723 from hashicorp/fix-race-job-test
Browse files Browse the repository at this point in the history
Remove race condition in job test
  • Loading branch information
izaaklauer committed May 15, 2023
2 parents edd65d1 + a3c862d commit cd92950
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/serverstate/statetest/test_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2680,10 +2680,12 @@ func TestJobHeartbeatOnRestart(t *testing.T, factory Factory, rf RestartFactory)
s = rf(t, s)
defer s.Close()

// Verify it exists
job, err = s.JobById(ctx, "A", nil)
require.NoError(err)
require.Equal(pb.Job_RUNNING, job.Job.State)
// Verify it exists. We use a closure here to avoid a possible race condition with the job object
{
job, err := s.JobById(ctx, "A", nil)
require.NoError(err)
require.Equal(pb.Job_RUNNING, job.Job.State)
}

// Should time out
require.Eventually(func() bool {
Expand Down

0 comments on commit cd92950

Please sign in to comment.