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
This commit is contained in:
Pierre Souchay 2018-11-20 12:27:26 +01:00 committed by Paul Banks
parent 559b2b63e0
commit d0ca1bade9
6 changed files with 14 additions and 5 deletions

View File

@ -41,7 +41,7 @@ func TestRPC_NoLeader_Fail(t *testing.T) {
} }
// Now make sure it goes through. // 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) err = msgpackrpc.CallWithCodec(codec, "Catalog.Register", &arg, &out)
if err != nil { if err != nil {
t.Fatalf("bad: %v", err) 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) 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 { if err := msgpackrpc.CallWithCodec(codec, "KVS.ListKeys", &getKeysReq, &keyList); err != nil {
t.Fatalf("Did not expect any error but got err: %v", err) t.Fatalf("Did not expect any error but got err: %v", err)
} }

View File

@ -506,6 +506,7 @@ func TestServer_JoinLAN_TLS(t *testing.T) {
} }
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
dir2, conf2 := testServerConfig(t) dir2, conf2 := testServerConfig(t)
conf2.Bootstrap = false conf2.Bootstrap = false
@ -521,6 +522,7 @@ func TestServer_JoinLAN_TLS(t *testing.T) {
// Try to join // Try to join
joinLAN(t, s2, s1) joinLAN(t, s2, s1)
testrpc.WaitForTestAgent(t, s2.RPC, "dc1")
// Verify Raft has established a peer // Verify Raft has established a peer
retry.Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {

View File

@ -41,7 +41,7 @@ func TestStatusLeader(t *testing.T) {
t.Fatalf("unexpected leader: %v", leader) 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 { if err := msgpackrpc.CallWithCodec(codec, "Status.Leader", arg, &leader); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)

View File

@ -1803,7 +1803,7 @@ func TestDNS_NSRecords(t *testing.T) {
node_name = "server1" node_name = "server1"
`) `)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForLeader(t, a.RPC, "dc1") testrpc.WaitForTestAgent(t, a.RPC, "dc1")
m := new(dns.Msg) m := new(dns.Msg)
m.SetQuestion("something.node.consul.", dns.TypeNS) m.SetQuestion("something.node.consul.", dns.TypeNS)
@ -1839,7 +1839,7 @@ func TestDNS_NSRecords_IPV6(t *testing.T) {
advertise_addr = "::1" advertise_addr = "::1"
`) `)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForLeader(t, a.RPC, "dc1") testrpc.WaitForTestAgent(t, a.RPC, "dc1")
m := new(dns.Msg) m := new(dns.Msg)
m.SetQuestion("server1.node.dc1.consul.", dns.TypeNS) m.SetQuestion("server1.node.dc1.consul.", dns.TypeNS)

View File

@ -9,6 +9,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/hashicorp/consul/testrpc"
"github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/logger"
) )
@ -62,6 +64,7 @@ func TestHTTPAPI_MethodNotAllowed_OSS(t *testing.T) {
a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`) a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`)
a.Agent.LogWriter = logger.NewLogWriter(512) a.Agent.LogWriter = logger.NewLogWriter(512)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
all := []string{"GET", "PUT", "POST", "DELETE", "HEAD", "OPTIONS"} all := []string{"GET", "PUT", "POST", "DELETE", "HEAD", "OPTIONS"}
const testTimeout = 10 * time.Second const testTimeout = 10 * time.Second
@ -123,6 +126,7 @@ func TestHTTPAPI_OptionMethod_OSS(t *testing.T) {
a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`) a := NewTestAgent(t.Name(), `acl_datacenter = "dc1"`)
a.Agent.LogWriter = logger.NewLogWriter(512) a.Agent.LogWriter = logger.NewLogWriter(512)
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
testOptionMethod := func(path string, methods []string) { testOptionMethod := func(path string, methods []string) {
t.Run("OPTIONS "+path, func(t *testing.T) { t.Run("OPTIONS "+path, func(t *testing.T) {

View File

@ -3,12 +3,15 @@ package agent
import ( import (
"net/http" "net/http"
"testing" "testing"
"github.com/hashicorp/consul/testrpc"
) )
func TestStatusLeader(t *testing.T) { func TestStatusLeader(t *testing.T) {
t.Parallel() t.Parallel()
a := NewTestAgent(t.Name(), "") a := NewTestAgent(t.Name(), "")
defer a.Shutdown() defer a.Shutdown()
testrpc.WaitForLeader(t, a.RPC, "dc1")
req, _ := http.NewRequest("GET", "/v1/status/leader", nil) req, _ := http.NewRequest("GET", "/v1/status/leader", nil)
obj, err := a.srv.StatusLeader(nil, req) obj, err := a.srv.StatusLeader(nil, req)