Merge pull request #7092 from xiang90/fix_raft

raft: use status to test node stop
This commit is contained in:
Xiang Li 2017-01-04 09:13:11 -08:00 committed by GitHub
commit 37501e2a5d

View File

@ -422,9 +422,7 @@ func TestNodeStop(t *testing.T) {
close(donec)
}()
elapsed := r.electionElapsed
n.Tick()
testutil.WaitSchedule()
status := n.Status()
n.Stop()
select {
@ -433,13 +431,15 @@ func TestNodeStop(t *testing.T) {
t.Fatalf("timed out waiting for node to stop!")
}
if r.electionElapsed != elapsed+1 {
t.Errorf("elapsed = %d, want %d", r.electionElapsed, elapsed+1)
emptyStatus := Status{}
if reflect.DeepEqual(status, emptyStatus) {
t.Errorf("status = %v, want not empty", status)
}
// Further ticks should have no effect, the node is stopped.
n.Tick()
if r.electionElapsed != elapsed+1 {
t.Errorf("elapsed = %d, want %d", r.electionElapsed, elapsed+1)
// Further status should return be empty, the node is stopped.
status = n.Status()
if !reflect.DeepEqual(status, emptyStatus) {
t.Errorf("status = %v, want empty", status)
}
// Subsequent Stops should have no effect.
n.Stop()