From 4685e1c51f75df8de41b74b4208c5687c057aa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Tis=C3=A4ter?= Date: Mon, 26 May 2014 23:49:23 +0200 Subject: [PATCH] Revert "Remove `WaitForResult` from two failing tests" This reverts commit f0842409cde194ce2102ff2baf3de821cb6ac9d5. --- consul/client_test.go | 9 +++++---- consul/server_test.go | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/consul/client_test.go b/consul/client_test.go index 4acc8e4b0a..10ab0fde7f 100644 --- a/consul/client_test.go +++ b/consul/client_test.go @@ -173,10 +173,11 @@ func TestClient_RPC_TLS(t *testing.T) { t.Fatalf("bad len") } - time.Sleep(100 * time.Millisecond) - // RPC should succeed - if err := c1.RPC("Status.Ping", struct{}{}, &out); err != nil { + testutil.WaitForResult(func() (bool, error) { + err := c1.RPC("Status.Ping", struct{}{}, &out) + return err == nil, err + }, func(err error) { t.Fatalf("err: %v", err) - } + }) } diff --git a/consul/server_test.go b/consul/server_test.go index 36b2b513c7..dc984ba35a 100644 --- a/consul/server_test.go +++ b/consul/server_test.go @@ -291,13 +291,16 @@ func TestServer_JoinLAN_TLS(t *testing.T) { t.Fatalf("bad len") }) - time.Sleep(100 * time.Millisecond) - // Verify Raft has established a peer - if s1.Stats()["raft"]["num_peers"] != "1" { - t.Fatalf("bad: %v", s1.Stats()["raft"]) - } - if s2.Stats()["raft"]["num_peers"] != "1" { - t.Fatalf("bad: %v", s2.Stats()["raft"]) - } + testutil.WaitForResult(func() (bool, error) { + return s1.Stats()["raft"]["num_peers"] == "1", nil + }, func(err error) { + t.Fatalf("no peer established") + }) + + testutil.WaitForResult(func() (bool, error) { + return s2.Stats()["raft"]["num_peers"] == "1", nil + }, func(err error) { + t.Fatalf("no peer established") + }) }