-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
testing_knobs.go
134 lines (103 loc) · 5.07 KB
/
testing_knobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.
package spanconfig
import (
"time"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/retry"
)
// TestingKnobs provide fine-grained control over the various span config
// components for testing.
type TestingKnobs struct {
// ManagerDisableJobCreation disables creating the auto span config
// reconciliation job.
ManagerDisableJobCreation bool
// ManagerCheckJobInterceptor, if set, is invoked when checking to see if
// the reconciliation job exists.
ManagerCheckJobInterceptor func()
// ManagerCreatedJobInterceptor expects a *jobs.Job to be passed into it. It
// takes an interface here to resolve a circular dependency.
ManagerCreatedJobInterceptor func(interface{})
// ManagerAfterCheckedReconciliationJobExistsInterceptor is run after the
// manager has checked if the auto span config reconciliation job exists or
// not.
ManagerAfterCheckedReconciliationJobExistsInterceptor func(exists bool)
// JobDisablePersistingCheckpoints disables the span config reconciliation
// job from persisting checkpoints.
JobDisablePersistingCheckpoints bool
// JobDisableInternalRetry disables the span config reconciliation job's
// internal retry loop.
JobDisableInternalRetry bool
// JobOverrideRetryOptions, if set, controls the internal retry behavior for
// the reconciliation job.
JobOverrideRetryOptions *retry.Options
// JobPersistCheckpointInterceptor, if set, is invoked before the
// reconciliation job persists checkpoints.
JobOnCheckpointInterceptor func() error
// KVSubscriberRangeFeedKnobs control lifecycle events for the rangefeed
// underlying the KVSubscriber.
KVSubscriberRangeFeedKnobs base.ModuleTestingKnobs
// StoreKVSubscriberOverride is used to override the KVSubscriber used when
// setting up a new store.
StoreKVSubscriberOverride func(KVSubscriber) KVSubscriber
// KVAccessorPaginationInterceptor, if set, is invoked on every pagination
// event.
KVAccessorPaginationInterceptor func()
// KVAccessorBatchSizeOverride overrides the batch size KVAccessor makes use
// of internally.
KVAccessorBatchSizeOverrideFn func() int
// KVAccessorPreCommitMinTSWaitInterceptor, if set, is invoked before
// UpdateSpanConfigRecords waits for present time to be in advance of the
// minimum commit timestamp.
KVAccessorPreCommitMinTSWaitInterceptor func()
// KVAccessorPostCommitDeadlineSetInterceptor is invoked after we set the
// commit deadline.
KVAccessorPostCommitDeadlineSetInterceptor func(*kv.Txn)
// SQLWatcherOnEventInterceptor, if set, is invoked when the SQLWatcher
// receives an event on one of its rangefeeds.
SQLWatcherOnEventInterceptor func() error
// SQLWatcherCheckpointNoopsEveryDurationOverride, if set, overrides how
// often the SQLWatcher checkpoints noops.
SQLWatcherCheckpointNoopsEveryDurationOverride time.Duration
// SQLWatcherSkipNoopCheckpoints allows tests to skip no-op checkpoints
// entirely.
SQLWatcherSkipNoopCheckpoints bool
// SplitterStepLogger is used to capture internal steps the splitter is
// making, for debugging and test-readability purposes.
SplitterStepLogger func(string)
// ExcludeDroppedDescriptorsFromLookup is used to control if the
// SQLTranslator ignores dropped descriptors. If enabled, dropped
// descriptors appear as missing -- a convenient+faster alternative to
// waiting for the descriptor to actually get GC-ed in tests.
ExcludeDroppedDescriptorsFromLookup bool
// ConfigureScratchRange controls whether the scratch range (used in tests)
// applies the RANGE DEFAULT configuration.
ConfigureScratchRange bool
// ReconcilerInitialInterceptor, if set, is invoked at the very outset of
// the reconciliation process.
ReconcilerInitialInterceptor func(startTS hlc.Timestamp)
// ProtectedTSReaderOverrideFn returns a ProtectedTSReader which is used to
// override the ProtectedTSReader used when setting up a new store.
ProtectedTSReaderOverrideFn func(clock *hlc.Clock) ProtectedTSReader
// LimiterLimitOverride, if set, allows tests to dynamically override the span
// config limit.
LimiterLimitOverride func() int64
// StoreDisableCoalesceAdjacent, if set, disables coalescing of
// adjacent-and-identical span configs.
StoreDisableCoalesceAdjacent bool
// StoreIgnoreCoalesceAdjacentExceptions, if set, ignores the cluster settings
// spanconfig.{storage,tenant}_coalesce_adjacent.enabled. It also allows
// coalescing system database ranges for the host tenant.
StoreIgnoreCoalesceAdjacentExceptions bool
// OverrideFallbackConf, if set, allows tests to override fields in the
// fallback config that will be applied to the span.
OverrideFallbackConf func(roachpb.SpanConfig) roachpb.SpanConfig
}
// ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
func (t *TestingKnobs) ModuleTestingKnobs() {}
var _ base.ModuleTestingKnobs = (*TestingKnobs)(nil)