mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
TestProposal
Don't check on `committed` but `lastIndex` instead. Signed-off-by: Tobias Grieger <tobias.b.grieger@gmail.com>
This commit is contained in:
parent
15abe294e7
commit
ff837f3a0b
@ -55,7 +55,7 @@ func mustTemp(pre, body string) string {
|
||||
}
|
||||
|
||||
func ltoa(l *raftLog) string {
|
||||
s := fmt.Sprintf("committed: %d\n", l.committed)
|
||||
s := fmt.Sprintf("lastIndex: %d\n", l.lastIndex())
|
||||
s += fmt.Sprintf("applied: %d\n", l.applied)
|
||||
for i, e := range l.allEntries() {
|
||||
s += fmt.Sprintf("#%d: %+v\n", i, e)
|
||||
|
@ -1077,6 +1077,7 @@ func TestProposal(t *testing.T) {
|
||||
// promote 1 to become leader
|
||||
send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
|
||||
send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
|
||||
r := tt.network.peers[1].(*raft)
|
||||
|
||||
wantLog := newLog(NewMemoryStorage(), raftLogger)
|
||||
if tt.success {
|
||||
@ -1084,8 +1085,8 @@ func TestProposal(t *testing.T) {
|
||||
storage: &MemoryStorage{
|
||||
ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}, {Term: 1, Index: 2, Data: data}},
|
||||
},
|
||||
unstable: unstable{offset: 3},
|
||||
committed: 2}
|
||||
unstable: unstable{offset: 3},
|
||||
}
|
||||
}
|
||||
base := ltoa(wantLog)
|
||||
for i, p := range tt.peers {
|
||||
@ -1098,8 +1099,7 @@ func TestProposal(t *testing.T) {
|
||||
t.Logf("#%d: peer %d empty log", j, i)
|
||||
}
|
||||
}
|
||||
sm := tt.network.peers[1].(*raft)
|
||||
if g := sm.Term; g != 1 {
|
||||
if g := r.Term; g != 1 {
|
||||
t.Errorf("#%d: term = %d, want %d", j, g, 1)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user