|
|
@@ -98,7 +98,10 @@ func TestCompactionSideEffects(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- unstableEnts := raftLog.unstableEnts()
|
|
|
+ offset, unstableEnts := raftLog.unstableEnts()
|
|
|
+ if offset != 501 {
|
|
|
+ t.Errorf("offset(unstableEntries) = %d, want = %d", offset, 500)
|
|
|
+ }
|
|
|
if g := len(unstableEnts); g != 500 {
|
|
|
t.Errorf("len(unstableEntries) = %d, want = %d", g, 500)
|
|
|
}
|
|
|
@@ -119,18 +122,22 @@ func TestUnstableEnts(t *testing.T) {
|
|
|
previousEnts := []Entry{{Term: 1}, {Term: 2}}
|
|
|
tests := []struct {
|
|
|
unstable int64
|
|
|
+ woffset int64
|
|
|
wents []Entry
|
|
|
wunstable int64
|
|
|
}{
|
|
|
- {3, nil, 3},
|
|
|
- {1, []Entry{{Term: 1}, {Term: 2}}, 3},
|
|
|
+ {3, 3, nil, 3},
|
|
|
+ {1, 1, []Entry{{Term: 1}, {Term: 2}}, 3},
|
|
|
}
|
|
|
|
|
|
for i, tt := range tests {
|
|
|
raftLog := newLog()
|
|
|
raftLog.ents = append(raftLog.ents, previousEnts...)
|
|
|
raftLog.unstable = tt.unstable
|
|
|
- ents := raftLog.unstableEnts()
|
|
|
+ offset, ents := raftLog.unstableEnts()
|
|
|
+ if offset != tt.woffset {
|
|
|
+ t.Errorf("#%d: offset = %d, want = %d", i, offset, tt.woffset)
|
|
|
+ }
|
|
|
if !reflect.DeepEqual(ents, tt.wents) {
|
|
|
t.Errorf("#%d: unstableEnts = %+v, want %+v", i, ents, tt.wents)
|
|
|
}
|