浏览代码

raft: flush the commit to fix a race in test

Xiang Li 11 年之前
父节点
当前提交
896bac1f76
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      raft/raft_test.go

+ 3 - 1
raft/raft_test.go

@@ -451,8 +451,10 @@ func TestCandidateConcede(t *testing.T) {
 	tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgBeat})
 	tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgBeat})
 
 
 	data := []byte("force follower")
 	data := []byte("force follower")
-	// send a proposal to 2 to flush out a MsgApp to 0
+	// send a proposal to 3 to flush out a MsgApp to 1
 	tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
 	tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
+	// send heartbeat; flush out commit
+	tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgBeat})
 
 
 	a := tt.peers[1].(*raft)
 	a := tt.peers[1].(*raft)
 	if g := a.state; g != StateFollower {
 	if g := a.state; g != StateFollower {