forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_server_args.go
96 lines (83 loc) · 3.58 KB
/
test_server_args.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
// Copyright 2016 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// Author: Andrei Matei (andreimatei1@gmail.com)
package base
import (
"time"
"github.com/cockroachdb/cockroach/util/stop"
)
// TestServerArgs contains the parameters one can set when creating a test
// server. Notably, TestServerArgs are passed to serverutils.StartServer().
// They're defined in base because they need to be shared between
// testutils/serverutils (test code) and server.TestServer (non-test code).
//
// The zero value is suitable for most tests.
type TestServerArgs struct {
// Knobs for the test server.
Knobs TestingKnobs
// PartOfCluster must be set if the TestServer is joining others in a cluster.
// If not set (and hence the server is the only one in the cluster), the
// default zone config will be overridden to disable all replication - so that
// tests don't get log spam about ranges not being replicated enough.
PartOfCluster bool
// JoinAddr (if nonempty) is the address of a node we are joining.
JoinAddr string
StoresPerNode int
// Fields copied to the server.Context.
Insecure bool
MetricsSampleInterval time.Duration
MaxOffset time.Duration
SocketFile string
ScanInterval time.Duration
ScanMaxIdleTime time.Duration
SSLCA string
SSLCert string
SSLCertKey string
// If set, this will be appended to the Postgres URL by functions that
// automatically open a connection to the server. That's equivalent to running
// SET DATABASE=foo, which works even if the database doesn't (yet) exist.
UseDatabase string
// Stopper can be used to stop the server. If not set, a stopper will be
// constructed and it can be gotten through TestServerInterface.Stopper().
Stopper *stop.Stopper
}
// TestClusterArgs contains the parameters one can set when creating a test
// cluster. It contains a TestServerArgs instance which will be copied over to
// every server.
//
// The zero value means "full replication".
type TestClusterArgs struct {
// ServerArgs will be copied to each constituent TestServer.
ServerArgs TestServerArgs
// ReplicationMode controls how replication is to be done in the cluster.
ReplicationMode TestClusterReplicationMode
// Stopper can be used to stop the cluster. If not set, a stopper will be
// constructed and it can be gotten through TestCluster.Stopper().
Stopper *stop.Stopper
}
// TestClusterReplicationMode represents the replication settings for a TestCluster.
type TestClusterReplicationMode int
const (
// ReplicationAuto means that ranges are replicated according to the
// production default zone config. Replication is performed as in
// production, by the replication queue.
// TestCluster.WaitForFullReplication() can be used to wait for
// replication to be stable at any point in a test.
ReplicationAuto TestClusterReplicationMode = iota
// ReplicationManual means that the split and replication queues of all
// servers are stopped, and the test must manually control splitting and
// replication through the TestServer.
ReplicationManual
)