From c5ae9caa282c1348f4f97ced8f0f7b9c25b723c9 Mon Sep 17 00:00:00 2001 From: Pierre Souchay Date: Tue, 20 Nov 2018 12:27:26 +0100 Subject: [PATCH] Fixed another list of unstable unit tests in travis (#4915) * Fixed another list of unstable unit tests in travis Fixed failing tests in https://travis-ci.org/hashicorp/consul/jobs/451357061 * Fixed another list of unstable unit tests in travis. Fixed failing tests in https://travis-ci.org/hashicorp/consul/jobs/451357061 --- agent/consul/rpc_test.go | 4 ++-- agent/consul/server_test.go | 2 ++ agent/consul/status_endpoint_test.go | 2 +- agent/dns_test.go | 4 ++-- agent/http_oss_test.go | 4 ++++ agent/status_endpoint_test.go | 3 +++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/agent/consul/rpc_test.go b/agent/consul/rpc_test.go index cd4e3d0aa1..75a619b6bc 100644 --- a/agent/consul/rpc_test.go +++ b/agent/consul/rpc_test.go @@ -41,7 +41,7 @@ func TestRPC_NoLeader_Fail(t *testing.T) { } // Now make sure it goes through. - testrpc.WaitForLeader(t, s1.RPC, "dc1") + testrpc.WaitForTestAgent(t, s1.RPC, "dc1") err = msgpackrpc.CallWithCodec(codec, "Catalog.Register", &arg, &out) if err != nil { t.Fatalf("bad: %v", err) @@ -84,7 +84,7 @@ func TestRPC_NoLeader_Fail_on_stale_read(t *testing.T) { t.Fatalf("expected %v but got err: %v", structs.ErrNoLeader, err) } - testrpc.WaitForLeader(t, s1.RPC, "dc1") + testrpc.WaitForTestAgent(t, s1.RPC, "dc1") if err := msgpackrpc.CallWithCodec(codec, "KVS.ListKeys", &getKeysReq, &keyList); err != nil { t.Fatalf("Did not expect any error but got err: %v", err) } diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index 82e7136c21..de53962707 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -506,6 +506,7 @@ func TestServer_JoinLAN_TLS(t *testing.T) { } defer os.RemoveAll(dir1) defer s1.Shutdown() + testrpc.WaitForTestAgent(t, s1.RPC, "dc1") dir2, conf2 := testServerConfig(t) conf2.Bootstrap = false @@ -521,6 +522,7 @@ func TestServer_JoinLAN_TLS(t *testing.T) { // Try to join joinLAN(t, s2, s1) + testrpc.WaitForTestAgent(t, s2.RPC, "dc1") // Verify Raft has established a peer retry.Run(t, func(r *retry.R) { diff --git a/agent/consul/status_endpoint_test.go b/agent/consul/status_endpoint_test.go index 4c8e360d95..96ba125734 100644 --- a/agent/consul/status_endpoint_test.go +++ b/agent/consul/status_endpoint_test.go @@ -41,7 +41,7 @@ func TestStatusLeader(t *testing.T) { t.Fatalf("unexpected leader: %v", leader) } - testrpc.WaitForLeader(t, s1.RPC, "dc1") + testrpc.WaitForTestAgent(t, s1.RPC, "dc1") if err := msgpackrpc.CallWithCodec(codec, "Status.Leader", arg, &leader); err != nil { t.Fatalf("err: %v", err) diff --git a/agent/dns_test.go b/agent/dns_test.go index 1613852df2..00edf257d4 100644 --- a/agent/dns_test.go +++ b/agent/dns_test.go @@ -1803,7 +1803,7 @@ func TestDNS_NSRecords(t *testing.T) { node_name = "server1" `) defer a.Shutdown() - testrpc.WaitForLeader(t, a.RPC, "dc1") + testrpc.WaitForTestAgent(t, a.RPC, "dc1") m := new(dns.Msg) m.SetQuestion("something.node.consul.", dns.TypeNS) @@ -1839,7 +1839,7 @@ func TestDNS_NSRecords_IPV6(t *testing.T) { advertise_addr = "::1" `) defer a.Shutdown() - testrpc.WaitForLeader(t, a.RPC, "dc1") + testrpc.WaitForTestAgent(t, a.RPC, "dc1") m := new(dns.Msg) m.SetQuestion("server1.node.dc1.consul.", dns.TypeNS) diff --git a/agent/http_oss_test.go b/agent/http_oss_test.go index a9b9014a85..502273cb84 100644 --- a/agent/http_oss_test.go +++ b/agent/http_oss_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/testrpc" + "github.com/hashicorp/consul/logger" ) @@ -62,6 +64,7 @@ func TestHTTPAPI_MethodNotAllowed_OSS(t *testing.T) { a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`) a.Agent.LogWriter = logger.NewLogWriter(512) defer a.Shutdown() + testrpc.WaitForTestAgent(t, a.RPC, "dc1") all := []string{"GET", "PUT", "POST", "DELETE", "HEAD", "OPTIONS"} const testTimeout = 10 * time.Second @@ -123,6 +126,7 @@ func TestHTTPAPI_OptionMethod_OSS(t *testing.T) { a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`) a.Agent.LogWriter = logger.NewLogWriter(512) defer a.Shutdown() + testrpc.WaitForTestAgent(t, a.RPC, "dc1") testOptionMethod := func(path string, methods []string) { t.Run("OPTIONS "+path, func(t *testing.T) { diff --git a/agent/status_endpoint_test.go b/agent/status_endpoint_test.go index 79d1662b5b..ca7be5bec9 100644 --- a/agent/status_endpoint_test.go +++ b/agent/status_endpoint_test.go @@ -3,12 +3,15 @@ package agent import ( "net/http" "testing" + + "github.com/hashicorp/consul/testrpc" ) func TestStatusLeader(t *testing.T) { t.Parallel() a := NewTestAgent(t.Name(), "") defer a.Shutdown() + testrpc.WaitForLeader(t, a.RPC, "dc1") req, _ := http.NewRequest("GET", "/v1/status/leader", nil) obj, err := a.srv.StatusLeader(nil, req)