Merge pull request #1888 from yichengq/258
raft: increase term to 1 before append initial entriesrelease-2.0
commit
22dd3b039c
|
@ -137,6 +137,9 @@ func StartNode(id uint64, peers []Peer, election, heartbeat int, storage Storage
|
||||||
n := newNode()
|
n := newNode()
|
||||||
r := newRaft(id, nil, election, heartbeat, storage)
|
r := newRaft(id, nil, election, heartbeat, storage)
|
||||||
|
|
||||||
|
// become the follower at term 1 and apply initial configuration
|
||||||
|
// entires of term 1
|
||||||
|
r.becomeFollower(1, None)
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
cc := pb.ConfChange{Type: pb.ConfChangeAddNode, NodeID: peer.ID, Context: peer.Context}
|
cc := pb.ConfChange{Type: pb.ConfChangeAddNode, NodeID: peer.ID, Context: peer.Context}
|
||||||
d, err := cc.Marshal()
|
d, err := cc.Marshal()
|
||||||
|
|
|
@ -306,20 +306,20 @@ func TestNodeStart(t *testing.T) {
|
||||||
wants := []Ready{
|
wants := []Ready{
|
||||||
{
|
{
|
||||||
SoftState: &SoftState{Lead: 1, Nodes: []uint64{1}, RaftState: StateLeader},
|
SoftState: &SoftState{Lead: 1, Nodes: []uint64{1}, RaftState: StateLeader},
|
||||||
HardState: raftpb.HardState{Term: 1, Commit: 2},
|
HardState: raftpb.HardState{Term: 2, Commit: 2},
|
||||||
Entries: []raftpb.Entry{
|
Entries: []raftpb.Entry{
|
||||||
{Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
|
{Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
|
||||||
{Term: 1, Index: 2},
|
{Term: 2, Index: 2},
|
||||||
},
|
},
|
||||||
CommittedEntries: []raftpb.Entry{
|
CommittedEntries: []raftpb.Entry{
|
||||||
{Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
|
{Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
|
||||||
{Term: 1, Index: 2},
|
{Term: 2, Index: 2},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
HardState: raftpb.HardState{Term: 1, Commit: 3},
|
HardState: raftpb.HardState{Term: 2, Commit: 3},
|
||||||
Entries: []raftpb.Entry{{Term: 1, Index: 3, Data: []byte("foo")}},
|
Entries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
|
||||||
CommittedEntries: []raftpb.Entry{{Term: 1, Index: 3, Data: []byte("foo")}},
|
CommittedEntries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
storage := NewMemoryStorage()
|
storage := NewMemoryStorage()
|
||||||
|
|
Loading…
Reference in New Issue