|
|
@@ -130,11 +130,11 @@ func TestNodePropose(t *testing.T) {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ n := newNode(rn)
|
|
|
r := rn.raft
|
|
|
- go n.run(rn)
|
|
|
+ go n.run()
|
|
|
if err := n.Campaign(context.TODO()); err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
@@ -173,13 +173,13 @@ func TestNodeReadIndex(t *testing.T) {
|
|
|
}
|
|
|
wrs := []ReadState{{Index: uint64(1), RequestCtx: []byte("somedata")}}
|
|
|
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ n := newNode(rn)
|
|
|
r := rn.raft
|
|
|
r.readStates = wrs
|
|
|
|
|
|
- go n.run(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
for {
|
|
|
rd := <-n.Ready()
|
|
|
@@ -311,11 +311,11 @@ func TestNodeProposeConfig(t *testing.T) {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ n := newNode(rn)
|
|
|
r := rn.raft
|
|
|
- go n.run(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
for {
|
|
|
rd := <-n.Ready()
|
|
|
@@ -350,10 +350,10 @@ func TestNodeProposeConfig(t *testing.T) {
|
|
|
// TestNodeProposeAddDuplicateNode ensures that two proposes to add the same node should
|
|
|
// not affect the later propose to add new node.
|
|
|
func TestNodeProposeAddDuplicateNode(t *testing.T) {
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
- go n.run(rn)
|
|
|
+ n := newNode(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
rdyEntries := make([]raftpb.Entry, 0)
|
|
|
ticker := time.NewTicker(time.Millisecond * 100)
|
|
|
@@ -426,9 +426,9 @@ func TestNodeProposeAddDuplicateNode(t *testing.T) {
|
|
|
// know who is the current leader; node will accept proposal when it knows
|
|
|
// who is the current leader.
|
|
|
func TestBlockProposal(t *testing.T) {
|
|
|
- n := newNode()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, NewMemoryStorage())
|
|
|
- go n.run(rn)
|
|
|
+ n := newNode(rn)
|
|
|
+ go n.run()
|
|
|
defer n.Stop()
|
|
|
|
|
|
errc := make(chan error, 1)
|
|
|
@@ -466,11 +466,11 @@ func TestNodeProposeWaitDropped(t *testing.T) {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ n := newNode(rn)
|
|
|
r := rn.raft
|
|
|
- go n.run(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
for {
|
|
|
rd := <-n.Ready()
|
|
|
@@ -501,11 +501,11 @@ func TestNodeProposeWaitDropped(t *testing.T) {
|
|
|
// TestNodeTick ensures that node.Tick() will increase the
|
|
|
// elapsed of the underlying raft state machine.
|
|
|
func TestNodeTick(t *testing.T) {
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ n := newNode(rn)
|
|
|
r := rn.raft
|
|
|
- go n.run(rn)
|
|
|
+ go n.run()
|
|
|
elapsed := r.electionElapsed
|
|
|
n.Tick()
|
|
|
|
|
|
@@ -522,13 +522,12 @@ func TestNodeTick(t *testing.T) {
|
|
|
// TestNodeStop ensures that node.Stop() blocks until the node has stopped
|
|
|
// processing, and that it is idempotent
|
|
|
func TestNodeStop(t *testing.T) {
|
|
|
- n := newNode()
|
|
|
- s := NewMemoryStorage()
|
|
|
- rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
+ rn := newTestRawNode(1, []uint64{1}, 10, 1, NewMemoryStorage())
|
|
|
+ n := newNode(rn)
|
|
|
donec := make(chan struct{})
|
|
|
|
|
|
go func() {
|
|
|
- n.run(rn)
|
|
|
+ n.run()
|
|
|
close(donec)
|
|
|
}()
|
|
|
|
|
|
@@ -813,10 +812,10 @@ func TestIsHardStateEqual(t *testing.T) {
|
|
|
func TestNodeProposeAddLearnerNode(t *testing.T) {
|
|
|
ticker := time.NewTicker(time.Millisecond * 100)
|
|
|
defer ticker.Stop()
|
|
|
- n := newNode()
|
|
|
s := NewMemoryStorage()
|
|
|
rn := newTestRawNode(1, []uint64{1}, 10, 1, s)
|
|
|
- go n.run(rn)
|
|
|
+ n := newNode(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
stop := make(chan struct{})
|
|
|
done := make(chan struct{})
|
|
|
@@ -914,8 +913,8 @@ func TestCommitPagination(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- n := newNode()
|
|
|
- go n.run(rn)
|
|
|
+ n := newNode(rn)
|
|
|
+ go n.run()
|
|
|
n.Campaign(context.TODO())
|
|
|
|
|
|
rd := readyWithTimeout(&n)
|
|
|
@@ -1006,8 +1005,8 @@ func TestNodeCommitPaginationAfterRestart(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
- n := newNode()
|
|
|
- go n.run(rn)
|
|
|
+ n := newNode(rn)
|
|
|
+ go n.run()
|
|
|
defer n.Stop()
|
|
|
|
|
|
rd := readyWithTimeout(&n)
|