Skip to content

Commit

Permalink
storage: add DisableRaftLogQueue to StoreTestingKnobs
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
nvanbenschoten committed Jul 30, 2019
1 parent 69f874d commit 80abd32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 6 additions & 4 deletions pkg/storage/raft_log_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,11 @@ func TestSnapshotLogTruncationConstraints(t *testing.T) {
func TestTruncateLog(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
cfg := TestStoreConfig(nil)
cfg.TestingKnobs.DisableRaftLogQueue = true
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
tc.Start(t, stopper)
tc.repl.store.SetRaftLogQueueActive(false)
tc.StartWithStoreConfig(t, stopper, cfg)

// Populate the log with 10 entries. Save the LastIndex after each write.
var indexes []uint64
Expand Down Expand Up @@ -887,10 +888,11 @@ func TestTruncateLogRecompute(t *testing.T) {
tc := testContext{
engine: eng,
}
cfg := TestStoreConfig(nil)
cfg.TestingKnobs.DisableRaftLogQueue = true
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
tc.Start(t, stopper)
tc.repl.store.SetRaftLogQueueActive(false)
tc.StartWithStoreConfig(t, stopper, cfg)

key := roachpb.Key("a")
repl := tc.store.LookupReplica(keys.MustAddr(key))
Expand Down
11 changes: 6 additions & 5 deletions pkg/storage/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1285,10 +1285,10 @@ func TestReplicaTSCacheLowWaterOnLease(t *testing.T) {
tc := testContext{manualClock: hlc.NewManualClock(123)}
cfg := TestStoreConfig(hlc.NewClock(tc.manualClock.UnixNano, time.Nanosecond))
cfg.TestingKnobs.DisableAutomaticLeaseRenewal = true
// Disable raft log truncation which confuses this test.
cfg.TestingKnobs.DisableRaftLogQueue = true
tc.StartWithStoreConfig(t, stopper, cfg)

// Disable raft log truncation which confuses this test.
tc.store.SetRaftLogQueueActive(false)
secondReplica, err := tc.addBogusReplicaToRangeDesc(context.TODO())
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -6624,10 +6624,10 @@ func TestEntries(t *testing.T) {
// Disable ticks to avoid quiescence, which can result in empty
// entries being proposed and causing the test to flake.
cfg.RaftTickInterval = math.MaxInt32
cfg.TestingKnobs.DisableRaftLogQueue = true
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
tc.StartWithStoreConfig(t, stopper, cfg)
tc.repl.store.SetRaftLogQueueActive(false)

repl := tc.repl
rangeID := repl.RangeID
Expand Down Expand Up @@ -6774,10 +6774,11 @@ func TestEntries(t *testing.T) {
func TestTerm(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
tsc := TestStoreConfig(nil)
tsc.TestingKnobs.DisableRaftLogQueue = true
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
tc.Start(t, stopper)
tc.repl.store.SetRaftLogQueueActive(false)
tc.StartWithStoreConfig(t, stopper, tsc)

repl := tc.repl
rangeID := repl.RangeID
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ func NewStore(
if cfg.TestingKnobs.DisableMergeQueue {
s.setMergeQueueActive(false)
}
if cfg.TestingKnobs.DisableRaftLogQueue {
s.setRaftLogQueueActive(false)
}
if cfg.TestingKnobs.DisableReplicaGCQueue {
s.setReplicaGCQueueActive(false)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ type StoreTestingKnobs struct {
DisableGCQueue bool
// DisableMergeQueue disables the merge queue.
DisableMergeQueue bool
// DisableReplicateQueue disables the raft log queue.
DisableRaftLogQueue bool
// DisableReplicaGCQueue disables the replica GC queue.
DisableReplicaGCQueue bool
// DisableReplicateQueue disables the replication queue.
Expand Down

0 comments on commit 80abd32

Please sign in to comment.