diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 8e78f24a4..ee50e563c 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -386,8 +386,10 @@ func TestAgent_ConsulService(t *testing.T) { func TestAgent_PersistService(t *testing.T) { config := nextConfig() + config.Server = false dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() svc := &structs.NodeService{ ID: "redis", @@ -444,6 +446,7 @@ func TestAgent_PurgeService(t *testing.T) { config := nextConfig() dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() svc := &structs.NodeService{ ID: "redis", @@ -476,8 +479,10 @@ func TestAgent_PurgeService(t *testing.T) { func TestAgent_PurgeServiceOnDuplicate(t *testing.T) { config := nextConfig() + config.Server = false dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() svc1 := &structs.NodeService{ ID: "redis", @@ -523,8 +528,10 @@ func TestAgent_PurgeServiceOnDuplicate(t *testing.T) { func TestAgent_PersistCheck(t *testing.T) { config := nextConfig() + config.Server = false dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() check := &structs.HealthCheck{ Node: config.NodeName, @@ -597,6 +604,7 @@ func TestAgent_PurgeCheck(t *testing.T) { config := nextConfig() dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() check := &structs.HealthCheck{ Node: config.NodeName, @@ -631,8 +639,10 @@ func TestAgent_PurgeCheck(t *testing.T) { func TestAgent_PurgeCheckOnDuplicate(t *testing.T) { config := nextConfig() + config.Server = false dir, agent := makeAgent(t, config) defer os.RemoveAll(dir) + defer agent.Shutdown() check1 := &structs.HealthCheck{ Node: config.NodeName, diff --git a/consul/server_test.go b/consul/server_test.go index 0d0d1d588..59c220b19 100644 --- a/consul/server_test.go +++ b/consul/server_test.go @@ -256,10 +256,12 @@ func TestServer_Leave(t *testing.T) { } // Should lose a peer - p1, _ = s1.raftPeers.Peers() - if len(p1) != 1 { + testutil.WaitForResult(func() (bool, error) { + p1, _ = s1.raftPeers.Peers() + return len(p1) == 1, nil + }, func(err error) { t.Fatalf("should have 1 peer: %v", p1) - } + }) } func TestServer_RPC(t *testing.T) { @@ -489,6 +491,12 @@ func TestServer_globalRPCErrors(t *testing.T) { defer os.RemoveAll(dir1) defer s1.Shutdown() + testutil.WaitForResult(func() (bool, error) { + return len(s1.remoteConsuls) == 1, nil + }, func(err error) { + t.Fatalf("Server did not join LAN successfully") + }) + // Check that an error from a remote DC is returned err := s1.globalRPC("Bad.Method", nil, &fakeGlobalResp{}) if err == nil {