Skip to content

Commit

Permalink
consul: fix server left test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanuber committed Jan 10, 2015
1 parent 757c850 commit 2c9bb57
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions consul/leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,23 +310,24 @@ func TestLeader_LeftServer(t *testing.T) {
})
}

// Kill any server
servers[0].Shutdown()
time.Sleep(100 * time.Millisecond)
testutil.WaitForResult(func() (bool, error) {
// Kill any server
servers[0].Shutdown()

// Force remove the non-leader (transition to left state)
if err := servers[1].RemoveFailedNode(servers[0].config.NodeName); err != nil {
t.Fatalf("err: %v", err)
}
// Force remove the non-leader (transition to left state)
if err := servers[1].RemoveFailedNode(servers[0].config.NodeName); err != nil {
t.Fatalf("err: %v", err)
}

for _, s := range servers[1:] {
testutil.WaitForResult(func() (bool, error) {
for _, s := range servers[1:] {
peers, _ := s.raftPeers.Peers()
return len(peers) == 2, errors.New(fmt.Sprintf("%v", peers))
}, func(err error) {
t.Fatalf("should have 2 peers: %v", err)
})
}
}

return true, nil
}, func(err error) {
t.Fatalf("err: %s", err)
})
}

func TestLeader_LeftLeader(t *testing.T) {
Expand Down

0 comments on commit 2c9bb57

Please sign in to comment.