mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fixup! address comments
Signed-off-by: Tobias Grieger <tobias.b.grieger@gmail.com>
This commit is contained in:
parent
304e260038
commit
9ad36eecab
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2015 The etcd Authors
|
// Copyright 2022 The etcd Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -105,5 +105,6 @@ func newNodeTestHarness(ctx context.Context, t *testing.T, cfg *Config, peers ..
|
|||||||
defer n.Stop()
|
defer n.Stop()
|
||||||
n.run()
|
n.run()
|
||||||
}()
|
}()
|
||||||
|
t.Cleanup(n.Stop)
|
||||||
return ctx, cancel, &nodeTestHarness{node: n, t: t}
|
return ctx, cancel, &nodeTestHarness{node: n, t: t}
|
||||||
}
|
}
|
||||||
|
@ -647,7 +647,7 @@ func (r *raft) appendEntry(es ...pb.Entry) (accepted bool) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// use latest "last" index after truncate/append
|
// use latest "last" index after truncate/append
|
||||||
li = r.raftLog.append(es...)
|
r.raftLog.append(es...)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,17 +884,17 @@ func TestRawNodeStatus(t *testing.T) {
|
|||||||
// TestNodeCommitPaginationAfterRestart. The anomaly here was even worse as the
|
// TestNodeCommitPaginationAfterRestart. The anomaly here was even worse as the
|
||||||
// Raft group would forget to apply entries:
|
// Raft group would forget to apply entries:
|
||||||
//
|
//
|
||||||
// - node learns that index 11 is committed
|
// - node learns that index 11 is committed
|
||||||
// - nextEnts returns index 1..10 in CommittedEntries (but index 10 already
|
// - nextEnts returns index 1..10 in CommittedEntries (but index 10 already
|
||||||
// exceeds maxBytes), which isn't noticed internally by Raft
|
// exceeds maxBytes), which isn't noticed internally by Raft
|
||||||
// - Commit index gets bumped to 10
|
// - Commit index gets bumped to 10
|
||||||
// - the node persists the HardState, but crashes before applying the entries
|
// - the node persists the HardState, but crashes before applying the entries
|
||||||
// - upon restart, the storage returns the same entries, but `slice` takes a
|
// - upon restart, the storage returns the same entries, but `slice` takes a
|
||||||
// different code path and removes the last entry.
|
// different code path and removes the last entry.
|
||||||
// - Raft does not emit a HardState, but when the app calls Advance(), it bumps
|
// - Raft does not emit a HardState, but when the app calls Advance(), it bumps
|
||||||
// its internal applied index cursor to 10 (when it should be 9)
|
// its internal applied index cursor to 10 (when it should be 9)
|
||||||
// - the next Ready asks the app to apply index 11 (omitting index 10), losing a
|
// - the next Ready asks the app to apply index 11 (omitting index 10), losing a
|
||||||
// write.
|
// write.
|
||||||
func TestRawNodeCommitPaginationAfterRestart(t *testing.T) {
|
func TestRawNodeCommitPaginationAfterRestart(t *testing.T) {
|
||||||
s := &ignoreSizeHintMemStorage{
|
s := &ignoreSizeHintMemStorage{
|
||||||
MemoryStorage: newTestMemoryStorage(withPeers(1)),
|
MemoryStorage: newTestMemoryStorage(withPeers(1)),
|
||||||
@ -1133,12 +1133,26 @@ func TestRawNodeConsumeReady(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkRawNode(b *testing.B) {
|
func BenchmarkRawNode(b *testing.B) {
|
||||||
b.Run("single-voter", func(b *testing.B) {
|
cases := []struct {
|
||||||
benchmarkRawNodeImpl(b, 1)
|
name string
|
||||||
})
|
peers []uint64
|
||||||
b.Run("two-voters", func(b *testing.B) {
|
}{
|
||||||
benchmarkRawNodeImpl(b, 1, 2)
|
{
|
||||||
})
|
name: "single-voter",
|
||||||
|
peers: []uint64{1},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "two-voters",
|
||||||
|
peers: []uint64{1, 2},
|
||||||
|
},
|
||||||
|
// You can easily add more cases here.
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
b.Run(tc.name, func(b *testing.B) {
|
||||||
|
benchmarkRawNodeImpl(b, tc.peers...)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
|
func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
|
||||||
|
@ -52,8 +52,7 @@ type Progress struct {
|
|||||||
// RecentActive is true if the progress is recently active. Receiving any messages
|
// RecentActive is true if the progress is recently active. Receiving any messages
|
||||||
// from the corresponding follower indicates the progress is active.
|
// from the corresponding follower indicates the progress is active.
|
||||||
// RecentActive can be reset to false after an election timeout.
|
// RecentActive can be reset to false after an election timeout.
|
||||||
//
|
// This is always true on the leader.
|
||||||
// TODO(tbg): the leader should always have this set to true.
|
|
||||||
RecentActive bool
|
RecentActive bool
|
||||||
|
|
||||||
// ProbeSent is used while this follower is in StateProbe. When ProbeSent is
|
// ProbeSent is used while this follower is in StateProbe. When ProbeSent is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user