From 16bfc8fd1d1781886374cd15cef65081ce496cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Tisa=CC=88ter?= Date: Fri, 9 May 2014 03:05:38 +0200 Subject: [PATCH] Fix race condition in `TestLeader_RegisterMember` --- consul/leader_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/consul/leader_test.go b/consul/leader_test.go index 39935c2ae..b99924eeb 100644 --- a/consul/leader_test.go +++ b/consul/leader_test.go @@ -31,10 +31,12 @@ func TestLeader_RegisterMember(t *testing.T) { // Client should be registered state := s1.fsm.State() - _, found, _ := state.GetNode(c1.config.NodeName) - if !found { + testutil.WaitForResult(func() (bool, error) { + _, found, _ := state.GetNode(c1.config.NodeName) + return found == true, nil + }, func(err error) { t.Fatalf("client not registered") - } + }) // Should have a check _, checks := state.NodeChecks(c1.config.NodeName) @@ -52,7 +54,7 @@ func TestLeader_RegisterMember(t *testing.T) { } // Server should be registered - _, found, _ = state.GetNode(s1.config.NodeName) + _, found, _ := state.GetNode(s1.config.NodeName) if !found { t.Fatalf("server not registered") }