Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
126516: server: rename BinaryVersionOverride to ClusterVersionOverride r=RaduBerinde a=RaduBerinde

This commit renames the field and updates the comment.

Epic: none
Release note: None

Co-authored-by: Radu Berinde <[email protected]>
  • Loading branch information
craig[bot] and RaduBerinde committed Jul 6, 2024
2 parents 9fd3626 + f73ee3c commit 485975b
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 109 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (d *datadrivenTestState) addCluster(t *testing.T, cfg clusterCfg) error {
t.Fatalf("clusterVersion %s does not exist in data driven global map", cfg.beforeVersion)
}
params.ServerArgs.Knobs.Server = &server.TestingKnobs{
BinaryVersionOverride: beforeKey.Version(),
ClusterVersionOverride: beforeKey.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/kvccl/kvtenantccl/upgradeccl/tenant_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func testTenantAutoUpgrade(t *testing.T, clusterSetting *autoUpgradeClusterSetti
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: v0.Version(),
ClusterVersionOverride: v0.Version(),
},
SQLEvalContext: &eval.TestingKnobs{
// When the host binary version is not equal to its cluster version, tenant logical version is set
Expand Down Expand Up @@ -106,7 +106,7 @@ func testTenantAutoUpgrade(t *testing.T, clusterSetting *autoUpgradeClusterSetti
Server: &server.TestingKnobs{
TenantAutoUpgradeInfo: upgradeInfoCh,
TenantAutoUpgradeLoopFrequency: time.Second,
BinaryVersionOverride: v0.Version(),
ClusterVersionOverride: v0.Version(),
},
},
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestTenantUpgrade(t *testing.T) {
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: v1,
ClusterVersionOverride: v1,
},
// Make the upgrade faster by accelerating jobs.
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestTenantUpgradeFailure(t *testing.T) {
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: v0,
ClusterVersionOverride: v0,
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func runTest(t *testing.T, variant sharedtestutil.TestVariant, test sharedtestut
DisableAutomaticVersionUpgrade: make(chan struct{}),
// Initialize to the minimum supported version
// so that we can perform the upgrade below.
BinaryVersionOverride: msv,
ClusterVersionOverride: msv,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/multiregionccl/multiregion_system_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func TestMrSystemDatabaseUpgrade(t *testing.T) {
base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: clusterversion.MinSupported.Version(),
ClusterVersionOverride: clusterversion.MinSupported.Version(),
},
},
multiregionccltestutils.WithSettings(makeSettings()))
Expand All @@ -572,7 +572,7 @@ func TestMrSystemDatabaseUpgrade(t *testing.T) {
TestingKnobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: clusterversion.MinSupported.Version(),
ClusterVersionOverride: clusterversion.MinSupported.Version(),
},
},
TenantID: id,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/multitenantccl/tenantcostserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestPreMigration(t *testing.T) {
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: (clusterversion.V24_2_TenantRates - 1).Version(),
ClusterVersionOverride: (clusterversion.V24_2_TenantRates - 1).Version(),
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/schemachangerccl/schemachanger_ccl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (f MultiRegionTestClusterFactory) WithSchemaChangerKnobs(
// WithMixedVersion implements the sctest.TestServerFactory interface.
func (f MultiRegionTestClusterFactory) WithMixedVersion() sctest.TestServerFactory {
f.server = &server.TestingKnobs{
BinaryVersionOverride: sctest.OldVersionKey.Version(),
ClusterVersionOverride: sctest.OldVersionKey.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
}
return f
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/serverccl/server_startup_guardrails_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestServerStartupGuardrails(t *testing.T) {
Settings: storageSettings,
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: test.storageBinaryVersion,
ClusterVersionOverride: test.storageBinaryVersion,
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
SQLEvalContext: &eval.TestingKnobs{
Expand All @@ -124,7 +124,7 @@ func TestServerStartupGuardrails(t *testing.T) {
TenantID: serverutils.TestTenantID(),
TestingKnobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: test.tenantBinaryVersion,
ClusterVersionOverride: test.tenantBinaryVersion,
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/serverccl/tenant_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestValidateTargetTenantClusterVersion(t *testing.T) {
Settings: makeSettings(),
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: test.binaryVersion,
ClusterVersionOverride: test.binaryVersion,
// We're bumping cluster versions manually ourselves. We
// want to avoid racing with the auto-upgrade process.
DisableAutomaticVersionUpgrade: make(chan struct{}),
Expand All @@ -107,7 +107,7 @@ func TestValidateTargetTenantClusterVersion(t *testing.T) {
TenantID: serverutils.TestTenantID(),
TestingKnobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: test.binaryVersion,
ClusterVersionOverride: test.binaryVersion,
},
},
})
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestBumpTenantClusterVersion(t *testing.T) {
// This test wants to bootstrap at the previously active
// cluster version, so we can actually bump the cluster
// version to the binary version.
BinaryVersionOverride: test.initialClusterVersion.Version,
ClusterVersionOverride: test.initialClusterVersion.Version,
// We're bumping cluster versions manually ourselves. We
// want to avoid racing with the auto-upgrade process.
DisableAutomaticVersionUpgrade: make(chan struct{}),
Expand All @@ -222,7 +222,7 @@ func TestBumpTenantClusterVersion(t *testing.T) {
TenantID: serverutils.TestTenantID(),
TestingKnobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: test.initialClusterVersion.Version,
ClusterVersionOverride: test.initialClusterVersion.Version,
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/jobs/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,7 @@ func TestStartableJobMixedVersion(t *testing.T) {
Settings: st,
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: clusterversion.MinSupported.Version(),
ClusterVersionOverride: clusterversion.MinSupported.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/client_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func TestMigrateWaitsForApplication(t *testing.T) {
Settings: cluster.MakeTestingClusterSettingsWithVersions(endV, startV, false),
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: startV,
ClusterVersionOverride: startV,
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
UpgradeManager: &upgradebase.TestingKnobs{
Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/client_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4110,7 +4110,7 @@ func TestStrictGCEnforcement(t *testing.T) {
testCache = true
args.ServerArgs.Knobs.Server = &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: (clusterversion.V24_1_MigrateOldStylePTSRecords - 1).Version(),
ClusterVersionOverride: (clusterversion.V24_1_MigrateOldStylePTSRecords - 1).Version(),
}
}

Expand Down Expand Up @@ -4924,7 +4924,7 @@ func TestRangeMigration(t *testing.T) {
Settings: cluster.MakeTestingClusterSettingsWithVersions(endV, startV, false),
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: startV,
ClusterVersionOverride: startV,
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func TestJoinVersionGate(t *testing.T) {

knobs := base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: oldVersion,
ClusterVersionOverride: oldVersion,
},
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,12 @@ func newInitServerConfig(
latestVersion := cfg.Settings.Version.LatestVersion()
minSupportedVersion := cfg.Settings.Version.MinSupportedVersion()
if knobs := cfg.TestingKnobs.Server; knobs != nil {
if overrideVersion := knobs.(*TestingKnobs).BinaryVersionOverride; overrideVersion != (roachpb.Version{}) {
if overrideVersion := knobs.(*TestingKnobs).ClusterVersionOverride; overrideVersion != (roachpb.Version{}) {
// We are customizing the cluster version. We can only bootstrap a fresh
// cluster at specific versions (specifically, the current version and
// previously released versions down to the minimum supported).
// We choose the closest version that's not newer than the target version.;
// later on, we will upgrade to `BinaryVersionOverride` (this happens
// previously released versions down to the minimum supported). We choose
// the closest version that's not newer than the target version.; later
// on, we will upgrade to `ClusterVersionOverride` (this happens
// separately when we Activate the server).
var bootstrapVersion roachpb.Version
for _, v := range bootstrap.VersionsWithInitialValues() {
Expand All @@ -657,7 +657,7 @@ func newInitServerConfig(
}
}
if bootstrapVersion == (roachpb.Version{}) {
panic(fmt.Sprintf("BinaryVersionOverride version %s too low", overrideVersion))
panic(fmt.Sprintf("ClusterVersionOverride version %s too low", overrideVersion))
}
latestVersion = bootstrapVersion
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/server/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestValidateTargetClusterVersion(t *testing.T) {
Settings: st,
Knobs: base.TestingKnobs{
Server: &TestingKnobs{
BinaryVersionOverride: test.latestVersion,
ClusterVersionOverride: test.latestVersion,
},
},
})
Expand Down Expand Up @@ -141,8 +141,8 @@ func TestSyncAllEngines(t *testing.T) {
StoreSpecs: []base.StoreSpec{storeSpec},
Knobs: base.TestingKnobs{
Server: &TestingKnobs{
BinaryVersionOverride: clusterversion.PreviousRelease.Version(),
StickyVFSRegistry: vfsRegistry,
ClusterVersionOverride: clusterversion.PreviousRelease.Version(),
StickyVFSRegistry: vfsRegistry,
},
},
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestBumpClusterVersion(t *testing.T) {
// cluster version, so we can actually bump the cluster
// version to the binary version. Think a cluster with
// active cluster version v20.1, but running v20.2 binaries.
BinaryVersionOverride: test.activeClusterVersion,
ClusterVersionOverride: test.activeClusterVersion,
// We're bumping cluster versions manually ourselves. We
// want avoid racing with the auto-upgrade process.
DisableAutomaticVersionUpgrade: make(chan struct{}),
Expand Down Expand Up @@ -358,7 +358,7 @@ func TestUpgradeHappensAfterMigrations(t *testing.T) {
Knobs: base.TestingKnobs{
Server: &TestingKnobs{
DisableAutomaticVersionUpgrade: automaticUpgrade,
BinaryVersionOverride: clusterversion.MinSupported.Version(),
ClusterVersionOverride: clusterversion.MinSupported.Version(),
},
UpgradeManager: &upgradebase.TestingKnobs{
AfterRunPermanentUpgrades: func() {
Expand Down
45 changes: 15 additions & 30 deletions pkg/server/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,27 @@ type TestingKnobs struct {
// server fails to start.
RPCListener net.Listener

// BinaryVersionOverride overrides the binary version that the CRDB server
// will end up running. This value could also influence what version the
// cluster is bootstrapped at.
// ClusterVersionOverride can be used to override the version of the cluster
// (assuming that one has to be created).
//
// This value, when set, influences test cluster/server creation in two
// different ways:
// Normally (when this knob isn't used), the cluster is initialized at
// cluster.Settings.Version.LatestVersion().
//
// Case 1:
// ------
// If the test has not overridden the
// `cluster.Settings.Version.MinSupportedVersion`, then the cluster will be
// bootstrapped at `minSupportedVersion` (if this server is the one
// bootstrapping the cluster). After all the servers in the test cluster have
// been started, `SET CLUSTER SETTING version = BinaryVersionOverride` will be
// run to step through the upgrades until the specified override.
// When ClusterVersionOverride is set, the cluster will be at this version
// once initialization is complete. Note that we cannot bootstrap clusters at
// arbitrary versions - we can only bootstrap clusters at the Latest version
// and at final versions of previous supported releases. The cluster will be
// bootstrapped at the most recent bootstrappable version that is at most
// ClusterVersionOverride; after all the servers in the test cluster have been
// started, `SET CLUSTER SETTING version = ClusterVersionOverride` will be run
// to step through the upgrades until the specified version.
//
// Case 2:
// ------
// If the test has overridden the
// `cluster.Settings.Version.MinSupportedVersion` then it is not safe for us
// to bootstrap at `minSupportedVersion` as it might be less than the
// overridden minimum supported version. Furthermore, we do not have the
// initial cluster data (system tables etc.) to bootstrap at the overridden
// minimum supported version. In this case we bootstrap at
// `BinaryVersionOverride` and populate the cluster with initial data
// corresponding to the `binaryVersion`. In other words no upgrades are
// *really* run and the server only thinks that it is running at
// `BinaryVersionOverride`. Tests that fall in this category should be audited
// for correctness.
//
// The version that we bootstrap at is also used when advertising this
// server's binary version when sending out join requests.
// ClusterVersionOverride is also used when advertising this server's binary
// version when sending out join requests.
//
// NB: When setting this, you probably also want to set
// DisableAutomaticVersionUpgrade.
BinaryVersionOverride roachpb.Version
ClusterVersionOverride roachpb.Version
// An (additional) callback invoked whenever a
// node is permanently removed from the cluster.
OnDecommissionedCallback func(id roachpb.NodeID)
Expand Down
21 changes: 7 additions & 14 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,13 @@ func (ts *testServer) Activate(ctx context.Context) error {
}

maybeRunVersionUpgrade := func(layer serverutils.ApplicationLayerInterface) error {
if v := ts.BinaryVersionOverride(); v != (roachpb.Version{}) {
ie := layer.InternalExecutor().(isql.Executor)
if _, err := ie.Exec(context.Background(), "set-cluster-version", nil, /* txn */
`SET CLUSTER SETTING version = $1`, v.String()); err != nil {
return err
if knobs := ts.TestingKnobs().Server; knobs != nil {
if v := knobs.(*TestingKnobs).ClusterVersionOverride; v != (roachpb.Version{}) {
ie := layer.InternalExecutor().(isql.Executor)
if _, err := ie.Exec(context.Background(), "set-cluster-version", nil, /* txn */
`SET CLUSTER SETTING version = $1`, v.String()); err != nil {
return err
}
}
}
return nil
Expand Down Expand Up @@ -2296,15 +2298,6 @@ func (ts *testServer) RangeDescIteratorFactory() interface{} {
return ts.sqlServer.execCfg.RangeDescIteratorFactory
}

// BinaryVersionOverride is part of the serverutils.TestServerInterface.
func (ts *testServer) BinaryVersionOverride() roachpb.Version {
knobs := ts.TestingKnobs().Server
if knobs == nil {
return roachpb.Version{}
}
return knobs.(*TestingKnobs).BinaryVersionOverride
}

// KvProber is part of the serverutils.StorageLayerInterface.
func (ts *testServer) KvProber() *kvprober.Prober {
return ts.topLevelServer.kvProber
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/version_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestClusterVersionUpgrade(t *testing.T) {
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: oldVersion,
ClusterVersionOverride: oldVersion,
DisableAutomaticVersionUpgrade: disableUpgradeCh,
},
},
Expand Down Expand Up @@ -401,7 +401,7 @@ func TestClusterVersionMixedVersionTooOld(t *testing.T) {
knobs := base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: v0,
ClusterVersionOverride: v0,
},
// Inject an upgrade which would run to upgrade the cluster.
// We'll validate that we never create a job for this upgrade.
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/catalog/lease/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ func TestLeaseTxnDeadlineExtension(t *testing.T) {
},
}
params.Knobs.Server = &server.TestingKnobs{
BinaryVersionOverride: clusterversion.V23_2.Version(),
ClusterVersionOverride: clusterversion.V23_2.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
}
s, sqlDB, _ := serverutils.StartServer(t, params)
Expand Down Expand Up @@ -3873,7 +3873,7 @@ func TestSessionLeasingTable(t *testing.T) {
DefaultTestTenant: base.TestNeedsTightIntegrationBetweenAPIsAndTestingKnobs,
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: clusterversion.V23_2.Version(),
ClusterVersionOverride: clusterversion.V23_2.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
},
Expand Down Expand Up @@ -3949,7 +3949,7 @@ func TestLongLeaseWaitMetrics(t *testing.T) {
DefaultTestTenant: base.TestNeedsTightIntegrationBetweenAPIsAndTestingKnobs,
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BinaryVersionOverride: clusterversion.V23_2.Version(),
ClusterVersionOverride: clusterversion.V23_2.Version(),
DisableAutomaticVersionUpgrade: make(chan struct{}),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/tabledesc/validate_version_gating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestIndexDoesNotStorePrimaryKeyColumnMixedVersion(t *testing.T) {
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: make(chan struct{}),
BinaryVersionOverride: v0.Version(),
ClusterVersionOverride: v0.Version(),
},
},
})
Expand Down
Loading

0 comments on commit 485975b

Please sign in to comment.