From e1d850c081d89eb2fca544b055981a896cd82ce5 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Tue, 25 Oct 2016 14:58:45 -0700 Subject: [PATCH] Add wait logic to TestClient_RPC_Pool --- consul/client_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/consul/client_test.go b/consul/client_test.go index b4d932b38b..156327ebf3 100644 --- a/consul/client_test.go +++ b/consul/client_test.go @@ -211,9 +211,14 @@ func TestClient_RPC_Pool(t *testing.T) { if _, err := c1.JoinLAN([]string{addr}); err != nil { t.Fatalf("err: %v", err) } - if len(s1.LANMembers()) != 2 || len(c1.LANMembers()) != 2 { - t.Fatalf("Server has %v of %v expected members; Client has %v of %v expected members.", len(s1.LANMembers()), 2, len(c1.LANMembers()), 2) - } + + // Wait for both agents to finish joining + testutil.WaitForResult(func() (bool, error) { + return len(s1.LANMembers()) == 2 && len(c1.LANMembers()) == 2, nil + }, func(err error) { + t.Fatalf("Server has %v of %v expected members; Client has %v of %v expected members.", + len(s1.LANMembers()), 2, len(c1.LANMembers()), 2) + }) // Blast out a bunch of RPC requests at the same time to try to get // contention opening new connections.