From 2d54ee2925ca1ed91f35e6f0f8204db11b333e26 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 3 May 2017 15:14:19 -0700 Subject: [PATCH] Fix tests --- client/alloc_runner_test.go | 1 + client/driver/driver_test.go | 6 +++++- client/task_runner_test.go | 1 + command/agent/consul/int_test.go | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/alloc_runner_test.go b/client/alloc_runner_test.go index f1bc828b8..2c1028704 100644 --- a/client/alloc_runner_test.go +++ b/client/alloc_runner_test.go @@ -32,6 +32,7 @@ func (m *MockAllocStateUpdater) Update(alloc *structs.Allocation) { func testAllocRunnerFromAlloc(alloc *structs.Allocation, restarts bool) (*MockAllocStateUpdater, *AllocRunner) { logger := testLogger() conf := config.DefaultConfig() + conf.Node = mock.Node() conf.StateDir = os.TempDir() conf.AllocDir = os.TempDir() upd := &MockAllocStateUpdater{} diff --git a/client/driver/driver_test.go b/client/driver/driver_test.go index c64ee1e79..21fcd1eb3 100644 --- a/client/driver/driver_test.go +++ b/client/driver/driver_test.go @@ -74,6 +74,8 @@ func testConfig() *config.Config { conf.StateDir = os.TempDir() conf.AllocDir = os.TempDir() conf.MaxKillTimeout = 10 * time.Second + conf.Region = "global" + conf.Node = mock.Node() return conf } @@ -163,7 +165,7 @@ func setupTaskEnv(t *testing.T, driver string) (*allocdir.TaskDir, map[string]st conf := testConfig() allocDir := allocdir.NewAllocDir(testLogger(), filepath.Join(conf.AllocDir, alloc.ID)) taskDir := allocDir.NewTaskDir(task.Name) - env, err := GetTaskEnv(taskDir, nil, task, alloc, conf, "") + env, err := GetTaskEnv(taskDir, conf.Node, task, alloc, conf, "") if err != nil { t.Fatalf("GetTaskEnv() failed: %v", err) } @@ -210,6 +212,8 @@ func setupTaskEnv(t *testing.T, driver string) (*allocdir.TaskDir, map[string]st "NOMAD_ALLOC_NAME": alloc.Name, "NOMAD_TASK_NAME": task.Name, "NOMAD_JOB_NAME": alloc.Job.Name, + "NOMAD_DC": "dc1", + "NOMAD_REGION": "global", } act := env.EnvMap() diff --git a/client/task_runner_test.go b/client/task_runner_test.go index ede8cb164..cabc13799 100644 --- a/client/task_runner_test.go +++ b/client/task_runner_test.go @@ -74,6 +74,7 @@ func testTaskRunner(t *testing.T, restarts bool) *taskRunnerTestCtx { func testTaskRunnerFromAlloc(t *testing.T, restarts bool, alloc *structs.Allocation) *taskRunnerTestCtx { logger := testLogger() conf := config.DefaultConfig() + conf.Node = mock.Node() conf.StateDir = os.TempDir() conf.AllocDir = os.TempDir() upd := &MockTaskStateUpdater{} diff --git a/command/agent/consul/int_test.go b/command/agent/consul/int_test.go index 9243b5822..764f9fd46 100644 --- a/command/agent/consul/int_test.go +++ b/command/agent/consul/int_test.go @@ -54,6 +54,7 @@ func TestConsul_Integration(t *testing.T) { defer testconsul.Stop() conf := config.DefaultConfig() + conf.Node = mock.Node() conf.ConsulConfig.Addr = testconsul.HTTPAddr consulConfig, err := conf.ConsulConfig.ApiConfig() if err != nil {