Fixed more flaky tests in ./agent/consul (#4617)

This commit is contained in:
Pierre Souchay 2018-09-04 15:02:47 +02:00 committed by Freddy
parent c01b410cf5
commit 9a2ae6e8eb
5 changed files with 10 additions and 11 deletions

View File

@ -165,11 +165,10 @@ func TestCatalog_Register_ACLDeny(t *testing.T) {
}) })
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
codec := rpcClient(t, s1) codec := rpcClient(t, s1)
defer codec.Close() defer codec.Close()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
// Create the ACL. // Create the ACL.
arg := structs.ACLRequest{ arg := structs.ACLRequest{
Datacenter: "dc1", Datacenter: "dc1",

View File

@ -290,6 +290,8 @@ func TestLeader_ReapServer(t *testing.T) {
joinLAN(t, s1, s3) joinLAN(t, s1, s3)
testrpc.WaitForLeader(t, s1.RPC, "dc1") testrpc.WaitForLeader(t, s1.RPC, "dc1")
testrpc.WaitForLeader(t, s2.RPC, "dc1")
testrpc.WaitForLeader(t, s3.RPC, "dc1")
state := s1.fsm.State() state := s1.fsm.State()
// s3 should be registered // s3 should be registered
@ -888,6 +890,7 @@ func TestLeader_ChangeServerID(t *testing.T) {
joinLAN(t, s2, s1) joinLAN(t, s2, s1)
joinLAN(t, s3, s1) joinLAN(t, s3, s1)
for _, s := range servers { for _, s := range servers {
testrpc.WaitForTestAgent(t, s.RPC, "dc1")
retry.Run(t, func(r *retry.R) { r.Check(wantPeers(s, 3)) }) retry.Run(t, func(r *retry.R) { r.Check(wantPeers(s, 3)) })
} }

View File

@ -238,10 +238,10 @@ func TestRTT_sortNodesByDistanceFrom_ServiceNodes(t *testing.T) {
dir, server := testServer(t) dir, server := testServer(t)
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
defer server.Shutdown() defer server.Shutdown()
testrpc.WaitForTestAgent(t, server.RPC, "dc1")
codec := rpcClient(t, server) codec := rpcClient(t, server)
defer codec.Close() defer codec.Close()
testrpc.WaitForLeader(t, server.RPC, "dc1")
seedCoordinates(t, codec, server) seedCoordinates(t, codec, server)
nodes := structs.ServiceNodes{ nodes := structs.ServiceNodes{

View File

@ -501,11 +501,10 @@ func TestSession_ApplyTimers(t *testing.T) {
dir1, s1 := testServer(t) dir1, s1 := testServer(t)
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
codec := rpcClient(t, s1) codec := rpcClient(t, s1)
defer codec.Close() defer codec.Close()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
s1.fsm.State().EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"}) s1.fsm.State().EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"})
arg := structs.SessionRequest{ arg := structs.SessionRequest{
Datacenter: "dc1", Datacenter: "dc1",
@ -549,11 +548,10 @@ func TestSession_Renew(t *testing.T) {
}) })
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
codec := rpcClient(t, s1) codec := rpcClient(t, s1)
defer codec.Close() defer codec.Close()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
s1.fsm.State().EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"}) s1.fsm.State().EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"})
ids := []string{} ids := []string{}
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
@ -713,11 +711,10 @@ func TestSession_Renew_ACLDeny(t *testing.T) {
}) })
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
codec := rpcClient(t, s1) codec := rpcClient(t, s1)
defer codec.Close() defer codec.Close()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
// Create the ACL. // Create the ACL.
req := structs.ACLRequest{ req := structs.ACLRequest{
Datacenter: "dc1", Datacenter: "dc1",

View File

@ -311,11 +311,11 @@ func TestSnapshot_Forward_Leader(t *testing.T) {
}) })
defer os.RemoveAll(dir2) defer os.RemoveAll(dir2)
defer s2.Shutdown() defer s2.Shutdown()
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
// Try to join. // Try to join.
joinLAN(t, s2, s1) joinLAN(t, s2, s1)
testrpc.WaitForLeader(t, s1.RPC, "dc1") testrpc.WaitForTestAgent(t, s2.RPC, "dc1")
testrpc.WaitForLeader(t, s2.RPC, "dc1")
// Run against the leader and the follower to ensure we forward. When // Run against the leader and the follower to ensure we forward. When
// we changed to Raft protocol version 3, since we only have two servers, // we changed to Raft protocol version 3, since we only have two servers,