Merge remote-tracking branch 'coreos/master' into merge
* coreos/master: scripts: build-docker tag and use ENTRYPOINT scripts: build-release add etcd-migrate create .godir raft: optimistically increase the next if the follower is already matched raft: add handleHeartbeat handleHeartbeat commits to the commit index in the message. It never decreases the commit index of the raft state machine. rafthttp: send takes raft message instead of bytes *: add rafthttp pkg into test list raft: include commitIndex in heartbeat rafthttp: move server stats in raftHandler to etcdserver *: etcdhttp.raftHandler -> rafthttp.RaftHandler etcdserver: rename sender.go -> sendhub.go *: etcdserver.sender -> rafthttp.Sender Conflicts: raft/log.go raft/raft_paper_test.go
This commit is contained in:
@ -400,6 +400,38 @@ func TestUnstableEnts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitTo(t *testing.T) {
|
||||
previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}, {Term: 3, Index: 3}}
|
||||
commit := uint64(2)
|
||||
tests := []struct {
|
||||
commit uint64
|
||||
wcommit uint64
|
||||
wpanic bool
|
||||
}{
|
||||
{3, 3, false},
|
||||
{1, 2, false}, // never decrease
|
||||
{4, 0, true}, // commit out of range -> panic
|
||||
}
|
||||
for i, tt := range tests {
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if tt.wpanic != true {
|
||||
t.Errorf("%d: panic = %v, want %v", i, true, tt.wpanic)
|
||||
}
|
||||
}
|
||||
}()
|
||||
raftLog := newLog(NewMemoryStorage())
|
||||
raftLog.append(0, previousEnts...)
|
||||
raftLog.committed = commit
|
||||
raftLog.commitTo(tt.commit)
|
||||
if raftLog.committed != tt.wcommit {
|
||||
t.Errorf("#%d: committed = %d, want %d", i, raftLog.committed, tt.wcommit)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestStableTo(t *testing.T) {
|
||||
tests := []struct {
|
||||
stable uint64
|
||||
|
Reference in New Issue
Block a user