From c8996612ac823b1e65028a8b4eb8e3f8d778138e Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Wed, 19 Jul 2023 13:27:28 -0700 Subject: [PATCH] sql: adjust more tests to work with test tenant Release note: None --- pkg/sql/alter_column_type_test.go | 6 +-- pkg/sql/ambiguous_commit_test.go | 3 +- pkg/sql/backfill_num_ranges_in_span_test.go | 19 +++++---- pkg/sql/conn_executor_test.go | 21 ++++++---- pkg/sql/crdb_internal_test.go | 4 +- pkg/sql/create_as_test.go | 41 +++++++++++++++--- pkg/sql/create_test.go | 24 ++++++----- pkg/sql/distsql_plan_changefeed_test.go | 10 ++--- pkg/sql/distsql_running_test.go | 1 + pkg/sql/drop_function_test.go | 4 +- pkg/sql/drop_test.go | 9 ++-- pkg/sql/explain_test.go | 11 +++-- pkg/sql/indexbackfiller_test.go | 46 ++++++++++----------- pkg/sql/instrumentation_test.go | 24 +++++------ pkg/sql/mem_limit_test.go | 1 + pkg/sql/multitenant_admin_function_test.go | 9 +++- pkg/sql/revert_test.go | 32 +++++++------- pkg/sql/schema_changer_test.go | 6 +-- pkg/sql/sqltestutils/BUILD.bazel | 1 - pkg/sql/sqltestutils/show_create_table.go | 22 ++++++---- pkg/sql/tests/split_test.go | 18 ++++---- 21 files changed, 183 insertions(+), 129 deletions(-) diff --git a/pkg/sql/alter_column_type_test.go b/pkg/sql/alter_column_type_test.go index dd85059d84ee..35b89fe89b60 100644 --- a/pkg/sql/alter_column_type_test.go +++ b/pkg/sql/alter_column_type_test.go @@ -20,7 +20,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" - "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "github.com/cockroachdb/cockroach/pkg/sql/tests" @@ -257,8 +256,7 @@ func TestAlterColumnTypeFailureRollback(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, kvDB := serverutils.StartServer(t, params) + s, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) sqlDB := sqlutils.MakeSQLRunner(db) defer s.Stopper().Stop(ctx) @@ -272,7 +270,7 @@ func TestAlterColumnTypeFailureRollback(t *testing.T) { // Ensure that the add column and column swap mutations are cleaned up. testutils.SucceedsSoon(t, func() error { - desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "t", "test") + desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, s.TenantOrServer().Codec(), "t", "test") if len(desc.AllMutations()) != 0 { return errors.New("expected no mutations on TableDescriptor") } diff --git a/pkg/sql/ambiguous_commit_test.go b/pkg/sql/ambiguous_commit_test.go index 626c4a0abfa9..0de6ebbb5618 100644 --- a/pkg/sql/ambiguous_commit_test.go +++ b/pkg/sql/ambiguous_commit_test.go @@ -18,7 +18,6 @@ import ( "testing" "github.com/cockroachdb/cockroach/pkg/base" - "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord" "github.com/cockroachdb/cockroach/pkg/kv/kvpb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" @@ -171,7 +170,7 @@ func TestAmbiguousCommit(t *testing.T) { } tableID := sqlutils.QueryTableID(t, sqlDB, "test", "public", "t") - tableStartKey.Store(keys.SystemSQLCodec.TablePrefix(tableID)) + tableStartKey.Store(tc.TenantOrServer(0).Codec().TablePrefix(tableID)) // Wait for new table to split & replication. if err := tc.WaitForSplitAndInitialization(tableStartKey.Load().(roachpb.Key)); err != nil { diff --git a/pkg/sql/backfill_num_ranges_in_span_test.go b/pkg/sql/backfill_num_ranges_in_span_test.go index eba17926b64a..7c23f5a10870 100644 --- a/pkg/sql/backfill_num_ranges_in_span_test.go +++ b/pkg/sql/backfill_num_ranges_in_span_test.go @@ -19,7 +19,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql" - "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/encoding" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -84,13 +84,14 @@ func TestNumRangesInSpanContainedBy(t *testing.T) { }, } - tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{ - ReplicationMode: base.ReplicationManual, + s, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{ + DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(107376), }) ctx := context.Background() - defer tc.Stopper().Stop(ctx) + defer s.Stopper().Stop(ctx) - scratchKey := tc.ScratchRange(t) + scratchKey, err := s.ScratchRange() + require.NoError(t, err) mkKey := func(prefix roachpb.Key, k string) roachpb.Key { return append(prefix[:len(prefix):len(prefix)], k...) } @@ -106,8 +107,7 @@ func TestNumRangesInSpanContainedBy(t *testing.T) { EndKey: mkEndKey(prefix, sp[1]), } } - db := tc.Server(0).DB() - dsp := tc.Server(0).ExecutorConfig().(sql.ExecutorConfig).DistSQLPlanner + dsp := s.TenantOrServer().ExecutorConfig().(sql.ExecutorConfig).DistSQLPlanner spanString := func(sp span) string { return sp[0] + "-" + sp[1] } @@ -121,7 +121,8 @@ func TestNumRangesInSpanContainedBy(t *testing.T) { run := func(t *testing.T, c testCase) { prefix := encoding.EncodeStringAscending(scratchKey, t.Name()) for _, split := range c.splits { - tc.SplitRangeOrFatal(t, mkKey(prefix, split)) + _, _, err = s.SplitRange(mkKey(prefix, split)) + require.NoError(t, err) } outerSpan := mkSpan(prefix, c.outer) for _, sc := range c.subtests { @@ -130,7 +131,7 @@ func TestNumRangesInSpanContainedBy(t *testing.T) { for _, sp := range sc.subSpans { spans = append(spans, mkSpan(prefix, sp)) } - total, contained, err := sql.NumRangesInSpanContainedBy(ctx, db, dsp, outerSpan, spans) + total, contained, err := sql.NumRangesInSpanContainedBy(ctx, kvDB, dsp, outerSpan, spans) require.NoError(t, err) require.Equal(t, c.total, total) require.Equal(t, sc.contained, contained) diff --git a/pkg/sql/conn_executor_test.go b/pkg/sql/conn_executor_test.go index 318a95901008..29ded242dc69 100644 --- a/pkg/sql/conn_executor_test.go +++ b/pkg/sql/conn_executor_test.go @@ -315,12 +315,12 @@ func TestErrorOnRollback(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - // We can't get the tableID programmatically here. - // The table id can be retrieved by doing. - // CREATE DATABASE test; - // CREATE TABLE test.t(); - // SELECT id FROM system.namespace WHERE name = 't' AND "parentID" != 1 - const targetKeyStringFmt string = "/Table/%d/1/1/0" + getTargetKey := func(s serverutils.TestServerInterface, tableID uint32) string { + if s.StartedDefaultTestTenant() { + return fmt.Sprintf("/Tenant/%d/Table/%d/1/1/0", serverutils.TestTenantID().ToUint64(), tableID) + } + return fmt.Sprintf("/Table/%d/1/1/0", tableID) + } var targetKeyString atomic.Value targetKeyString.Store("") var injectedErr int64 @@ -363,7 +363,7 @@ CREATE DATABASE t; CREATE TABLE t.test (k INT PRIMARY KEY, v TEXT); `) tableID := sqlutils.QueryTableID(t, sqlDB, "t", "public", "test") - targetKeyString.Store(fmt.Sprintf(targetKeyStringFmt, tableID)) + targetKeyString.Store(getTargetKey(s, tableID)) tx, err := sqlDB.Begin() if err != nil { @@ -774,6 +774,7 @@ func TestRetriableErrorDuringPrepare(t *testing.T) { func TestRetriableErrorDuringUpgradedTransaction(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + var retryCount int64 const numToRetry = 2 // only fail on the first two attempts filter := newDynamicRequestFilter() @@ -785,6 +786,7 @@ func TestRetriableErrorDuringUpgradedTransaction(t *testing.T) { }, }) defer s.Stopper().Stop(context.Background()) + codec := s.TenantOrServer().Codec() conn, err := sqlDB.Conn(context.Background()) require.NoError(t, err) @@ -803,7 +805,7 @@ func TestRetriableErrorDuringUpgradedTransaction(t *testing.T) { } if req, ok := ba.GetArg(kvpb.ConditionalPut); ok { put := req.(*kvpb.ConditionalPutRequest) - _, tableID, err := keys.SystemSQLCodec.DecodeTablePrefix(put.Key) + _, tableID, err := codec.DecodeTablePrefix(put.Key) if err != nil || tableID != fooTableId { return nil } @@ -843,6 +845,7 @@ func TestErrorDuringPrepareInExplicitTransactionPropagates(t *testing.T) { }, }) defer s.Stopper().Stop(ctx) + codec := s.TenantOrServer().Codec() testDB := sqlutils.MakeSQLRunner(sqlDB) testDB.Exec(t, "CREATE TABLE foo (i INT PRIMARY KEY)") @@ -880,7 +883,7 @@ func TestErrorDuringPrepareInExplicitTransactionPropagates(t *testing.T) { } if req, ok := ba.GetArg(kvpb.Get); ok { get := req.(*kvpb.GetRequest) - _, tableID, err := keys.SystemSQLCodec.DecodeTablePrefix(get.Key) + _, tableID, err := codec.DecodeTablePrefix(get.Key) if err != nil || tableID != keys.NamespaceTableID { err = nil return nil diff --git a/pkg/sql/crdb_internal_test.go b/pkg/sql/crdb_internal_test.go index d5dd379f0c74..9a86f22f9b0b 100644 --- a/pkg/sql/crdb_internal_test.go +++ b/pkg/sql/crdb_internal_test.go @@ -1510,7 +1510,7 @@ func TestInternalSystemJobsAccess(t *testing.T) { // do not disable background job creation nor job adoption. This is because creating // users requires jobs to be created and run. Thus, this test only creates jobs of type // jobspb.TypeImport and overrides the import resumer. - registry := s.JobRegistry().(*jobs.Registry) + registry := s.TenantOrServer().JobRegistry().(*jobs.Registry) registry.TestingWrapResumerConstructor(jobspb.TypeImport, func(r jobs.Resumer) jobs.Resumer { return &fakeResumer{} }) @@ -1519,7 +1519,7 @@ func TestInternalSystemJobsAccess(t *testing.T) { pgURL := url.URL{ Scheme: "postgres", User: url.UserPassword(user, "test"), - Host: s.SQLAddr(), + Host: s.ServingSQLAddr(), } db2, err := gosql.Open("postgres", pgURL.String()) assert.NoError(t, err) diff --git a/pkg/sql/create_as_test.go b/pkg/sql/create_as_test.go index 4c2835b648bb..2b8764ea4a85 100644 --- a/pkg/sql/create_as_test.go +++ b/pkg/sql/create_as_test.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/stretchr/testify/require" ) @@ -30,11 +31,12 @@ import ( // CREATE TABLE AS and CREATE MATERIALIZED VIEW AS. func TestCreateAsVTable(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) ctx := context.Background() - testCluster := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{}) - defer testCluster.Stopper().Stop(ctx) - sqlRunner := sqlutils.MakeSQLRunner(testCluster.ServerConn(0)) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer s.Stopper().Stop(ctx) + sqlRunner := sqlutils.MakeSQLRunner(db) var p parser.Parser i := 0 @@ -74,6 +76,27 @@ func TestCreateAsVTable(t *testing.T) { } fqName := name.FQString() + if s.StartedDefaultTestTenant() { + // Some of the virtual tables are currently only available in + // the system tenant. + // TODO(yuzefovich): update this list when #54252 is addressed. + onlySystemTenant := map[string]struct{}{ + `"".crdb_internal.gossip_alerts`: {}, + `"".crdb_internal.gossip_liveness`: {}, + `"".crdb_internal.gossip_nodes`: {}, + `"".crdb_internal.kv_flow_controller`: {}, + `"".crdb_internal.kv_flow_control_handles`: {}, + `"".crdb_internal.kv_flow_token_deductions`: {}, + `"".crdb_internal.kv_node_status`: {}, + `"".crdb_internal.kv_node_liveness`: {}, + `"".crdb_internal.kv_store_status`: {}, + `"".crdb_internal.node_tenant_capabilities_cache`: {}, + `"".crdb_internal.tenant_usage_details`: {}, + } + if _, ok := onlySystemTenant[fqName]; ok { + continue + } + } // Filter by trace_id to prevent error when selecting from // crdb_internal.cluster_inflight_traces: // "pq: a trace_id value needs to be specified". @@ -101,6 +124,7 @@ func TestCreateAsVTable(t *testing.T) { func TestCreateAsShow(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) testCases := []struct { sql string @@ -267,9 +291,9 @@ func TestCreateAsShow(t *testing.T) { } ctx := context.Background() - testCluster := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{}) - defer testCluster.Stopper().Stop(ctx) - sqlRunner := sqlutils.MakeSQLRunner(testCluster.ServerConn(0)) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer s.Stopper().Stop(ctx) + sqlRunner := sqlutils.MakeSQLRunner(db) for i, testCase := range testCases { t.Run(testCase.sql, func(t *testing.T) { @@ -277,6 +301,11 @@ func TestCreateAsShow(t *testing.T) { return } if testCase.setup != "" { + if s.StartedDefaultTestTenant() && strings.Contains(testCase.setup, "create_tenant") { + // Only the system tenant has the ability to create other + // tenants. + return + } sqlRunner.Exec(t, testCase.setup) } createTableStmt := fmt.Sprintf( diff --git a/pkg/sql/create_test.go b/pkg/sql/create_test.go index cb66ead5cbaf..63fd585f202a 100644 --- a/pkg/sql/create_test.go +++ b/pkg/sql/create_test.go @@ -20,6 +20,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/security/username" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descidgen" @@ -83,7 +84,8 @@ func createTestTable( // of values. func verifyTables( t *testing.T, - tc *testcluster.TestCluster, + kvDB *kv.DB, + codec keys.SQLCodec, completed chan int, expectedNumOfTables int, descIDStart descpb.ID, @@ -95,8 +97,7 @@ func verifyTables( for id := range completed { count++ tableName := fmt.Sprintf("table_%d", id) - kvDB := tc.Servers[count%tc.NumServers()].DB() - tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "test", tableName) + tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, codec, "test", tableName) if tableDesc.GetID() < descIDStart { t.Fatalf( "table %s's ID %d is too small. Expected >= %d", @@ -123,12 +124,11 @@ func verifyTables( // Check that no extra descriptors have been written in the range // descIDStart..maxID. - kvDB := tc.Servers[0].DB() for id := descIDStart; id < maxID; id++ { if _, ok := tableIDs[id]; ok { continue } - descKey := catalogkeys.MakeDescMetadataKey(keys.SystemSQLCodec, id) + descKey := catalogkeys.MakeDescMetadataKey(codec, id) desc := &descpb.Descriptor{} if err := kvDB.GetProto(context.Background(), descKey, desc); err != nil { t.Fatal(err) @@ -157,8 +157,8 @@ func TestParallelCreateTables(t *testing.T) { t.Fatal(err) } // Get the id descriptor generator count. - s := tc.Servers[0] - idgen := descidgen.NewGenerator(s.ClusterSettings(), keys.SystemSQLCodec, s.DB()) + s := tc.Servers[0].TenantOrServer() + idgen := descidgen.NewGenerator(s.ClusterSettings(), s.Codec(), s.DB()) descIDStart, err := idgen.PeekNextUniqueDescID(context.Background()) if err != nil { t.Fatal(err) @@ -185,7 +185,8 @@ func TestParallelCreateTables(t *testing.T) { verifyTables( t, - tc, + s.DB(), + s.Codec(), completed, numberOfTables, descIDStart, @@ -211,8 +212,8 @@ func TestParallelCreateConflictingTables(t *testing.T) { } // Get the id descriptor generator count. - s := tc.Servers[0] - idgen := descidgen.NewGenerator(s.ClusterSettings(), keys.SystemSQLCodec, s.DB()) + s := tc.Servers[0].TenantOrServer() + idgen := descidgen.NewGenerator(s.ClusterSettings(), s.Codec(), s.DB()) descIDStart, err := idgen.PeekNextUniqueDescID(context.Background()) if err != nil { t.Fatal(err) @@ -239,7 +240,8 @@ func TestParallelCreateConflictingTables(t *testing.T) { verifyTables( t, - tc, + s.DB(), + s.Codec(), completed, 1, /* expectedNumOfTables */ descIDStart, diff --git a/pkg/sql/distsql_plan_changefeed_test.go b/pkg/sql/distsql_plan_changefeed_test.go index 7f5e15351e45..1119f0fac715 100644 --- a/pkg/sql/distsql_plan_changefeed_test.go +++ b/pkg/sql/distsql_plan_changefeed_test.go @@ -17,6 +17,7 @@ import ( "sort" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" @@ -492,9 +493,9 @@ func TestCdcExpressionExecution(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, kvDB := serverutils.StartServer(t, params) + s, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) + tt := s.TenantOrServer() sqlDB := sqlutils.MakeSQLRunner(db) sqlDB.Exec(t, `CREATE TABLE foo ( @@ -506,11 +507,10 @@ FAMILY main(a,b,c), FAMILY extra (extra) )`) - fooDesc := desctestutils.TestingGetTableDescriptor( - kvDB, keys.SystemSQLCodec, "defaultdb", "public", "foo") + fooDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, tt.Codec(), "defaultdb", "foo") ctx := context.Background() - execCfg := s.ExecutorConfig().(ExecutorConfig) + execCfg := tt.ExecutorConfig().(ExecutorConfig) sd := NewInternalSessionData(ctx, execCfg.Settings, "test") sd.Database = "defaultdb" p, cleanup := NewInternalPlanner("test", kv.NewTxn(ctx, kvDB, s.NodeID()), diff --git a/pkg/sql/distsql_running_test.go b/pkg/sql/distsql_running_test.go index 74bf5b8bc53f..5364a1990c55 100644 --- a/pkg/sql/distsql_running_test.go +++ b/pkg/sql/distsql_running_test.go @@ -625,6 +625,7 @@ func TestDistSQLReceiverDrainsMeta(t *testing.T) { Insecure: true, }}) defer tc.Stopper().Stop(ctx) + SecondaryTenantSplitAtEnabled.Override(ctx, &tc.Server(0).TenantOrServer().ClusterSettings().SV, true) // Create a table with 30 rows, split them into 3 ranges with each node // having one. diff --git a/pkg/sql/drop_function_test.go b/pkg/sql/drop_function_test.go index 5076090fd89a..c96b86aa6cc2 100644 --- a/pkg/sql/drop_function_test.go +++ b/pkg/sql/drop_function_test.go @@ -35,7 +35,9 @@ func TestDropFunction(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{}) + s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{ + DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(107322), + }) defer s.Stopper().Stop(ctx) tDB := sqlutils.MakeSQLRunner(sqlDB) diff --git a/pkg/sql/drop_test.go b/pkg/sql/drop_test.go index e352f03d7890..5b128f9329d9 100644 --- a/pkg/sql/drop_test.go +++ b/pkg/sql/drop_test.go @@ -223,10 +223,11 @@ INSERT INTO t.kv VALUES ('c', 'e'), ('a', 'c'), ('b', 'd'); func TestDropDatabaseEmpty(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, sqlDB, kvDB := serverutils.StartServer(t, params) - defer s.Stopper().Stop(context.Background()) + ctx := context.Background() + s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) + defer s.Stopper().Stop(ctx) + codec := s.TenantOrServer().Codec() if _, err := sqlDB.Exec(` CREATE DATABASE t; @@ -234,7 +235,7 @@ CREATE DATABASE t; t.Fatal(err) } - dKey := catalogkeys.EncodeNameKey(keys.SystemSQLCodec, descpb.NameInfo{Name: "t"}) + dKey := catalogkeys.EncodeNameKey(codec, descpb.NameInfo{Name: "t"}) r, err := kvDB.Get(ctx, dKey) if err != nil { t.Fatal(err) diff --git a/pkg/sql/explain_test.go b/pkg/sql/explain_test.go index 227e19592cc7..491b87b7cc39 100644 --- a/pkg/sql/explain_test.go +++ b/pkg/sql/explain_test.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/internal/sqlsmith" + "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -40,9 +41,13 @@ func TestStatementReuses(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) - defer s.Stopper().Stop(context.Background()) + ctx := context.Background() + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer s.Stopper().Stop(ctx) + tenantSettings := s.TenantOrServer().ClusterSettings() + sql.SecondaryTenantScatterEnabled.Override(ctx, &tenantSettings.SV, true) + sql.SecondaryTenantSplitAtEnabled.Override(ctx, &tenantSettings.SV, true) + sql.SecondaryTenantZoneConfigsEnabled.Override(ctx, &tenantSettings.SV, true) initStmts := []string{ `CREATE DATABASE d`, diff --git a/pkg/sql/indexbackfiller_test.go b/pkg/sql/indexbackfiller_test.go index 83c584115771..ba041e5ffb24 100644 --- a/pkg/sql/indexbackfiller_test.go +++ b/pkg/sql/indexbackfiller_test.go @@ -43,7 +43,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" - "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/mon" @@ -365,7 +364,7 @@ INSERT INTO foo VALUES (1), (10), (100); // as datums. The datums will correspond to each of the columns stored in the // index, ordered by column ID. fetchIndex := func( - ctx context.Context, t *testing.T, txn *kv.Txn, table *tabledesc.Mutable, indexID descpb.IndexID, + ctx context.Context, t *testing.T, codec keys.SQLCodec, txn *kv.Txn, table *tabledesc.Mutable, indexID descpb.IndexID, ) []tree.Datums { t.Helper() @@ -384,7 +383,7 @@ INSERT INTO foo VALUES (1), (10), (100); } require.NoError(t, err) - spans := []roachpb.Span{table.IndexSpan(keys.SystemSQLCodec, indexID)} + spans := []roachpb.Span{table.IndexSpan(codec, indexID)} var fetcherCols []descpb.ColumnID for _, col := range table.PublicColumns() { if colIDsNeeded.Contains(col.GetID()) { @@ -395,7 +394,7 @@ INSERT INTO foo VALUES (1), (10), (100); var spec fetchpb.IndexFetchSpec require.NoError(t, rowenc.InitIndexFetchSpec( &spec, - keys.SystemSQLCodec, + codec, table, idx, fetcherCols, @@ -450,26 +449,24 @@ INSERT INTO foo VALUES (1), (10), (100); blockChan := make(chan struct{}) var jobToBlock atomic.Value jobToBlock.Store(jobspb.InvalidJobID) - tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{ - ServerArgs: base.TestServerArgs{ - Knobs: base.TestingKnobs{ - SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ - RunBeforeResume: func(jobID jobspb.JobID) error { - if jobID == jobToBlock.Load().(jobspb.JobID) { - <-blockChan - return errors.New("boom") - } - return nil - }, + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{ + Knobs: base.TestingKnobs{ + SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ + RunBeforeResume: func(jobID jobspb.JobID) error { + if jobID == jobToBlock.Load().(jobspb.JobID) { + <-blockChan + return errors.New("boom") + } + return nil }, }, }, }) - defer tc.Stopper().Stop(ctx) + defer s.Stopper().Stop(ctx) defer close(blockChan) // Run the initial setupSQL. - tdb := sqlutils.MakeSQLRunner(tc.ServerConn(0)) + tdb := sqlutils.MakeSQLRunner(db) tdb.Exec(t, test.setupSQL) // Fetch the descriptor ID for the relevant table. @@ -478,11 +475,12 @@ INSERT INTO foo VALUES (1), (10), (100); // Run the testCase's setupDesc function to prepare an index backfill // mutation. Also, create an associated job and set it up to be blocked. - s0 := tc.Server(0) - lm := s0.LeaseManager().(*lease.Manager) - settings := s0.ClusterSettings() - execCfg := s0.ExecutorConfig().(sql.ExecutorConfig) - jr := s0.JobRegistry().(*jobs.Registry) + lm := s.LeaseManager().(*lease.Manager) + tt := s.TenantOrServer() + codec := tt.Codec() + settings := tt.ClusterSettings() + execCfg := tt.ExecutorConfig().(sql.ExecutorConfig) + jr := tt.JobRegistry().(*jobs.Registry) var j *jobs.Job var table catalog.TableDescriptor require.NoError(t, sql.DescsTxn(ctx, &execCfg, func( @@ -531,7 +529,7 @@ INSERT INTO foo VALUES (1), (10), (100); changer := sql.NewSchemaChangerForTesting( tableID, 1, execCfg.NodeInfo.NodeID.SQLInstanceID(), execCfg.InternalDB, lm, jr, &execCfg, settings) changer.SetJob(j) - spans := []roachpb.Span{table.IndexSpan(keys.SystemSQLCodec, test.indexToBackfill)} + spans := []roachpb.Span{table.IndexSpan(codec, test.indexToBackfill)} require.NoError(t, changer.TestingDistIndexBackfill(ctx, table.GetVersion(), spans, []descpb.IndexID{test.indexToBackfill}, backfill.IndexMutationFilter)) @@ -550,7 +548,7 @@ INSERT INTO foo VALUES (1), (10), (100); require.NoError(t, table.MakeMutationComplete(mut)) } table.Mutations = table.Mutations[toComplete:] - datums := fetchIndex(ctx, t, txn.KV(), table, test.indexToBackfill) + datums := fetchIndex(ctx, t, codec, txn.KV(), table, test.indexToBackfill) require.Equal(t, test.expectedContents, datumSliceToStrMatrix(datums)) return nil })) diff --git a/pkg/sql/instrumentation_test.go b/pkg/sql/instrumentation_test.go index f33d75b415e9..8c21d8269583 100644 --- a/pkg/sql/instrumentation_test.go +++ b/pkg/sql/instrumentation_test.go @@ -16,7 +16,6 @@ import ( "testing" "github.com/cockroachdb/cockroach/pkg/base" - "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/appstatspb" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -32,9 +31,10 @@ func TestSampledStatsCollection(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - st := cluster.MakeTestingClusterSettings() - s, db, _ := serverutils.StartServer(t, base.TestServerArgs{Settings: st}) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) + tt := s.TenantOrServer() + sv, sqlStats := &tt.ClusterSettings().SV, tt.SQLServer().(*Server).sqlStats sqlutils.CreateTable( t, db, "test", "x INT", 10, sqlutils.ToRowFn(sqlutils.RowIdxFn), @@ -43,7 +43,6 @@ func TestSampledStatsCollection(t *testing.T) { getStmtStats := func( t *testing.T, - server serverutils.TestServerInterface, stmt string, implicitTxn bool, database string, @@ -56,7 +55,7 @@ func TestSampledStatsCollection(t *testing.T) { Failed: false, } var stats *appstatspb.CollectedStatementStatistics - require.NoError(t, server.SQLServer().(*Server).sqlStats. + require.NoError(t, sqlStats. GetLocalMemProvider(). IterateStatementStats( ctx, @@ -79,13 +78,12 @@ func TestSampledStatsCollection(t *testing.T) { getTxnStats := func( t *testing.T, - server serverutils.TestServerInterface, key appstatspb.TransactionFingerprintID, ) *appstatspb.CollectedTransactionStatistics { t.Helper() var stats *appstatspb.CollectedTransactionStatistics - require.NoError(t, server.SQLServer().(*Server).sqlStats. + require.NoError(t, sqlStats. GetLocalMemProvider(). IterateTransactionStats( ctx, @@ -108,7 +106,7 @@ func TestSampledStatsCollection(t *testing.T) { if enable { v = 1 } - collectTxnStatsSampleRate.Override(ctx, &st.SV, v) + collectTxnStatsSampleRate.Override(ctx, sv, v) } type queryer interface { @@ -128,7 +126,7 @@ func TestSampledStatsCollection(t *testing.T) { toggleSampling(true) queryDB(t, db, selectOrderBy) - stats := getStmtStats(t, s, selectOrderBy, true /* implicitTxn */, "defaultdb") + stats := getStmtStats(t, selectOrderBy, true /* implicitTxn */, "defaultdb") require.Equal(t, int64(2), stats.Stats.Count, "expected to have collected two sets of general stats") require.Equal(t, int64(1), stats.Stats.ExecStats.Count, "expected to have collected exactly one set of execution stats") @@ -153,8 +151,8 @@ func TestSampledStatsCollection(t *testing.T) { toggleSampling(true) doTxn(t) - aggStats := getStmtStats(t, s, aggregation, false /* implicitTxn */, "defaultdb") - selectStats := getStmtStats(t, s, selectOrderBy, false /* implicitTxn */, "defaultdb") + aggStats := getStmtStats(t, aggregation, false /* implicitTxn */, "defaultdb") + selectStats := getStmtStats(t, selectOrderBy, false /* implicitTxn */, "defaultdb") require.Equal(t, int64(2), aggStats.Stats.Count, "expected to have collected two sets of general stats") require.Equal(t, int64(1), aggStats.Stats.ExecStats.Count, "expected to have collected exactly one set of execution stats") @@ -169,7 +167,7 @@ func TestSampledStatsCollection(t *testing.T) { key := util.MakeFNV64() key.Add(uint64(aggStats.ID)) key.Add(uint64(selectStats.ID)) - txStats := getTxnStats(t, s, appstatspb.TransactionFingerprintID(key.Sum())) + txStats := getTxnStats(t, appstatspb.TransactionFingerprintID(key.Sum())) require.Equal(t, int64(2), txStats.Stats.Count, "expected to have collected two sets of general stats") require.Equal(t, int64(1), txStats.Stats.ExecStats.Count, "expected to have collected exactly one set of execution stats") @@ -191,7 +189,7 @@ func TestSampledStatsCollection(t *testing.T) { // Make sure DEALLOCATE statements are grouped together rather than having // one key per prepared statement name. - stats := getStmtStats(t, s, "DEALLOCATE _", true /* implicitTxn */, "defaultdb") + stats := getStmtStats(t, "DEALLOCATE _", true /* implicitTxn */, "defaultdb") require.Equal(t, int64(2), stats.Stats.Count, "expected to have collected two sets of general stats") require.Equal(t, int64(0), stats.Stats.ExecStats.Count, "expected to have collected zero execution stats") diff --git a/pkg/sql/mem_limit_test.go b/pkg/sql/mem_limit_test.go index 28805aeecce6..1d00f2aea7ea 100644 --- a/pkg/sql/mem_limit_test.go +++ b/pkg/sql/mem_limit_test.go @@ -157,6 +157,7 @@ func TestStreamerTightBudget(t *testing.T) { }) ctx := context.Background() defer s.Stopper().Stop(ctx) + SecondaryTenantSplitAtEnabled.Override(ctx, &s.TenantOrServer().ClusterSettings().SV, true) const blobSize = 1 << 20 const numRows = 5 diff --git a/pkg/sql/multitenant_admin_function_test.go b/pkg/sql/multitenant_admin_function_test.go index 49466d4a4d98..c342f1786e0f 100644 --- a/pkg/sql/multitenant_admin_function_test.go +++ b/pkg/sql/multitenant_admin_function_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/ccl" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" "github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities" @@ -253,7 +254,7 @@ func (tc testCase) runTest( systemDB := serverutils.OpenDBConn( t, - testServer.ServingSQLAddr(), + testServer.SQLAddr(), "", /* useDatabase */ false, /* insecure */ testServer.Stopper(), @@ -416,6 +417,7 @@ func bcap(cap tenantcapabilities.ID, val bool) capValue { func TestMultiTenantAdminFunction(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() testCases := []testCase{ { @@ -628,6 +630,7 @@ func TestMultiTenantAdminFunction(t *testing.T) { func TestTruncateTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() tc := testCase{ system: tenantExpected{ @@ -679,6 +682,7 @@ func TestTruncateTable(t *testing.T) { func TestRelocateVoters(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() testCases := []testCase{ { @@ -770,6 +774,7 @@ func TestRelocateVoters(t *testing.T) { func TestExperimentalRelocateVoters(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() testCases := []testCase{ { @@ -843,6 +848,7 @@ func TestExperimentalRelocateVoters(t *testing.T) { func TestRelocateNonVoters(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() testCases := []testCase{ { @@ -929,6 +935,7 @@ func TestRelocateNonVoters(t *testing.T) { func TestExperimentalRelocateNonVoters(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + defer ccl.TestingEnableEnterprise()() testCases := []testCase{ { diff --git a/pkg/sql/revert_test.go b/pkg/sql/revert_test.go index 04ac842136b7..9becf86864bb 100644 --- a/pkg/sql/revert_test.go +++ b/pkg/sql/revert_test.go @@ -43,10 +43,12 @@ func TestTableRollback(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - s, sqlDB, kv := serverutils.StartServer( - t, base.TestServerArgs{UseDatabase: "test"}) + s, sqlDB, kv := serverutils.StartServer(t, base.TestServerArgs{UseDatabase: "test"}) defer s.Stopper().Stop(context.Background()) - execCfg := s.ExecutorConfig().(sql.ExecutorConfig) + tt := s.TenantOrServer() + codec, sv := tt.Codec(), &tt.ClusterSettings().SV + execCfg := tt.ExecutorConfig().(sql.ExecutorConfig) + sql.SecondaryTenantSplitAtEnabled.Override(ctx, sv, true) db := sqlutils.MakeSQLRunner(sqlDB) db.Exec(t, `CREATE DATABASE IF NOT EXISTS test`) @@ -87,9 +89,9 @@ func TestTableRollback(t *testing.T) { require.Equal(t, before, aost) // Revert the table to ts. - desc := desctestutils.TestingGetPublicTableDescriptor(kv, keys.SystemSQLCodec, "test", "test") + desc := desctestutils.TestingGetPublicTableDescriptor(kv, codec, "test", "test") desc.TableDesc().State = descpb.DescriptorState_OFFLINE // bypass the offline check. - require.NoError(t, sql.RevertTables(context.Background(), kv, &execCfg, []catalog.TableDescriptor{desc}, targetTime, ignoreGC, 10)) + require.NoError(t, sql.RevertTables(ctx, kv, &execCfg, []catalog.TableDescriptor{desc}, targetTime, ignoreGC, 10)) var reverted int db.QueryRow(t, `SELECT xor_agg(k # rev) FROM test`).Scan(&reverted) @@ -101,11 +103,11 @@ func TestTableRollback(t *testing.T) { t.Run("simple-delete-range-predicate", func(t *testing.T) { // Delete all keys with values after the targetTime - desc := desctestutils.TestingGetPublicTableDescriptor(kv, keys.SystemSQLCodec, "test", "test") + desc := desctestutils.TestingGetPublicTableDescriptor(kv, codec, "test", "test") predicates := kvpb.DeleteRangePredicates{StartTime: targetTime} - require.NoError(t, sql.DeleteTableWithPredicate(context.Background(), kv, execCfg.Codec, - &s.ClusterSettings().SV, execCfg.DistSender, desc, predicates, 10)) + require.NoError(t, sql.DeleteTableWithPredicate( + ctx, kv, codec, sv, execCfg.DistSender, desc, predicates, 10)) db.CheckQueryResults(t, `SELECT count(*) FROM test`, beforeNumRows) }) @@ -118,19 +120,19 @@ func TestTableRollbackMultiTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - s, sqlDB, kv := serverutils.StartServer( - t, base.TestServerArgs{UseDatabase: "test"}) + s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{UseDatabase: "test"}) defer s.Stopper().Stop(context.Background()) - execCfg := s.ExecutorConfig().(sql.ExecutorConfig) + tt := s.TenantOrServer() + codec, kvDB := tt.Codec(), tt.DB() + execCfg := tt.ExecutorConfig().(sql.ExecutorConfig) db := sqlutils.MakeSQLRunner(sqlDB) db.Exec(t, "CREATE DATABASE IF NOT EXISTS test") db.Exec(t, "CREATE TABLE test (k INT PRIMARY KEY)") db.Exec(t, "CREATE TABLE test2 (k INT PRIMARY KEY)") - kvDB := s.DB() - desc1 := desctestutils.TestingGetPublicTableDescriptor(kvDB, execCfg.Codec, "test", "test") - desc2 := desctestutils.TestingGetPublicTableDescriptor(kv, keys.SystemSQLCodec, "test", "test2") + desc1 := desctestutils.TestingGetPublicTableDescriptor(kvDB, codec, "test", "test") + desc2 := desctestutils.TestingGetPublicTableDescriptor(kvDB, codec, "test", "test2") tableID1 := desc1.GetID() tableID2 := desc2.GetID() @@ -165,7 +167,7 @@ func TestTableRollbackMultiTable(t *testing.T) { desc1.TableDesc().State = descpb.DescriptorState_OFFLINE desc2.TableDesc().State = descpb.DescriptorState_OFFLINE - require.NoError(t, sql.RevertTables(context.Background(), kv, &execCfg, []catalog.TableDescriptor{desc1, desc2}, targetTime, ignoreGC, 10)) + require.NoError(t, sql.RevertTables(context.Background(), kvDB, &execCfg, []catalog.TableDescriptor{desc1, desc2}, targetTime, ignoreGC, 10)) reverted1, _ := fingerprintTableNoHistory(t, db, tableID1, "") reverted2, _ := fingerprintTableNoHistory(t, db, tableID2, "") diff --git a/pkg/sql/schema_changer_test.go b/pkg/sql/schema_changer_test.go index c2f10e93024b..c9bb0fe548d8 100644 --- a/pkg/sql/schema_changer_test.go +++ b/pkg/sql/schema_changer_test.go @@ -2983,9 +2983,9 @@ UPDATE t.test SET z = NULL, a = $1, b = NULL, c = NULL, d = $1 WHERE y = $2`, 2* func TestPrimaryKeyChangeInTxn(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, sqlDB, kvDB := serverutils.StartServer(t, params) + s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) if _, err := sqlDB.Exec(` @@ -2999,7 +2999,7 @@ COMMIT; } // Ensure that t.test doesn't have any pending mutations // after the primary key change. - desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "t", "test") + desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, s.TenantOrServer().Codec(), "t", "test") if len(desc.AllMutations()) != 0 { t.Fatalf("expected to find 0 mutations, but found %d", len(desc.AllMutations())) } diff --git a/pkg/sql/sqltestutils/BUILD.bazel b/pkg/sql/sqltestutils/BUILD.bazel index 955c1f1a7b7f..28ba198e627f 100644 --- a/pkg/sql/sqltestutils/BUILD.bazel +++ b/pkg/sql/sqltestutils/BUILD.bazel @@ -28,7 +28,6 @@ go_library( "//pkg/sql/pgwire/pgcode", "//pkg/sql/pgwire/pgerror", "//pkg/sql/sem/catconstants", - "//pkg/sql/tests", "//pkg/testutils", "//pkg/testutils/diagutils", "//pkg/testutils/serverutils", diff --git a/pkg/sql/sqltestutils/show_create_table.go b/pkg/sql/sqltestutils/show_create_table.go index 7e959dd18814..61cbc31fdb55 100644 --- a/pkg/sql/sqltestutils/show_create_table.go +++ b/pkg/sql/sqltestutils/show_create_table.go @@ -15,8 +15,9 @@ import ( "fmt" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/sql/tests" + "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/stretchr/testify/require" ) @@ -35,17 +36,22 @@ type ShowCreateTableTestCase struct { } // ShowCreateTableTest tests the output for SHOW CREATE TABLE matches -// the expect values. Furthermore, it round trips SHOW CREATE TABLE -// statements to ensure they produces an identical SHOW CREATE TABLE. +// the expected values. Furthermore, it round trips SHOW CREATE TABLE +// statements to ensure they produce an identical SHOW CREATE TABLE. func ShowCreateTableTest( t *testing.T, extraQuerySetup string, testCases []ShowCreateTableTestCase, ) { - params, _ := tests.CreateTestServerParams() - params.Locality.Tiers = []roachpb.Tier{ - {Key: "region", Value: "us-west1"}, - } - s, sqlDB, _ := serverutils.StartServer(t, params) + s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{ + Locality: roachpb.Locality{ + Tiers: []roachpb.Tier{ + {Key: "region", Value: "us-west1"}, + }, + }, + }) defer s.Stopper().Stop(context.Background()) + tenantSettings := s.TenantOrServer().ClusterSettings() + // In case we're with multi region abstractions against the test tenant. + sql.SecondaryTenantsMultiRegionAbstractionsEnabled.Override(context.Background(), &tenantSettings.SV, true) if _, err := sqlDB.Exec(` SET CLUSTER SETTING sql.cross_db_fks.enabled = TRUE; diff --git a/pkg/sql/tests/split_test.go b/pkg/sql/tests/split_test.go index 52e1b2d9916f..de91ebda2ce1 100644 --- a/pkg/sql/tests/split_test.go +++ b/pkg/sql/tests/split_test.go @@ -16,11 +16,11 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/server" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -68,13 +68,15 @@ func TestSplitOnTableBoundaries(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - // We want fast scan. - params.ScanInterval = time.Millisecond - params.ScanMinIdleTime = time.Millisecond - params.ScanMaxIdleTime = time.Millisecond - params.DisableSpanConfigs = true - s, sqlDB, kvDB := serverutils.StartServer(t, params) + s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{ + // The test needs to be refactored to work with the secondary tenants. + DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(107289), + // We want fast scan. + ScanInterval: time.Millisecond, + ScanMinIdleTime: time.Millisecond, + ScanMaxIdleTime: time.Millisecond, + DisableSpanConfigs: true, + }) defer s.Stopper().Stop(context.Background()) expectedInitialRanges, err := server.ExpectedInitialRangeCount(