Skip to content

Commit

Permalink
Merge pull request #9528 from bdarnell/cherry-pick
Browse files Browse the repository at this point in the history
storage: De-flake TestAcceptsUnsplitRanges on master
  • Loading branch information
bdarnell authored Sep 25, 2016
2 parents bebc77a + 5289007 commit 3e55a5d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions storage/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ func (m *multiTestContext) makeContext(i int) storage.StoreContext {
ctx.Gossip = m.gossips[i]
ctx.StorePool = m.storePools[i]
ctx.TestingKnobs.DisableSplitQueue = true
ctx.TestingKnobs.ReplicateQueueAcceptsUnsplit = true
return ctx
}

Expand Down
8 changes: 4 additions & 4 deletions storage/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ func (bq *baseQueue) requiresSplit(cfg config.SystemConfig, repl *Replica) bool
if bq.acceptsUnsplitRanges {
return false
}
// If there's no store (as is the case in some narrow unit tests), or if
// the store's split queue is disabled, the "required" split will never
// come. In that case, pretend we don't require the split.
if store := repl.store; store == nil || store.splitQueue.Disabled() {
// If there's no store (as is the case in some narrow unit tests),
// the "required" split will never come. In that case, pretend we
// don't require the split.
if store := repl.store; store == nil {
return false
}
desc := repl.Desc()
Expand Down
2 changes: 1 addition & 1 deletion storage/replicate_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func newReplicateQueue(store *Store, g *gossip.Gossip, allocator Allocator, cloc
rq.baseQueue = makeBaseQueue("replicate", rq, store, g, queueConfig{
maxSize: replicateQueueMaxSize,
needsLease: true,
acceptsUnsplitRanges: false,
acceptsUnsplitRanges: store.TestingKnobs().ReplicateQueueAcceptsUnsplit,
successes: store.metrics.ReplicateQueueSuccesses,
failures: store.metrics.ReplicateQueueFailures,
pending: store.metrics.ReplicateQueuePending,
Expand Down
4 changes: 4 additions & 0 deletions storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ type StoreTestingKnobs struct {
DisableRefreshReasonTicks bool
// DisableProcessRaft disables the process raft loop.
DisableProcessRaft bool
// ReplicateQueueAcceptsUnsplit allows the replication queue to
// process ranges that need to be split, for use in tests that use
// the replication queue but disable the split queue.
ReplicateQueueAcceptsUnsplit bool
}

var _ base.ModuleTestingKnobs = &StoreTestingKnobs{}
Expand Down
3 changes: 3 additions & 0 deletions storage/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ func createTestStore(t testing.TB) (*Store, *hlc.ManualClock, *stop.Stopper) {
// so just disable the scanner for all tests that use this function
// instead of figuring out exactly which tests need it.
ctx.TestingKnobs.DisableScanner = true
// The scanner affects background operations; we must also disable
// the split queue separately to cover event-driven splits.
ctx.TestingKnobs.DisableSplitQueue = true
return createTestStoreWithContext(t, &ctx)
}

Expand Down

0 comments on commit 3e55a5d

Please sign in to comment.