From d29a27f248d795df5740e617c189cb7580e7bb1e Mon Sep 17 00:00:00 2001 From: James Phillips Date: Mon, 17 Jul 2017 11:14:23 -0700 Subject: [PATCH] Turns off script checks by default in unit tests. --- agent/agent_test.go | 27 ++++++++++++++++++--------- agent/testagent.go | 1 - api/agent_test.go | 4 +++- testutil/server.go | 3 +-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index 4792acc152f3..c19ab9832333 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -628,7 +628,9 @@ func TestAgent_RemoveServiceRemovesAllChecks(t *testing.T) { func TestAgent_AddCheck(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + cfg := TestConfig() + cfg.EnableScriptChecks = true + a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() health := &structs.HealthCheck{ @@ -665,7 +667,9 @@ func TestAgent_AddCheck(t *testing.T) { func TestAgent_AddCheck_StartPassing(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + cfg := TestConfig() + cfg.EnableScriptChecks = true + a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() health := &structs.HealthCheck{ @@ -702,7 +706,9 @@ func TestAgent_AddCheck_StartPassing(t *testing.T) { func TestAgent_AddCheck_MinInterval(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + cfg := TestConfig() + cfg.EnableScriptChecks = true + a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() health := &structs.HealthCheck{ @@ -735,7 +741,9 @@ func TestAgent_AddCheck_MinInterval(t *testing.T) { func TestAgent_AddCheck_MissingService(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + cfg := TestConfig() + cfg.EnableScriptChecks = true + a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() health := &structs.HealthCheck{ @@ -800,10 +808,7 @@ func TestAgent_AddCheck_RestoreState(t *testing.T) { func TestAgent_AddCheck_ExecDisable(t *testing.T) { t.Parallel() - cfg := TestConfig() - cfg.EnableScriptChecks = false - - a := NewTestAgent(t.Name(), cfg) + a := NewTestAgent(t.Name(), nil) defer a.Shutdown() health := &structs.HealthCheck{ @@ -829,7 +834,9 @@ func TestAgent_AddCheck_ExecDisable(t *testing.T) { func TestAgent_RemoveCheck(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + cfg := TestConfig() + cfg.EnableScriptChecks = true + a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() // Remove check that doesn't exist @@ -1127,6 +1134,7 @@ func TestAgent_PersistCheck(t *testing.T) { cfg := TestConfig() cfg.Server = false cfg.DataDir = testutil.TempDir(t, "agent") // we manage the data dir + cfg.EnableScriptChecks = true a := NewTestAgent(t.Name(), cfg) defer os.RemoveAll(cfg.DataDir) defer a.Shutdown() @@ -1260,6 +1268,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) { cfg := TestConfig() cfg.Server = false cfg.DataDir = testutil.TempDir(t, "agent") // we manage the data dir + cfg.EnableScriptChecks = true a := NewTestAgent(t.Name(), cfg) defer os.RemoveAll(cfg.DataDir) defer a.Shutdown() diff --git a/agent/testagent.go b/agent/testagent.go index 853619f7fdbc..cf5d98c4db77 100644 --- a/agent/testagent.go +++ b/agent/testagent.go @@ -314,7 +314,6 @@ func TestConfig() *Config { cfg.Datacenter = "dc1" cfg.Bootstrap = true cfg.Server = true - cfg.EnableScriptChecks = true ccfg := consul.DefaultConfig() cfg.ConsulConfig = ccfg diff --git a/api/agent_test.go b/api/agent_test.go index 01ba9f88d3f4..d49630d66071 100644 --- a/api/agent_test.go +++ b/api/agent_test.go @@ -529,7 +529,9 @@ func TestAPI_AgentChecks_serviceBound(t *testing.T) { func TestAPI_AgentChecks_Docker(t *testing.T) { t.Parallel() - c, s := makeClient(t) + c, s := makeClientWithConfig(t, nil, func(c *testutil.TestServerConfig) { + c.EnableScriptChecks = true + }) defer s.Stop() agent := c.Agent() diff --git a/testutil/server.go b/testutil/server.go index 2077da31a8d7..969d06a58481 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -125,8 +125,7 @@ func defaultServerConfig() *TestServerConfig { Server: randomPort(), RPC: randomPort(), }, - EnableScriptChecks: true, - ReadyTimeout: 10 * time.Second, + ReadyTimeout: 10 * time.Second, } }