Fix racing condition
when creating a Nomad job in the e2e tests
This commit is contained in:
@ -14,6 +14,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateOrUpdateEnvironment(t *testing.T) {
|
func TestCreateOrUpdateEnvironment(t *testing.T) {
|
||||||
@ -114,6 +115,7 @@ func TestListEnvironments(t *testing.T) {
|
|||||||
job.Name = &jobID
|
job.Name = &jobID
|
||||||
_, _, err := nomadClient.Jobs().Register(job, nil)
|
_, _, err := nomadClient.Jobs().Register(job, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
<-time.After(tests.ShortTimeout) // Nomad needs a bit to create the job
|
||||||
|
|
||||||
// List without fetch should not include the added environment
|
// List without fetch should not include the added environment
|
||||||
response, err := http.Get(path) //nolint:gosec // because we build this path right above
|
response, err := http.Get(path) //nolint:gosec // because we build this path right above
|
||||||
@ -167,6 +169,7 @@ func TestGetEnvironment(t *testing.T) {
|
|||||||
job.Name = &jobID
|
job.Name = &jobID
|
||||||
_, _, err := nomadClient.Jobs().Register(job, nil)
|
_, _, err := nomadClient.Jobs().Register(job, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
<-time.After(tests.ShortTimeout) // Nomad needs a bit to create the job
|
||||||
|
|
||||||
// List without fetch should not include the added environment
|
// List without fetch should not include the added environment
|
||||||
path := helpers.BuildURL(api.BasePath, api.EnvironmentsPath, tests.AnotherEnvironmentIDAsString)
|
path := helpers.BuildURL(api.BasePath, api.EnvironmentsPath, tests.AnotherEnvironmentIDAsString)
|
||||||
|
Reference in New Issue
Block a user