Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: remove calls to CreateTestServerParams #107765

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ go_library(
"//pkg/sql",
"//pkg/sql/contention",
"//pkg/sql/sqlstats/persistedsqlstats",
"//pkg/sql/tests",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/util/httputil",
Expand Down
4 changes: 1 addition & 3 deletions pkg/ccl/serverccl/statusccl/tenant_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ func TestTenantGRPCServices(t *testing.T) {

tenantID := serverutils.TestTenantID()
testingKnobs := base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
},
SQLStatsKnobs: sqlstats.CreateTestingKnobs(),
}
tenant, connTenant := serverutils.StartTenant(t, server, base.TestTenantArgs{
TenantID: tenantID,
Expand Down
4 changes: 1 addition & 3 deletions pkg/ccl/serverccl/statusccl/tenant_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,7 @@ func TestTenantCannotSeeNonTenantStats(t *testing.T) {
tenant, sqlDB := serverutils.StartTenant(t, server, base.TestTenantArgs{
TenantID: roachpb.MustMakeTenantID(10 /* id */),
TestingKnobs: base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
},
SQLStatsKnobs: sqlstats.CreateTestingKnobs(),
},
})

Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/serverccl/tenant_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/contention"
"github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/httputil"
Expand Down Expand Up @@ -221,9 +220,10 @@ func newTenantClusterHelper(

var cluster tenantCluster = make([]TestTenant, tenantClusterSize)
for i := 0; i < tenantClusterSize; i++ {
args := tests.CreateTestTenantParams(roachpb.MustMakeTenantID(tenantID))
args.TestingKnobs = knobs
cluster[i] = newTestTenant(t, server, args)
cluster[i] = newTestTenant(t, server, base.TestTenantArgs{
TenantID: roachpb.MustMakeTenantID(tenantID),
TestingKnobs: knobs,
})
}

return cluster
Expand Down
1 change: 0 additions & 1 deletion pkg/ccl/sqlproxyccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ go_test(
"//pkg/sql/pgwire",
"//pkg/sql/pgwire/pgerror",
"//pkg/sql/pgwire/pgwirebase",
"//pkg/sql/tests",
"//pkg/testutils",
"//pkg/testutils/datapathutils",
"//pkg/testutils/serverutils",
Expand Down
19 changes: 10 additions & 9 deletions pkg/ccl/sqlproxyccl/proxy_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
Expand Down Expand Up @@ -1931,15 +1930,16 @@ func TestConnectionMigration(t *testing.T) {
require.NoError(t, err)

// Start first SQL pod.
tenant1, tenantDB1 := serverutils.StartTenant(t, s, tests.CreateTestTenantParams(tenantID))
tenant1, tenantDB1 := serverutils.StartTenant(t, s, base.TestTenantArgs{TenantID: tenantID})
tenant1.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
defer tenant1.Stopper().Stop(ctx)
defer tenantDB1.Close()

// Start second SQL pod.
params2 := tests.CreateTestTenantParams(tenantID)
params2.DisableCreateTenant = true
tenant2, tenantDB2 := serverutils.StartTenant(t, s, params2)
tenant2, tenantDB2 := serverutils.StartTenant(t, s, base.TestTenantArgs{
TenantID: tenantID,
DisableCreateTenant: true,
})
tenant2.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
defer tenant2.Stopper().Stop(ctx)
defer tenantDB2.Close()
Expand Down Expand Up @@ -2984,10 +2984,11 @@ func startTestTenantPodsWithStopper(

var tenants []serverutils.ApplicationLayerInterface
for i := 0; i < count; i++ {
params := tests.CreateTestTenantParams(tenantID)
params.TestingKnobs = knobs
params.Stopper = stopper
tenant, tenantDB := serverutils.StartTenant(t, ts, params)
tenant, tenantDB := serverutils.StartTenant(t, ts, base.TestTenantArgs{
TenantID: tenantID,
TestingKnobs: knobs,
Stopper: stopper,
})
tenant.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)

// Create a test user. We only need to do it once.
Expand Down
5 changes: 3 additions & 2 deletions pkg/ccl/testccl/sqlccl/gc_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/sql/sqltestutils"
"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"
Expand All @@ -36,7 +35,9 @@ func TestGCJobGetsMarkedIdle(t *testing.T) {
})
sqltestutils.SetShortRangeFeedIntervals(t, mainDB)
defer s.Stopper().Stop(ctx)
tenant, tenantDB := serverutils.StartTenant(t, s, tests.CreateTestTenantParams(serverutils.TestTenantID()))
tenant, tenantDB := serverutils.StartTenant(t, s, base.TestTenantArgs{
TenantID: serverutils.TestTenantID(),
})
defer tenant.Stopper().Stop(ctx)
defer tenantDB.Close()

Expand Down
5 changes: 3 additions & 2 deletions pkg/ccl/testccl/sqlccl/session_revival_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
Expand All @@ -40,7 +39,9 @@ func TestAuthenticateWithSessionRevivalToken(t *testing.T) {
})
defer s.Stopper().Stop(ctx)
defer mainDB.Close()
tenant, tenantDB := serverutils.StartTenant(t, s, tests.CreateTestTenantParams(serverutils.TestTenantID()))
tenant, tenantDB := serverutils.StartTenant(t, s, base.TestTenantArgs{
TenantID: serverutils.TestTenantID(),
})
defer tenant.Stopper().Stop(ctx)
defer tenantDB.Close()

Expand Down
5 changes: 3 additions & 2 deletions pkg/ccl/testccl/sqlccl/show_transfer_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/cockroachdb/cockroach-go/v2/crdb"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
Expand All @@ -32,7 +31,9 @@ func TestShowTransferState(t *testing.T) {
DefaultTestTenant: base.TestControlsTenantsExplicitly,
})
defer s.Stopper().Stop(ctx)
tenant, tenantDB := serverutils.StartTenant(t, s, tests.CreateTestTenantParams(serverutils.TestTenantID()))
tenant, tenantDB := serverutils.StartTenant(t, s, base.TestTenantArgs{
TenantID: serverutils.TestTenantID(),
})
defer tenant.Stopper().Stop(ctx)

_, err := tenantDB.Exec("CREATE USER testuser WITH PASSWORD 'hunter2'")
Expand Down
4 changes: 1 addition & 3 deletions pkg/cli/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ func newCLITestWithArgs(params TestCLIParams, argsFn func(args *base.TestServerA
Locality: params.Locality,
ExternalIODir: filepath.Join(certsDir, "extern"),
Knobs: base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
},
SQLStatsKnobs: sqlstats.CreateTestingKnobs(),
},
}
if argsFn != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ go_test(
"//pkg/sql/sessiondata",
"//pkg/sql/sqlstats",
"//pkg/sql/sqlstats/persistedsqlstats",
"//pkg/sql/tests",
"//pkg/storage",
"//pkg/testutils",
"//pkg/testutils/datapathutils",
Expand Down
1 change: 0 additions & 1 deletion pkg/server/application_api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ go_test(
"//pkg/sql/sem/tree",
"//pkg/sql/sessiondata",
"//pkg/sql/sqlstats",
"//pkg/sql/tests",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
Expand Down
6 changes: 1 addition & 5 deletions pkg/server/application_api/contention_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/clusterunique"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"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"
Expand All @@ -42,11 +41,8 @@ func TestStatusAPIContentionEvents(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

params, _ := tests.CreateTestServerParams()
ctx := context.Background()
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: params,
})
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{})

defer testCluster.Stopper().Stop(ctx)

Expand Down
11 changes: 2 additions & 9 deletions pkg/server/application_api/sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/server/apiconstants"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/server/srvtestutils"
"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/skip"
Expand Down Expand Up @@ -133,11 +132,8 @@ func TestStatusAPIListSessions(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

params, _ := tests.CreateTestServerParams()
ctx := context.Background()
testCluster := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{
ServerArgs: params,
})
testCluster := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{})
defer testCluster.Stopper().Stop(ctx)

serverProto := testCluster.Server(0)
Expand Down Expand Up @@ -200,10 +196,7 @@ func TestListClosedSessions(t *testing.T) {
skip.UnderStressRace(t, "active sessions")

ctx := context.Background()
serverParams, _ := tests.CreateTestServerParams()
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: serverParams,
})
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{})
defer testCluster.Stopper().Stop(ctx)

server := testCluster.Server(0)
Expand Down
29 changes: 11 additions & 18 deletions pkg/server/application_api/sql_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/sql/sqlstats"
"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/skip"
Expand All @@ -49,7 +48,7 @@ func TestStatusAPICombinedTransactions(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

params, _ := tests.CreateTestServerParams()
var params base.TestServerArgs
params.Knobs.SpanConfig = &spanconfig.TestingKnobs{ManagerDisableJobCreation: true} // TODO(irfansharif): #74919.
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: params,
Expand Down Expand Up @@ -323,10 +322,7 @@ func TestStatusAPITransactionStatementFingerprintIDsTruncation(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

params, _ := tests.CreateTestServerParams()
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: params,
})
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{})
defer testCluster.Stopper().Stop(context.Background())

firstServerProto := testCluster.Server(0)
Expand Down Expand Up @@ -386,13 +382,12 @@ func TestStatusAPIStatements(t *testing.T) {

// Aug 30 2021 19:50:00 GMT+0000
aggregatedTs := int64(1630353000)
statsKnobs := sqlstats.CreateTestingKnobs()
statsKnobs.StubTimeNow = func() time.Time { return timeutil.Unix(aggregatedTs, 0) }
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
StubTimeNow: func() time.Time { return timeutil.Unix(aggregatedTs, 0) },
},
SQLStatsKnobs: statsKnobs,
SpanConfig: &spanconfig.TestingKnobs{
ManagerDisableJobCreation: true, // TODO(irfansharif): #74919.
},
Expand Down Expand Up @@ -498,13 +493,12 @@ func TestStatusAPICombinedStatements(t *testing.T) {

// Aug 30 2021 19:50:00 GMT+0000
aggregatedTs := int64(1630353000)
statsKnobs := sqlstats.CreateTestingKnobs()
statsKnobs.StubTimeNow = func() time.Time { return timeutil.Unix(aggregatedTs, 0) }
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
StubTimeNow: func() time.Time { return timeutil.Unix(aggregatedTs, 0) },
},
SQLStatsKnobs: statsKnobs,
SpanConfig: &spanconfig.TestingKnobs{
ManagerDisableJobCreation: true, // TODO(irfansharif): #74919.
},
Expand Down Expand Up @@ -669,13 +663,12 @@ func TestStatusAPIStatementDetails(t *testing.T) {

// Aug 30 2021 19:50:00 GMT+0000
aggregatedTs := int64(1630353000)
statsKnobs := sqlstats.CreateTestingKnobs()
statsKnobs.StubTimeNow = func() time.Time { return timeutil.Unix(aggregatedTs, 0) }
testCluster := serverutils.StartNewTestCluster(t, 3, base.TestClusterArgs{
ServerArgs: base.TestServerArgs{
Knobs: base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
StubTimeNow: func() time.Time { return timeutil.Unix(aggregatedTs, 0) },
},
SQLStatsKnobs: statsKnobs,
SpanConfig: &spanconfig.TestingKnobs{
ManagerDisableJobCreation: true,
},
Expand Down
8 changes: 3 additions & 5 deletions pkg/server/statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"context"
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand All @@ -31,8 +31,7 @@ func TestStatements(t *testing.T) {

ctx := context.Background()

params, _ := tests.CreateTestServerParams()
testServer, db, _ := serverutils.StartServer(t, params)
testServer, db, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer testServer.Stopper().Stop(ctx)

client := testServer.GetStatusClient(t)
Expand All @@ -59,8 +58,7 @@ func TestStatementsExcludeStats(t *testing.T) {

ctx := context.Background()

params, _ := tests.CreateTestServerParams()
testServer, db, _ := serverutils.StartServer(t, params)
testServer, db, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer testServer.Stopper().Stop(ctx)

client := testServer.GetStatusClient(t)
Expand Down
6 changes: 1 addition & 5 deletions pkg/server/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ func TestTelemetrySQLStatsIndependence(t *testing.T) {

ctx := context.Background()
var params base.TestServerArgs
params.Knobs = base.TestingKnobs{
SQLStatsKnobs: &sqlstats.TestingKnobs{
AOSTClause: "AS OF SYSTEM TIME '-1us'",
},
}
params.Knobs.SQLStatsKnobs = sqlstats.CreateTestingKnobs()

r := diagutils.NewServer()
defer r.Close()
Expand Down
3 changes: 2 additions & 1 deletion pkg/server/tracedumper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ go_test(
args = ["-test.timeout=295s"],
embed = [":tracedumper"],
deps = [
"//pkg/base",
"//pkg/ccl",
"//pkg/security/securityassets",
"//pkg/security/securitytest",
"//pkg/server",
"//pkg/server/dumpstore",
"//pkg/sql/isql",
"//pkg/sql/tests",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/testcluster",
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/tracedumper/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
Loading