diff --git a/command/force_leave_test.go b/command/force_leave_test.go index 6b66b4fb1c..40a2224f7b 100644 --- a/command/force_leave_test.go +++ b/command/force_leave_test.go @@ -2,12 +2,12 @@ package command import ( "fmt" + "github.com/hashicorp/consul/testutil" "github.com/hashicorp/serf/serf" - "github.com/hashicorp/serf/testutil" "github.com/mitchellh/cli" "strings" "testing" - "time" + "errors" ) func TestForceLeaveCommand_implements(t *testing.T) { @@ -26,13 +26,9 @@ func TestForceLeaveCommandRun(t *testing.T) { t.Fatalf("err: %s", err) } - testutil.Yield() - // Forcibly shutdown a2 so that it appears "failed" in a1 a2.Shutdown() - time.Sleep(time.Second) - ui := new(cli.MockUi) c := &ForceLeaveCommand{Ui: ui} args := []string{ @@ -50,9 +46,14 @@ func TestForceLeaveCommandRun(t *testing.T) { t.Fatalf("should have 2 members: %#v", m) } - if m[1].Status != serf.StatusLeft { - t.Fatalf("should be left: %#v", m[1]) - } + testutil.WaitForResult(func() (bool, error) { + m = a1.agent.LANMembers() + success := m[1].Status == serf.StatusLeft + err := errors.New(m[1].Status.String()) + return success, err + }, func(err error) { + t.Fatalf("member status is %v, not left", err) + }) } func TestForceLeaveCommandRun_noAddrs(t *testing.T) {