From 80abd32388f5bb41c8f9f45ace591a1155f9958b Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Tue, 16 Jul 2019 19:32:06 -0400 Subject: [PATCH] storage: add DisableRaftLogQueue to StoreTestingKnobs Release note: None --- pkg/storage/raft_log_queue_test.go | 10 ++++++---- pkg/storage/replica_test.go | 11 ++++++----- pkg/storage/store.go | 3 +++ pkg/storage/testing_knobs.go | 2 ++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pkg/storage/raft_log_queue_test.go b/pkg/storage/raft_log_queue_test.go index 56edc99b2a62..e9e05b85fc53 100644 --- a/pkg/storage/raft_log_queue_test.go +++ b/pkg/storage/raft_log_queue_test.go @@ -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 @@ -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)) diff --git a/pkg/storage/replica_test.go b/pkg/storage/replica_test.go index a05d8b8593cf..ad8e3c8f8142 100644 --- a/pkg/storage/replica_test.go +++ b/pkg/storage/replica_test.go @@ -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) @@ -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 @@ -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 diff --git a/pkg/storage/store.go b/pkg/storage/store.go index b43bf361ca3c..fe3b6be37af7 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -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) } diff --git a/pkg/storage/testing_knobs.go b/pkg/storage/testing_knobs.go index 6821f0268e69..268fc628055f 100644 --- a/pkg/storage/testing_knobs.go +++ b/pkg/storage/testing_knobs.go @@ -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.