|
|
@@ -391,7 +391,7 @@ func testServer(t *testing.T, ns int64) {
|
|
|
|
|
|
for i := int64(0); i < ns; i++ {
|
|
|
id := i + 1
|
|
|
- n := raft.StartNode(id, members, 10, 1, nil)
|
|
|
+ n := raft.StartNode(id, members, 10, 1)
|
|
|
tk := time.NewTicker(10 * time.Millisecond)
|
|
|
defer tk.Stop()
|
|
|
srv := &EtcdServer{
|
|
|
@@ -458,7 +458,7 @@ func TestDoProposal(t *testing.T) {
|
|
|
|
|
|
for i, tt := range tests {
|
|
|
ctx, _ := context.WithCancel(context.Background())
|
|
|
- n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1, nil)
|
|
|
+ n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1)
|
|
|
st := &storeRecorder{}
|
|
|
tk := make(chan time.Time)
|
|
|
// this makes <-tk always successful, which accelerates internal clock
|
|
|
@@ -491,7 +491,7 @@ func TestDoProposal(t *testing.T) {
|
|
|
func TestDoProposalCancelled(t *testing.T) {
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
// node cannot make any progress because there are two nodes
|
|
|
- n := raft.StartNode(0xBAD0, []int64{0xBAD0, 0xBAD1}, 10, 1, nil)
|
|
|
+ n := raft.StartNode(0xBAD0, []int64{0xBAD0, 0xBAD1}, 10, 1)
|
|
|
st := &storeRecorder{}
|
|
|
wait := &waitRecorder{}
|
|
|
srv := &EtcdServer{
|
|
|
@@ -527,7 +527,7 @@ func TestDoProposalStopped(t *testing.T) {
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
defer cancel()
|
|
|
// node cannot make any progress because there are two nodes
|
|
|
- n := raft.StartNode(0xBAD0, []int64{0xBAD0, 0xBAD1}, 10, 1, nil)
|
|
|
+ n := raft.StartNode(0xBAD0, []int64{0xBAD0, 0xBAD1}, 10, 1)
|
|
|
st := &storeRecorder{}
|
|
|
tk := make(chan time.Time)
|
|
|
// this makes <-tk always successful, which accelarates internal clock
|
|
|
@@ -668,7 +668,7 @@ func TestSyncTrigger(t *testing.T) {
|
|
|
// snapshot should snapshot the store and cut the persistent
|
|
|
// TODO: node.Compact is called... we need to make the node an interface
|
|
|
func TestSnapshot(t *testing.T) {
|
|
|
- n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1, nil)
|
|
|
+ n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1)
|
|
|
defer n.Stop()
|
|
|
st := &storeRecorder{}
|
|
|
p := &storageRecorder{}
|
|
|
@@ -699,7 +699,7 @@ func TestSnapshot(t *testing.T) {
|
|
|
// Applied > SnapCount should trigger a SaveSnap event
|
|
|
func TestTriggerSnap(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
|
- n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1, nil)
|
|
|
+ n := raft.StartNode(0xBAD0, []int64{0xBAD0}, 10, 1)
|
|
|
n.Campaign(ctx)
|
|
|
st := &storeRecorder{}
|
|
|
p := &storageRecorder{}
|
|
|
@@ -712,7 +712,7 @@ func TestTriggerSnap(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
s.start()
|
|
|
- for i := 0; int64(i) < s.snapCount; i++ {
|
|
|
+ for i := 0; int64(i) < s.snapCount-1; i++ {
|
|
|
s.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
|
|
}
|
|
|
time.Sleep(time.Millisecond)
|
|
|
@@ -720,12 +720,12 @@ func TestTriggerSnap(t *testing.T) {
|
|
|
|
|
|
gaction := p.Action()
|
|
|
// each operation is recorded as a Save
|
|
|
- // Nop + SnapCount * Puts + Cut + SaveSnap = Save + SnapCount * Save + Cut + SaveSnap
|
|
|
- if len(gaction) != 3+int(s.snapCount) {
|
|
|
- t.Fatalf("len(action) = %d, want %d", len(gaction), 3+int(s.snapCount))
|
|
|
+ // BootstrapConfig/Nop + (SnapCount - 1) * Puts + Cut + SaveSnap = Save + (SnapCount - 1) * Save + Cut + SaveSnap
|
|
|
+ if len(gaction) != 2+int(s.snapCount) {
|
|
|
+ t.Fatalf("len(action) = %d, want %d", len(gaction), 2+int(s.snapCount))
|
|
|
}
|
|
|
- if !reflect.DeepEqual(gaction[12], action{name: "SaveSnap"}) {
|
|
|
- t.Errorf("action = %s, want SaveSnap", gaction[12])
|
|
|
+ if !reflect.DeepEqual(gaction[11], action{name: "SaveSnap"}) {
|
|
|
+ t.Errorf("action = %s, want SaveSnap", gaction[11])
|
|
|
}
|
|
|
}
|
|
|
|