From 24b22f2c4088b0472786d05c902dbbaa7db07265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Fri, 22 Oct 2021 15:14:53 +0200 Subject: [PATCH] Fix racing condition when creating a Nomad job in the e2e tests --- tests/e2e/environments_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/environments_test.go b/tests/e2e/environments_test.go index ac30951..79b816f 100644 --- a/tests/e2e/environments_test.go +++ b/tests/e2e/environments_test.go @@ -14,6 +14,7 @@ import ( "net/http" "strings" "testing" + "time" ) func TestCreateOrUpdateEnvironment(t *testing.T) { @@ -114,6 +115,7 @@ func TestListEnvironments(t *testing.T) { job.Name = &jobID _, _, err := nomadClient.Jobs().Register(job, nil) 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 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 _, _, err := nomadClient.Jobs().Register(job, nil) 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 path := helpers.BuildURL(api.BasePath, api.EnvironmentsPath, tests.AnotherEnvironmentIDAsString)