-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
testing_knobs.go
69 lines (56 loc) · 2.68 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
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package kvcoord
import (
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
)
// ClientTestingKnobs contains testing options that dictate the behavior
// of the key-value client.
type ClientTestingKnobs struct {
// The RPC dispatcher. Defaults to grpc but can be changed here for
// testing purposes.
TransportFactory TransportFactory
// DontConsiderConnHealth, if set, makes the GRPCTransport not take into
// consideration the connection health when deciding the ordering for
// replicas. When not set, replicas on nodes with unhealthy connections are
// deprioritized.
DontConsiderConnHealth bool
// The maximum number of times a txn will attempt to refresh its
// spans for a single transactional batch.
// 0 means use a default. -1 means disable refresh.
MaxTxnRefreshAttempts int
// CondenseRefreshSpansFilter, if set, is called when the span refresher is
// considering condensing the refresh spans. If it returns false, condensing
// will not be attempted and the span refresher will behave as if condensing
// failed to save enough memory.
CondenseRefreshSpansFilter func() bool
// LatencyFunc, if set, overrides RPCContext.RemoteClocks.Latency as the
// function used by the DistSender to order replicas for follower reads.
LatencyFunc LatencyFunc
// If set, the DistSender will try the replicas in the order they appear in
// the descriptor, instead of trying to reorder them by latency. The knob
// only applies to requests sent with the LEASEHOLDER routing policy.
DontReorderReplicas bool
// CommitWaitFilter allows tests to instrument the beginning of a transaction
// commit wait sleep.
CommitWaitFilter func()
// OnRangeSpanningNonTxnalBatch is invoked whenever DistSender attempts to split
// a non-transactional batch across a range boundary. The method may inject an
// error which, if non-nil, becomes the result of the batch. Otherwise, execution
// continues.
OnRangeSpanningNonTxnalBatch func(ba *kvpb.BatchRequest) *kvpb.Error
// EnableRandomTransactionRetryErrors allows transaction retry
// loops to randomly inject retriable errors.
EnableRandomTransactionRetryErrors bool
}
var _ base.ModuleTestingKnobs = &ClientTestingKnobs{}
// ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
func (*ClientTestingKnobs) ModuleTestingKnobs() {}