github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/server/testing_knobs.go (about)

     1  // Copyright 2019 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package server
    12  
    13  import (
    14  	"net"
    15  
    16  	"github.com/cockroachdb/cockroach/pkg/config/zonepb"
    17  	"github.com/cockroachdb/cockroach/pkg/roachpb"
    18  	"github.com/cockroachdb/cockroach/pkg/rpc"
    19  	"github.com/cockroachdb/cockroach/pkg/server/diagnosticspb"
    20  )
    21  
    22  // TestingKnobs groups testing knobs for the Server.
    23  type TestingKnobs struct {
    24  	// DisableAutomaticVersionUpgrade, if set, temporarily disables the server's
    25  	// automatic version upgrade mechanism.
    26  	DisableAutomaticVersionUpgrade int32 // accessed atomically
    27  	// DefaultZoneConfigOverride, if set, overrides the default zone config defined in `pkg/config/zone.go`
    28  	DefaultZoneConfigOverride *zonepb.ZoneConfig
    29  	// DefaultSystemZoneConfigOverride, if set, overrides the default system zone config defined in `pkg/config/zone.go`
    30  	DefaultSystemZoneConfigOverride *zonepb.ZoneConfig
    31  	// PauseAfterGettingRPCAddress, if non-nil, instructs the server to wait until
    32  	// the channel is closed after getting an RPC serving address.
    33  	PauseAfterGettingRPCAddress chan struct{}
    34  	// SignalAfterGettingRPCAddress, if non-nil, is closed after the server gets
    35  	// an RPC server address.
    36  	SignalAfterGettingRPCAddress chan struct{}
    37  	// ContextTestingKnobs allows customization of the RPC context testing knobs.
    38  	ContextTestingKnobs rpc.ContextTestingKnobs
    39  	// DiagnosticsTestingKnobs allows customization of diagnostics testing knobs.
    40  	DiagnosticsTestingKnobs diagnosticspb.TestingKnobs
    41  
    42  	// If set, use this listener for RPC (and possibly SQL, depending on
    43  	// the SplitListenSQL setting), instead of binding a new listener.
    44  	// This is useful in tests that need an ephemeral listening port but
    45  	// must know it before the server starts.
    46  	//
    47  	// When this is used, the advertise address should also be set to
    48  	// match.
    49  	//
    50  	// The Server takes responsibility for closing this listener.
    51  	// TODO(bdarnell): That doesn't give us a good way to clean up if the
    52  	// server fails to start.
    53  	RPCListener net.Listener
    54  
    55  	// BootstrapVersionOverride, if not empty, will be used for bootstrapping
    56  	// clusters instead of clusterversion.BinaryVersion (if this server is the
    57  	// one bootstrapping the cluster).
    58  	//
    59  	// This can be used by tests to essentially pretend that a new cluster is
    60  	// not starting from scratch, but instead is "created" by a node starting up
    61  	// with engines that had already been bootstrapped, at this
    62  	// BootstrapVersionOverride. For example, it allows convenient creation of a
    63  	// cluster from a 2.1 binary, but that's running at version 2.0.
    64  	//
    65  	// NB: When setting this, you probably also want to set
    66  	// DisableAutomaticVersionUpgrade.
    67  	//
    68  	// TODO(irfansharif): Update users of this testing knob to use the
    69  	// appropriate clusterversion.Handle instead.
    70  	BootstrapVersionOverride roachpb.Version
    71  }
    72  
    73  // ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
    74  func (*TestingKnobs) ModuleTestingKnobs() {}