From 12cd27e588ac10eadd893e91ce7bf1c7fc6ee539 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 9 Jan 2015 16:42:44 -0800 Subject: [PATCH] agent: wrap deferred anti-entropy sync test in WaitForResult --- command/agent/local_test.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/command/agent/local_test.go b/command/agent/local_test.go index b47adb944..49613d0a7 100644 --- a/command/agent/local_test.go +++ b/command/agent/local_test.go @@ -431,20 +431,23 @@ func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) { } // Wait for a deferred update - time.Sleep(100 * time.Millisecond) - if err := agent.RPC("Health.NodeChecks", &req, &checks); err != nil { - t.Fatalf("err: %v", err) - } + testutil.WaitForResult(func() (bool, error) { + if err := agent.RPC("Health.NodeChecks", &req, &checks); err != nil { + return false, err + } - // Verify not updated - for _, chk := range checks.HealthChecks { - switch chk.CheckID { - case "web": - if chk.Output != "output" { - t.Fatalf("no update: %v", chk) + // Verify updated + for _, chk := range checks.HealthChecks { + switch chk.CheckID { + case "web": + if chk.Output != "output" { + return false, fmt.Errorf("no update: %v", chk) + } } } - } + }, func(err error) { + t.Fatalf("err: %s", err) + }) } var testRegisterRules = `