Skip to content

Commit

Permalink
Merge pull request #10011 from hashicorp/b-e2e-gh-9985
Browse files Browse the repository at this point in the history
e2e: account for race condition in periodic dispatch test.
  • Loading branch information
jrasell committed Feb 11, 2021
2 parents 2a50f73 + 7cb48ab commit 58a9480
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion e2e/periodic/input/simple.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ job "periodic" {
}
}
}

17 changes: 13 additions & 4 deletions e2e/periodic/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,24 @@ func (tc *PeriodicTest) TestPeriodicDispatch_Basic(f *framework.F) {
tc.jobIDs = append(tc.jobIDs, jobID)

// register job
e2eutil.Register(jobID, "periodic/input/simple.nomad")
require.NoError(t, e2eutil.Register(jobID, "periodic/input/simple.nomad"))

// force dispatch
require.NoError(t, e2eutil.PeriodicForce(jobID))

// Get the child job ID
childID, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 1}}{{printf "%s" .ID}}{{end}}`)
require.NoError(t, err)
require.NotEmpty(t, childID)
testutil.WaitForResult(func() (bool, error) {
childID, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 1}}{{printf "%s" .ID}}{{end}}`)
if err != nil {
return false, err
}
if childID != "" {
return true, nil
}
return false, fmt.Errorf("expected non-empty periodic child jobID for job %s", jobID)
}, func(err error) {
require.NoError(t, err)
})

testutil.WaitForResult(func() (bool, error) {
status, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 1}}{{printf "%s" .Status}}{{end}}`)
Expand Down

0 comments on commit 58a9480

Please sign in to comment.