Skip to content

Commit

Permalink
Merge #114439
Browse files Browse the repository at this point in the history
114439: upgrades: skip upgrade tests when MinSupported is bumped r=RaduBerinde a=RaduBerinde

This commit adds a `SkipWhenMinSupportedVersionIsAtLeast` primitive
and applies it to tests for 23.1->23.2 upgrades. This will allow
bumping `MinSupported` (e.g. in a special build) without having to
remove these tests at the same time.

Epic: none
Release note: None

Co-authored-by: Radu Berinde <[email protected]>
  • Loading branch information
craig[bot] and RaduBerinde committed Nov 15, 2023
2 parents 603b980 + a54375b commit c15e481
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/clusterversion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/build",
"//pkg/roachpb",
"//pkg/settings",
"//pkg/testutils/skip",
"//pkg/util/envutil",
"//pkg/util/log",
"//pkg/util/metric",
Expand Down
19 changes: 19 additions & 0 deletions pkg/clusterversion/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,27 @@

package clusterversion

import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
)

// TestingClusterVersion is a ClusterVersion that tests can use when they don't
// want to go through a Settings object.
var TestingClusterVersion = ClusterVersion{
Version: Latest.Version(),
}

// SkipWhenMinSupportedVersionIsAtLeast skips this test if MinSupported is >=
// the given version.
//
// Used for upgrade tests that require support for a previous version; it allows
// experimenting with bumping MinSupported and limiting how many things must be
// fixed in the same PR that bumps it.
func SkipWhenMinSupportedVersionIsAtLeast(t skip.SkippableTest, major, minor int) {
t.Helper()
v := roachpb.Version{Major: int32(major), Minor: int32(minor)}
if MinSupported.Version().AtLeast(v) {
skip.IgnoreLint(t, "test disabled when MinVersion >= %d.%d", major, minor)
}
}
2 changes: 2 additions & 0 deletions pkg/upgrade/upgrades/v23_2_create_region_liveness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

func TestRegionLivenessTableMigration(t *testing.T) {
skip.UnderStressRace(t)
clusterversion.SkipWhenMinSupportedVersionIsAtLeast(t, 23, 2)

defer leaktest.AfterTest(t)()
ctx := context.Background()

Expand Down
7 changes: 5 additions & 2 deletions pkg/upgrade/upgrades/v23_2_grant_execute_to_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ import (
)

func TestGrantExecuteToPublicOnAllFunctions(t *testing.T) {
skip.UnderRace(t)
clusterversion.SkipWhenMinSupportedVersionIsAtLeast(t, 23, 2)

defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

skip.UnderRace(t)

var (
v0 = clusterversion.MinSupported.Version()
v1 = clusterversion.Latest.Version()
Expand Down Expand Up @@ -118,6 +119,8 @@ func TestGrantExecuteToPublicOnAllFunctions(t *testing.T) {
}

func BenchmarkGrantExecuteToPublicOnAllFunctions(b *testing.B) {
clusterversion.SkipWhenMinSupportedVersionIsAtLeast(b, 23, 2)

defer leaktest.AfterTest(b)()
defer log.Scope(b).Close(b)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
)

func TestStmtDiagForPlanGistMigration(t *testing.T) {
clusterversion.SkipWhenMinSupportedVersionIsAtLeast(t, 23, 2)

defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

Expand Down
2 changes: 2 additions & 0 deletions pkg/upgrade/upgrades/v23_2_system_exec_insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
)

func TestExecSystemInsights(t *testing.T) {
clusterversion.SkipWhenMinSupportedVersionIsAtLeast(t, 23, 2)

defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

Expand Down

0 comments on commit c15e481

Please sign in to comment.