Browse Source

raft: fix test case, should wait config propose applied

Vincent Lee 9 years ago
parent
commit
62bd5477b9
1 changed files with 3 additions and 1 deletions
  1. 3 1
      raft/node_test.go

+ 3 - 1
raft/node_test.go

@@ -325,13 +325,15 @@ func TestNodeProposeAddDuplicateNode(t *testing.T) {
 	cc1 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
 	ccdata1, _ := cc1.Marshal()
 	n.ProposeConfChange(context.TODO(), cc1)
+	time.Sleep(time.Millisecond * 10)
 	// try add the same node again
 	n.ProposeConfChange(context.TODO(), cc1)
+	time.Sleep(time.Millisecond * 10)
 	// the new node join should be ok
 	cc2 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 2}
 	ccdata2, _ := cc2.Marshal()
 	n.ProposeConfChange(context.TODO(), cc2)
-	time.Sleep(time.Second)
+	time.Sleep(time.Millisecond * 10)
 
 	if len(rdyEntries) != 4 {
 		t.Errorf("len(entry) = %d, want %d, %v\n", len(rdyEntries), 3, rdyEntries)