Skip to content

Commit

Permalink
upgrademanager: simplify TestMigrationFailure
Browse files Browse the repository at this point in the history
This also removes `TODOTestTenantDisabled`.

(I have verified the test works, albeit still flaky due to cockroachdb#106648, by
temporarily removing the skip.)

Release note: None
  • Loading branch information
knz committed Jul 21, 2023
1 parent 73f51aa commit 67974d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/upgrade/upgrademanager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ go_test(
args = ["-test.timeout=295s"],
deps = [
"//pkg/base",
"//pkg/ccl",
"//pkg/ccl/kvccl/kvtenantccl",
"//pkg/clusterversion",
"//pkg/jobs",
Expand Down
2 changes: 2 additions & 0 deletions pkg/upgrade/upgrademanager/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach/pkg/ccl"
"github.com/cockroachdb/cockroach/pkg/security/securityassets"
"github.com/cockroachdb/cockroach/pkg/security/securitytest"
"github.com/cockroachdb/cockroach/pkg/server"
Expand All @@ -25,6 +26,7 @@ func TestMain(m *testing.M) {
securityassets.SetLoader(securitytest.EmbeddedAssets)
serverutils.InitTestServerFactory(server.TestServerFactory)
serverutils.InitTestClusterFactory(testcluster.TestClusterFactory)
defer ccl.TestingEnableEnterprise()()
os.Exit(m.Run())
}

Expand Down
32 changes: 19 additions & 13 deletions pkg/upgrade/upgrademanager/manager_external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestAlreadyRunningJobsAreHandledProperly(t *testing.T) {
tc := testcluster.StartTestCluster(t, 2, base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(107396),

Knobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
Server: &server.TestingKnobs{
Expand Down Expand Up @@ -243,6 +245,8 @@ func TestMigrateUpdatesReplicaVersion(t *testing.T) {
tc := testcluster.StartTestCluster(t, 2, base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{
DefaultTestTenant: base.TestIsSpecificToStorageLayerAndNeedsASystemTenant,

Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
BootstrapVersionKeyOverride: clusterversion.BinaryMinSupportedVersionKey,
Expand Down Expand Up @@ -346,6 +350,8 @@ func TestConcurrentMigrationAttempts(t *testing.T) {
tc := testcluster.StartTestCluster(t, 3, base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(107395),

Settings: cluster.MakeTestingClusterSettingsWithVersions(
versions[len(versions)-1],
versions[0],
Expand Down Expand Up @@ -435,6 +441,8 @@ func TestPauseMigration(t *testing.T) {
tc := testcluster.StartTestCluster(t, 2, base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(107393),

Knobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
Server: &server.TestingKnobs{
Expand Down Expand Up @@ -602,6 +610,8 @@ func TestPrecondition(t *testing.T) {
ctx := context.Background()
args := func() base.TestServerArgs {
return base.TestServerArgs{
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(107397),

Knobs: knobs,
Settings: cluster.MakeTestingClusterSettingsWithVersions(
v2, // binaryVersion
Expand Down Expand Up @@ -689,24 +699,20 @@ func TestMigrationFailure(t *testing.T) {
fenceVersion := upgrade.FenceVersionFor(ctx, clusterversion.ClusterVersion{Version: failVersion}).Version
t.Logf("test will fail at version: %s", failVersion.String())

// Create a storage cluster for the tenant
testCluster := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
DefaultTestTenant: base.TODOTestTenantDisabled,
Knobs: base.TestingKnobs{
SQLEvalContext: &eval.TestingKnobs{
TenantLogicalVersionKeyOverride: startVersionKey,
},
// Create a storage cluster for the tenant.
s, goDB, _ := serverutils.StartServer(t, base.TestServerArgs{
DefaultTestTenant: base.TestControlsTenantsExplicitly,
Knobs: base.TestingKnobs{
SQLEvalContext: &eval.TestingKnobs{
TenantLogicalVersionKeyOverride: startVersionKey,
},
},
})
defer testCluster.Stopper().Stop(ctx)
defer s.Stopper().Stop(ctx)

// Set the version override so that the tenant is able to upgrade. If this is
// not set, the tenant treats the storage cluster as if it had the oldest
// supported binary version.
s := testCluster.Server(0)
goDB := serverutils.OpenDBConn(t, s.ServingSQLAddr(), "system", false, s.Stopper())
_, err := goDB.Exec(`ALTER TENANT ALL SET CLUSTER SETTING version = $1`, endVersion.String())
require.NoError(t, err)

Expand All @@ -722,7 +728,7 @@ func TestMigrationFailure(t *testing.T) {
false,
)
require.NoError(t, clusterversion.Initialize(ctx, startVersion, &tenantSettings.SV))
tenant, db := serverutils.StartTenant(t, testCluster.Server(0), base.TestTenantArgs{
tenant, db := serverutils.StartTenant(t, s, base.TestTenantArgs{
TenantID: roachpb.MustMakeTenantID(10),
Settings: tenantSettings,
TestingKnobs: base.TestingKnobs{
Expand Down Expand Up @@ -773,7 +779,7 @@ func TestMigrationFailure(t *testing.T) {
checkActiveVersion(t, startVersion)
checkSettingVersion(t, startVersion)

// Try to finalize
// Try to finalize.
_, err = db.Exec(`SET CLUSTER SETTING version = $1`, endVersion.String())
require.Error(t, err)
checkActiveVersion(t, fenceVersion)
Expand Down

0 comments on commit 67974d8

Please sign in to comment.