Skip to content

Commit

Permalink
Turns off script checks by default in unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackpad committed Jul 17, 2017
1 parent 211d18d commit d29a27f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
27 changes: 18 additions & 9 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion agent/testagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion api/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ func defaultServerConfig() *TestServerConfig {
Server: randomPort(),
RPC: randomPort(),
},
EnableScriptChecks: true,
ReadyTimeout: 10 * time.Second,
ReadyTimeout: 10 * time.Second,
}
}

Expand Down

0 comments on commit d29a27f

Please sign in to comment.