mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
testing: setting env var incompatible with parallel tests (#14405)
Neither the `os.Setenv` nor `t.Setenv` helper are safe to use in parallel tests because environment variables are process-global. The stdlib panics if you try to do this. Remove the `ci.Parallel()` call from all tests where we're setting environment variables.
This commit is contained in:
@@ -1376,14 +1376,11 @@ BAR={{key "bar"}}
|
||||
// process environment variables. nomad host process environment variables
|
||||
// are to be treated the same as not found environment variables.
|
||||
func TestTaskTemplateManager_FiltersEnvVars(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
defer os.Setenv("NOMAD_TASK_NAME", os.Getenv("NOMAD_TASK_NAME"))
|
||||
os.Setenv("NOMAD_TASK_NAME", "should be overridden by task")
|
||||
t.Setenv("NOMAD_TASK_NAME", "should be overridden by task")
|
||||
|
||||
testenv := "TESTENV_" + strings.ReplaceAll(uuid.Generate(), "-", "")
|
||||
os.Setenv(testenv, "MY_TEST_VALUE")
|
||||
defer os.Unsetenv(testenv)
|
||||
t.Setenv(testenv, "MY_TEST_VALUE")
|
||||
|
||||
// Make a template that will render immediately
|
||||
content := `Hello Nomad Task: {{env "NOMAD_TASK_NAME"}}
|
||||
|
||||
Reference in New Issue
Block a user