From 78328ec149cd5c55e15e4fbc7fac3f3d60b0462c Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Tue, 13 Jan 2015 11:25:19 -0800 Subject: [PATCH] api: make node health test more reliable --- api/health_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/api/health_test.go b/api/health_test.go index 9a00645d1e..e445910240 100644 --- a/api/health_test.go +++ b/api/health_test.go @@ -20,17 +20,21 @@ func TestHealth_Node(t *testing.T) { } name := info["Config"]["NodeName"].(string) - checks, meta, err := health.Node(name, nil) - if err != nil { - t.Fatalf("err: %v", err) - } - - if meta.LastIndex == 0 { - t.Fatalf("bad: %v", meta) - } - if len(checks) == 0 { - t.Fatalf("Bad: %v", checks) - } + testutil.WaitForResult(func() (bool, error) { + checks, meta, err := health.Node(name, nil) + if err != nil { + return false, err + } + if meta.LastIndex == 0 { + return false, fmt.Errorf("bad: %v", meta) + } + if len(checks) == 0 { + return false, fmt.Errorf("bad: %v", checks) + } + return true, nil + }, func(err error) { + t.Fatalf("err: %s", err) + }) } func TestHealth_Checks(t *testing.T) {