Skip to content

Commit

Permalink
[wip] migrations,server: allow tests to override minimum supported ve…
Browse files Browse the repository at this point in the history
…rsion

Certain tests override the binary version (for e.g. in order to test the
execution of a specific migration association with a specific cluster
version). For these tests we also want to bypass the bootstrap ("is too
old for running version") version check, especially as we bump the
minimum supported version past a bunch of cluster versions that were
introduced in the last release cycle (cockroachdb#69828).

We could technically delete all the past-release cluster version
handling code before introducing next release development versions,
but it's easy to keep it around to simplify backports (and also it's a
lot of code to get rid of, only to allow next-release versions to be
added). Allowing these tests to override the minimum supported
version is a convenient workaround.

---

This commit updates one of the many failing tests blocking cockroachdb#69828, but
not all of them. The approach in this commit of providing a sister testing
knob `BinaryMinSupportedVersion` might not be sufficient due to
interactions with the cluster version setting (see comments on cockroachdb#69828).
It's possible we want to go all the way and all tests to install a
clusterversion.Handle instead. Leaving this PR up for posterity.

Release note: None
  • Loading branch information
irfansharif committed Oct 19, 2021
1 parent b05967b commit 0f9572a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func TestDeleteDeprecatedNamespaceDescriptorMigration(t *testing.T) {
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: 1,
BinaryVersionOverride: clusterversion.ByKey(clusterversion.DeleteDeprecatedNamespaceTableDescriptorMigration - 1),
DisableAutomaticVersionUpgrade: 1,
BinaryVersionOverride: clusterversion.ByKey(clusterversion.DeleteDeprecatedNamespaceTableDescriptorMigration - 1),
BinaryMinSupportedVersionOverride: clusterversion.ByKey(clusterversion.DeleteDeprecatedNamespaceTableDescriptorMigration - 1),
},
},
},
Expand Down
5 changes: 4 additions & 1 deletion pkg/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,15 @@ type initServerCfg struct {

func newInitServerConfig(ctx context.Context, cfg Config, dialOpts []grpc.DialOption) initServerCfg {
binaryVersion := cfg.Settings.Version.BinaryVersion()
binaryMinSupportedVersion := cfg.Settings.Version.BinaryMinSupportedVersion()
if knobs := cfg.TestingKnobs.Server; knobs != nil {
if ov := knobs.(*TestingKnobs).BinaryVersionOverride; ov != (roachpb.Version{}) {
binaryVersion = ov
}
if ov := knobs.(*TestingKnobs).BinaryMinSupportedVersionOverride; ov != (roachpb.Version{}) {
binaryMinSupportedVersion = ov
}
}
binaryMinSupportedVersion := cfg.Settings.Version.BinaryMinSupportedVersion()
if binaryVersion.Less(binaryMinSupportedVersion) {
log.Fatalf(ctx, "binary version (%s) less than min supported version (%s)",
binaryVersion, binaryMinSupportedVersion)
Expand Down
6 changes: 5 additions & 1 deletion pkg/server/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ type TestingKnobs struct {
// out join requests.
//
// NB: When setting this, you probably also want to set
// DisableAutomaticVersionUpgrade.
// DisableAutomaticVersionUpgrade and BinaryMinSupportedVersionOverride.
//
// TODO(irfansharif): Update users of this testing knob to use the
// appropriate clusterversion.Handle instead.
BinaryVersionOverride roachpb.Version
// BinaryMinSupportedVersionOverride overrides the minimum supported binary
// version. See BinaryVersionOverride.
BinaryMinSupportedVersionOverride roachpb.Version

// An (additional) callback invoked whenever a
// node is permanently removed from the cluster.
OnDecommissionedCallback func(livenesspb.Liveness)
Expand Down

0 comments on commit 0f9572a

Please sign in to comment.