|
|
@@ -303,6 +303,7 @@ func TestNodeProposeAddDuplicateNode(t *testing.T) {
|
|
|
ticker := time.NewTicker(time.Millisecond * 100)
|
|
|
done := make(chan struct{})
|
|
|
stop := make(chan struct{})
|
|
|
+ applyChan := make(chan struct{})
|
|
|
go func() {
|
|
|
defer close(done)
|
|
|
for {
|
|
|
@@ -324,21 +325,22 @@ func TestNodeProposeAddDuplicateNode(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
n.Advance()
|
|
|
+ applyChan <- struct{}{}
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
cc1 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
|
|
|
ccdata1, _ := cc1.Marshal()
|
|
|
n.ProposeConfChange(context.TODO(), cc1)
|
|
|
- time.Sleep(time.Millisecond * 10)
|
|
|
+ <-applyChan
|
|
|
// try add the same node again
|
|
|
n.ProposeConfChange(context.TODO(), cc1)
|
|
|
- time.Sleep(time.Millisecond * 10)
|
|
|
+ <-applyChan
|
|
|
// 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.Millisecond * 10)
|
|
|
+ <-applyChan
|
|
|
close(stop)
|
|
|
<-done
|
|
|
|