diff --git a/dev b/dev index dab753348452..6da7a15bf111 100755 --- a/dev +++ b/dev @@ -8,7 +8,7 @@ fi set -euo pipefail # Bump this counter to force rebuilding `dev` on all machines. -DEV_VERSION=82 +DEV_VERSION=83 THIS_DIR=$(cd "$(dirname "$0")" && pwd) BINARY_DIR=$THIS_DIR/bin/dev-versions diff --git a/pkg/ccl/changefeedccl/changefeed_test.go b/pkg/ccl/changefeedccl/changefeed_test.go index cd235a0ee31f..759c559353b4 100644 --- a/pkg/ccl/changefeedccl/changefeed_test.go +++ b/pkg/ccl/changefeedccl/changefeed_test.go @@ -7342,6 +7342,25 @@ func (s *memoryHoggingSink) Close() error { return nil } +type countEmittedRowsSink struct { + memoryHoggingSink + numRows int64 // Accessed atomically; not using atomic.Int64 to make backports possible. +} + +func (s *countEmittedRowsSink) EmitRow( + ctx context.Context, + topic TopicDescriptor, + key, value []byte, + updated, mvcc hlc.Timestamp, + alloc kvevent.Alloc, +) error { + alloc.Release(ctx) + atomic.AddInt64(&s.numRows, 1) + return nil +} + +var _ Sink = (*countEmittedRowsSink)(nil) + func TestChangefeedFlushesSinkToReleaseMemory(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) @@ -7392,6 +7411,54 @@ func TestChangefeedFlushesSinkToReleaseMemory(t *testing.T) { require.Greater(t, sink.numFlushes(), 0) } +// Test verifies that KV feed does not leak event memory allocation +// when it reaches end_time or scan boundary. +func TestKVFeedDoesNotLeakMemoryWhenSkippingEvents(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + + s, stopServer := makeServer(t) + defer stopServer() + + sqlDB := sqlutils.MakeSQLRunner(s.DB) + knobs := s.TestingKnobs. + DistSQL.(*execinfra.TestingKnobs). + Changefeed.(*TestingKnobs) + + // Arrange for a small memory budget. + knobs.MemMonitor = startMonitorWithBudget(4096) + + // Arrange for custom sink to be used -- a sink that counts emitted rows. + sink := &countEmittedRowsSink{} + knobs.WrapSink = func(_ Sink, _ jobspb.JobID) Sink { + return sink + } + sqlDB.Exec(t, `CREATE TABLE foo(key INT PRIMARY KEY DEFAULT unique_rowid(), val INT)`) + + startTime := s.Server.Clock().Now().AsOfSystemTime() + + // Insert 123 rows -- this fills up our tiny memory buffer (~26 rows do) + // Collect statement timestamp -- this will become our end time. + var insertTimeStr string + sqlDB.QueryRow(t, + `INSERT INTO foo (val) SELECT * FROM generate_series(1, 123) RETURNING cluster_logical_timestamp();`, + ).Scan(&insertTimeStr) + endTime := parseTimeToHLC(t, insertTimeStr).AsOfSystemTime() + + // Start the changefeed, with end_time set to be equal to the insert time. + // KVFeed should ignore all events. + var jobID jobspb.JobID + sqlDB.QueryRow(t, `CREATE CHANGEFEED FOR foo INTO 'null:' WITH cursor = $1, end_time = $2`, + startTime, endTime).Scan(&jobID) + + // If everything is fine (events are ignored, but their memory allocation is released), + // the changefeed should terminate. If not, we'll time out waiting for job. + waitForJobStatus(sqlDB, t, jobID, jobs.StatusSucceeded) + + // No rows should have been emitted (all should have been filtered out due to end_time). + require.EqualValues(t, 0, atomic.LoadInt64(&sink.numRows)) +} + func TestChangefeedMultiPodTenantPlanning(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) diff --git a/pkg/ccl/changefeedccl/kvfeed/kv_feed.go b/pkg/ccl/changefeedccl/kvfeed/kv_feed.go index f41c3565d59c..18f99e47567b 100644 --- a/pkg/ccl/changefeedccl/kvfeed/kv_feed.go +++ b/pkg/ccl/changefeedccl/kvfeed/kv_feed.go @@ -584,6 +584,7 @@ func copyFromSourceToDestUntilTableEvent( ) error { var ( scanBoundary errBoundaryReached + endTimeIsSet = !endTime.IsEmpty() // checkForScanBoundary takes in a new event's timestamp (event generated // from rangefeed), and asks "Is some type of 'boundary' reached @@ -595,7 +596,11 @@ func copyFromSourceToDestUntilTableEvent( // If the scanBoundary is not nil, it either means that there is a table // event boundary set or a boundary for the end time. If the boundary is // for the end time, we should keep looking for table events. - _, isEndTimeBoundary := scanBoundary.(*errEndTimeReached) + isEndTimeBoundary := false + if endTimeIsSet { + _, isEndTimeBoundary = scanBoundary.(*errEndTimeReached) + } + if scanBoundary != nil && !isEndTimeBoundary { return nil } @@ -610,7 +615,7 @@ func copyFromSourceToDestUntilTableEvent( // precedence to table events. if len(nextEvents) > 0 { scanBoundary = &errTableEventReached{nextEvents[0]} - } else if !endTime.IsEmpty() && scanBoundary == nil { + } else if endTimeIsSet && scanBoundary == nil { scanBoundary = &errEndTimeReached{ endTime: endTime, } @@ -691,6 +696,17 @@ func copyFromSourceToDestUntilTableEvent( if err != nil { return err } + + if skipEntry || scanBoundaryReached { + // We will skip this entry or outright terminate kvfeed (if boundary reached). + // Regardless of the reason, we must release this event memory allocation + // since other ranges might not have reached scan boundary yet. + // Failure to release this event allocation may prevent other events from being + // enqueued in the blocking buffer due to memory limit. + a := e.DetachAlloc() + a.Release(ctx) + } + if scanBoundaryReached { // All component rangefeeds are now at the boundary. // Break out of the ctxgroup by returning the sentinel error. @@ -702,7 +718,6 @@ func copyFromSourceToDestUntilTableEvent( return addEntry(e) } ) - for { e, err := source.Get(ctx) if err != nil { diff --git a/pkg/ccl/serverccl/BUILD.bazel b/pkg/ccl/serverccl/BUILD.bazel index 4f0c22f944a5..ac9b87428c2b 100644 --- a/pkg/ccl/serverccl/BUILD.bazel +++ b/pkg/ccl/serverccl/BUILD.bazel @@ -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", diff --git a/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go b/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go index f3d517c28b90..a2f3ccdb503d 100644 --- a/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go +++ b/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go @@ -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, diff --git a/pkg/ccl/serverccl/statusccl/tenant_status_test.go b/pkg/ccl/serverccl/statusccl/tenant_status_test.go index ec84ba484378..b66f92401d30 100644 --- a/pkg/ccl/serverccl/statusccl/tenant_status_test.go +++ b/pkg/ccl/serverccl/statusccl/tenant_status_test.go @@ -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(), }, }) diff --git a/pkg/ccl/serverccl/tenant_test_utils.go b/pkg/ccl/serverccl/tenant_test_utils.go index 053e0d761846..26ce31a12633 100644 --- a/pkg/ccl/serverccl/tenant_test_utils.go +++ b/pkg/ccl/serverccl/tenant_test_utils.go @@ -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" @@ -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 diff --git a/pkg/ccl/sqlproxyccl/BUILD.bazel b/pkg/ccl/sqlproxyccl/BUILD.bazel index a8a6cec2b1d1..706babd0291c 100644 --- a/pkg/ccl/sqlproxyccl/BUILD.bazel +++ b/pkg/ccl/sqlproxyccl/BUILD.bazel @@ -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", diff --git a/pkg/ccl/sqlproxyccl/proxy_handler_test.go b/pkg/ccl/sqlproxyccl/proxy_handler_test.go index d4b8ad0f561e..6e01e39e58bd 100644 --- a/pkg/ccl/sqlproxyccl/proxy_handler_test.go +++ b/pkg/ccl/sqlproxyccl/proxy_handler_test.go @@ -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" @@ -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() @@ -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. diff --git a/pkg/ccl/testccl/sqlccl/gc_job_test.go b/pkg/ccl/testccl/sqlccl/gc_job_test.go index c25211531e9c..85ead4c09f2a 100644 --- a/pkg/ccl/testccl/sqlccl/gc_job_test.go +++ b/pkg/ccl/testccl/sqlccl/gc_job_test.go @@ -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" @@ -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() diff --git a/pkg/ccl/testccl/sqlccl/session_revival_test.go b/pkg/ccl/testccl/sqlccl/session_revival_test.go index 955263138fb7..0d1580e84bb6 100644 --- a/pkg/ccl/testccl/sqlccl/session_revival_test.go +++ b/pkg/ccl/testccl/sqlccl/session_revival_test.go @@ -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" @@ -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() diff --git a/pkg/ccl/testccl/sqlccl/show_transfer_state_test.go b/pkg/ccl/testccl/sqlccl/show_transfer_state_test.go index a11f84bc7d99..db5eaa04ae8a 100644 --- a/pkg/ccl/testccl/sqlccl/show_transfer_state_test.go +++ b/pkg/ccl/testccl/sqlccl/show_transfer_state_test.go @@ -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" @@ -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'") diff --git a/pkg/cli/testutils.go b/pkg/cli/testutils.go index 3c15b572dc91..2311b5d21f87 100644 --- a/pkg/cli/testutils.go +++ b/pkg/cli/testutils.go @@ -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 { diff --git a/pkg/cmd/bazci/githubpost/githubpost.go b/pkg/cmd/bazci/githubpost/githubpost.go index f431ff2e93c4..30dba004d3d3 100644 --- a/pkg/cmd/bazci/githubpost/githubpost.go +++ b/pkg/cmd/bazci/githubpost/githubpost.go @@ -62,7 +62,7 @@ type formatter func(context.Context, failure) (issues.IssueFormatter, issues.Pos func defaultFormatter(ctx context.Context, f failure) (issues.IssueFormatter, issues.PostRequest) { teams := getOwner(ctx, f.packageName, f.testName) - repro := fmt.Sprintf("./dev test ./pkg/%s --race --count 250 -f %s", + repro := fmt.Sprintf("./dev test ./pkg/%s --race --stress -f %s", trimPkg(f.packageName), f.testName) var projColID int diff --git a/pkg/cmd/dev/bench.go b/pkg/cmd/dev/bench.go index 73e9dc952444..ad103ff700e6 100644 --- a/pkg/cmd/dev/bench.go +++ b/pkg/cmd/dev/bench.go @@ -163,7 +163,7 @@ func (d *dev) bench(cmd *cobra.Command, commandLine []string) error { args = append(args, goTestArgs...) } args = append(args, d.getGoTestEnvArgs()...) - args = append(args, d.getTestOutputArgs(false /* stress */, verbose, showLogs, streamOutput)...) + args = append(args, d.getTestOutputArgs(verbose, showLogs, streamOutput)...) args = append(args, additionalBazelArgs...) logCommand("bazel", args...) return d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...) diff --git a/pkg/cmd/dev/build.go b/pkg/cmd/dev/build.go index 31fbd4f24225..3096bc91a7d9 100644 --- a/pkg/cmd/dev/build.go +++ b/pkg/cmd/dev/build.go @@ -108,7 +108,6 @@ var buildTargetMapping = map[string]string{ "smithcmp": "//pkg/cmd/smithcmp:smithcmp", "smithtest": "//pkg/cmd/smithtest:smithtest", "staticcheck": "@co_honnef_go_tools//cmd/staticcheck:staticcheck", - "stress": stressTarget, "swagger": "@com_github_go_swagger_go_swagger//cmd/swagger:swagger", "tests": "//pkg:all_tests", "workload": "//pkg/cmd/workload:workload", diff --git a/pkg/cmd/dev/compose.go b/pkg/cmd/dev/compose.go index 44fdf0592892..4c5e9e3d7d4d 100644 --- a/pkg/cmd/dev/compose.go +++ b/pkg/cmd/dev/compose.go @@ -78,6 +78,7 @@ func (d *dev) compose(cmd *cobra.Command, _ []string) error { args = append(args, "--test_arg", "-cockroach", "--test_arg", cockroachBin) args = append(args, "--test_arg", "-compare", "--test_arg", compareBin) + args = append(args, "--test_env", "COCKROACH_DEV_LICENSE") logCommand("bazel", args...) return d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...) diff --git a/pkg/cmd/dev/roachprod_stress.go b/pkg/cmd/dev/roachprod_stress.go index febf81414062..f7f5e18f3be9 100644 --- a/pkg/cmd/dev/roachprod_stress.go +++ b/pkg/cmd/dev/roachprod_stress.go @@ -21,7 +21,9 @@ import ( ) const ( - clusterFlag = "cluster" + clusterFlag = "cluster" + stressArgsFlag = "stress-args" + stressTarget = "@com_github_cockroachdb_stress//:stress" ) func makeRoachprodStressCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Command { diff --git a/pkg/cmd/dev/test.go b/pkg/cmd/dev/test.go index d284492227f2..e0d34a17af37 100644 --- a/pkg/cmd/dev/test.go +++ b/pkg/cmd/dev/test.go @@ -19,7 +19,6 @@ import ( "os/exec" "path/filepath" "strings" - "time" "github.com/cockroachdb/cockroach/pkg/util/buildutil" "github.com/google/shlex" @@ -27,15 +26,12 @@ import ( ) const ( - stressTarget = "@com_github_cockroachdb_stress//:stress" - // General testing flags. changedFlag = "changed" countFlag = "count" vFlag = "verbose" showLogsFlag = "show-logs" stressFlag = "stress" - stressArgsFlag = "stress-args" raceFlag = "race" deadlockFlag = "deadlock" ignoreCacheFlag = "ignore-cache" @@ -66,17 +62,30 @@ pkg/kv/kvserver:kvserver_test) instead.`, dev test pkg/spanconfig/... pkg/ccl/spanconfigccl/... Test multiple packages recursively - dev test --stress --timeout=1m --test-args='-test.timeout 5s' - Stress for 1m until a test runs longer than 5s - dev test --race --count 250 ... Run a test under race, 250 times in parallel dev test pkg/spanconfig/... --test-args '-test.trace=trace.out' Pass arguments to go test (see 'go help testflag'; prefix args with '-test.{arg}') - dev test pkg/spanconfig --stress --stress-args '-maxruns 1000 -p 4' --timeout=10m - Pass arguments to github.com/cockroachdb/stress, run for 10 min + dev test pkg/spanconfig --stress + Run pkg/spanconfig test repeatedly in parallel up to 1000 times until it fails + + dev test pkg/spanconfig --stress --count 2000 + Same as above, but run 2000 times instead of 1000 + + timeout 60 dev test pkg/spanconfig --stress --count 2000 + Same as above, but time out after 60 seconds if no test has failed + (Note: the timeout command is called "gtimeout" on macOS and can be installed with "brew install coreutils") + + dev test pkg/cmd/dev:dev_test --stress --test-args='-test.timeout 5s' + Run a test repeatedly until it runs longer than 5s + + end=$((SECONDS+N)) + while [ $SECONDS -lt $end ]; do + dev test pkg/cmd/dev:dev_test --stress + done + Run a test repeatedly until at least N seconds have passed (useful if "dev test --stress" ends too quickly and you want to keep the test running for a while) dev test pkg/server -f=TestSpanStatsResponse -v --count=5 --vmodule='raft=1' `, @@ -100,7 +109,6 @@ pkg/kv/kvserver:kvserver_test) instead.`, testCmd.Flags().Int(countFlag, 1, "run test the given number of times") testCmd.Flags().BoolP(showLogsFlag, "", false, "show crdb logs in-line") testCmd.Flags().Bool(stressFlag, false, "run tests under stress") - testCmd.Flags().String(stressArgsFlag, "", "additional arguments to pass to stress") testCmd.Flags().Bool(raceFlag, false, "run tests using race builds") testCmd.Flags().Bool(deadlockFlag, false, "run tests using the deadlock detector") testCmd.Flags().Bool(ignoreCacheFlag, false, "ignore cached test runs") @@ -136,23 +144,22 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { pkgs, additionalBazelArgs := splitArgsAtDash(cmd, commandLine) ctx := cmd.Context() var ( - filter = mustGetFlagString(cmd, filterFlag) - ignoreCache = mustGetFlagBool(cmd, ignoreCacheFlag) - race = mustGetFlagBool(cmd, raceFlag) - deadlock = mustGetFlagBool(cmd, deadlockFlag) - rewrite = mustGetFlagBool(cmd, rewriteFlag) - streamOutput = mustGetFlagBool(cmd, streamOutputFlag) - testArgs = mustGetFlagString(cmd, testArgsFlag) - short = mustGetFlagBool(cmd, shortFlag) - stress = mustGetFlagBool(cmd, stressFlag) - stressCmdArgs = mustGetFlagString(cmd, stressArgsFlag) - timeout = mustGetFlagDuration(cmd, timeoutFlag) - verbose = mustGetFlagBool(cmd, vFlag) - changed = mustGetFlagBool(cmd, changedFlag) - showLogs = mustGetFlagBool(cmd, showLogsFlag) - count = mustGetFlagInt(cmd, countFlag) - vModule = mustGetFlagString(cmd, vModuleFlag) - showDiff = mustGetFlagBool(cmd, showDiffFlag) + filter = mustGetFlagString(cmd, filterFlag) + ignoreCache = mustGetFlagBool(cmd, ignoreCacheFlag) + race = mustGetFlagBool(cmd, raceFlag) + deadlock = mustGetFlagBool(cmd, deadlockFlag) + rewrite = mustGetFlagBool(cmd, rewriteFlag) + streamOutput = mustGetFlagBool(cmd, streamOutputFlag) + testArgs = mustGetFlagString(cmd, testArgsFlag) + short = mustGetFlagBool(cmd, shortFlag) + stress = mustGetFlagBool(cmd, stressFlag) + timeout = mustGetFlagDuration(cmd, timeoutFlag) + verbose = mustGetFlagBool(cmd, vFlag) + changed = mustGetFlagBool(cmd, changedFlag) + showLogs = mustGetFlagBool(cmd, showLogsFlag) + count = mustGetFlagInt(cmd, countFlag) + vModule = mustGetFlagString(cmd, vModuleFlag) + showDiff = mustGetFlagBool(cmd, showDiffFlag) // These are tests that require access to another directory for // --rewrite. These can either be single directories or @@ -210,8 +217,6 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { } if race { args = append(args, "--config=race") - } else if stress { - disableTestSharding = true } if deadlock { goTags = append(goTags, "deadlock") @@ -244,22 +249,6 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { testTargets = append(testTargets, target) } - // Stressing is specifically for go tests. Take a second here to filter - // only the go_test targets so we don't end up stressing e.g. a - // disallowed_imports_test. - if stress { - query := fmt.Sprintf("kind('go_test', %s)", strings.Join(testTargets, " + ")) - goTestLines, err := d.exec.CommandContextSilent(ctx, "bazel", "query", "--output=label", query) - if err != nil { - return err - } - testTargets = strings.Split(strings.TrimSpace(string(goTestLines)), "\n") - if len(testTargets) == 0 { - log.Printf("WARNING: no tests found") - return nil - } - } - args = append(args, testTargets...) if ignoreCache { args = append(args, "--nocache_test_results") @@ -303,9 +292,7 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { if showDiff { args = append(args, "--test_arg", "-show-diff") } - if timeout > 0 && !stress { - // If stress is specified, we'll pad the timeout differently below. - + if timeout > 0 { // The bazel timeout should be higher than the timeout passed to the // test binary (giving it ample time to clean up, 5 seconds is probably // enough). @@ -318,7 +305,14 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { } if stress { - args = append(args, d.getStressArgs(stressCmdArgs, timeout)...) + if count == 1 { + // Default to 1000 unless a different count was provided. + count = 1000 + } + args = append(args, + "--test_env=COCKROACH_STRESS=true", + "--notest_keep_going", + ) } if filter != "" { @@ -357,9 +351,12 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { if len(goTags) > 0 { args = append(args, "--define", "gotags=bazel,gss,"+strings.Join(goTags, ",")) } - args = append(args, d.getTestOutputArgs(stress, verbose, showLogs, streamOutput)...) + args = append(args, d.getTestOutputArgs(verbose, showLogs, streamOutput)...) args = append(args, additionalBazelArgs...) logCommand("bazel", args...) + if stress { + d.warnAboutChangeInStressBehavior(timeout) + } // Do not log --build_event_binary_file=... because it is not relevant to the actual call // from the user perspective. @@ -376,9 +373,10 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { // If the exit code is 4, the build was successful but no tests were found. // ref: https://docs.bazel.build/versions/0.21.0/guide.html#what-exit-code-will-i-get log.Printf("WARNING: the build succeeded but no tests were found.") - return nil + err = nil } } + return err // TODO(irfansharif): Both here and in `dev bench`, if the command is @@ -420,9 +418,9 @@ func (d *dev) getGoTestArgs(ctx context.Context, testArgs string) ([]string, err return goTestArgs, nil } -func (d *dev) getTestOutputArgs(stress, verbose, showLogs, streamOutput bool) []string { +func (d *dev) getTestOutputArgs(verbose, showLogs, streamOutput bool) []string { testOutputArgs := []string{"--test_output", "errors"} - if stress || streamOutput { + if streamOutput { // Stream the output to continually observe the number of successful // test iterations. testOutputArgs = []string{"--test_output", "streamed"} @@ -432,38 +430,6 @@ func (d *dev) getTestOutputArgs(stress, verbose, showLogs, streamOutput bool) [] return testOutputArgs } -func (d *dev) getStressArgs(stressCmdArg string, timeout time.Duration) []string { - var stressArgs, stressCmdArgs []string - if timeout > 0 { - stressCmdArgs = append(stressCmdArgs, fmt.Sprintf("-maxtime=%s", timeout)) - // The bazel timeout should be higher than the stress duration, lets - // generously give it an extra minute. - stressArgs = append(stressArgs, fmt.Sprintf("--test_timeout=%d", int((timeout+time.Minute).Seconds()))) - } else { - // We're running under stress and no timeout is specified. We want - // to respect the timeout passed down to stress[1]. Similar to above - // we want the bazel timeout to be longer, so lets just set it to - // 24h. - // - // [1]: Through --stress-arg=-maxtime or if nothing is specified, - // -maxtime=0 is taken as "run forever". - stressArgs = append(stressArgs, fmt.Sprintf("--test_timeout=%.0f", 24*time.Hour.Seconds())) - } - if numCPUs > 0 { - stressCmdArgs = append(stressCmdArgs, fmt.Sprintf("-p=%d", numCPUs)) - } - if stressCmdArg != "" { - stressCmdArgs = append(stressCmdArgs, stressCmdArg) - } - stressArgs = append(stressArgs, "--test_env=COCKROACH_STRESS=true") - stressArgs = append(stressArgs, "--run_under", - // NB: Run with -bazel, which propagates `TEST_TMPDIR` to `TMPDIR`, - // and -shardable-artifacts set such that we can merge the XML output - // files. - fmt.Sprintf("%s -bazel -shardable-artifacts 'XML_OUTPUT_FILE=%s merge-test-xmls' %s", stressTarget, d.getDevBin(), strings.Join(stressCmdArgs, " "))) - return stressArgs -} - func getDirectoryFromTarget(target string) string { target = strings.TrimPrefix(target, "//") if strings.HasSuffix(target, "/...") { diff --git a/pkg/cmd/dev/testdata/datadriven/dev-build b/pkg/cmd/dev/testdata/datadriven/dev-build index 1b849a275557..98b9e67871ec 100644 --- a/pkg/cmd/dev/testdata/datadriven/dev-build +++ b/pkg/cmd/dev/testdata/datadriven/dev-build @@ -64,16 +64,6 @@ bazel info bazel-bin --color=no rm crdb-checkout/cockroach cp sandbox/pkg/cmd/cockroach/cockroach_/cockroach crdb-checkout/cockroach -exec -dev build stress ----- -bazel build @com_github_cockroachdb_stress//:stress --//build/toolchains:nogo_disable_flag --build_event_binary_file=/tmp/path -bazel info workspace --color=no -mkdir crdb-checkout/bin -bazel info bazel-bin --color=no -rm crdb-checkout/bin/stress -cp sandbox/external/com_github_cockroachdb_stress/stress_/stress crdb-checkout/bin/stress - exec dev build tests ---- diff --git a/pkg/cmd/dev/testdata/datadriven/test b/pkg/cmd/dev/testdata/datadriven/test index 1c048dddf4df..d711eb05c3ce 100644 --- a/pkg/cmd/dev/testdata/datadriven/test +++ b/pkg/cmd/dev/testdata/datadriven/test @@ -150,3 +150,15 @@ exec dev test pkg/spanconfig/spanconfigstore --timeout=40s -- --test_arg '-test.timeout=0.5s' ---- bazel test pkg/spanconfig/spanconfigstore:all --test_env=GOTRACEBACK=all --test_timeout=45 --test_arg -test.timeout=40s --test_output errors --test_arg -test.timeout=0.5s --build_event_binary_file=/tmp/path + +exec +dev test pkg/spanconfig/spanconfigstore --stress +---- +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test pkg/spanconfig/spanconfigstore:all --test_env=GOTRACEBACK=all --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=1000 --test_output errors --build_event_binary_file=/tmp/path + +exec +dev test pkg/spanconfig/spanconfigstore --stress --count 250 +---- +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test pkg/spanconfig/spanconfigstore:all --test_env=GOTRACEBACK=all --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=250 --test_output errors --build_event_binary_file=/tmp/path diff --git a/pkg/cmd/dev/testdata/datadriven/testlogic b/pkg/cmd/dev/testdata/datadriven/testlogic index 3c8e27c08221..4fa277eea3c9 100644 --- a/pkg/cmd/dev/testdata/datadriven/testlogic +++ b/pkg/cmd/dev/testdata/datadriven/testlogic @@ -44,7 +44,8 @@ dev testlogic base --files=auto_span_config_reconciliation --stress bazel info workspace --color=no bazel info workspace --color=no bazel run pkg/cmd/generate-logictest -- -out-dir=crdb-checkout -bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=86400 --test_env=COCKROACH_STRESS=true --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' ' --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=500 --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output errors exec dev testlogic base --files=auto_span_config_reconciliation --stress --timeout 1m --cpus 8 @@ -52,7 +53,8 @@ dev testlogic base --files=auto_span_config_reconciliation --stress --timeout 1m bazel info workspace --color=no bazel info workspace --color=no bazel run pkg/cmd/generate-logictest -- -out-dir=crdb-checkout -bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --local_cpu_resources=8 --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=120 --test_env=COCKROACH_STRESS=true --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' -maxtime=1m0s -p=8' --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --local_cpu_resources=8 --test_arg -show-sql --test_timeout=65 --test_arg -test.timeout=1m0s --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=500 --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output errors exec dev testlogic base --files=auto_span_config_reconciliation --stress --stream-output @@ -60,7 +62,8 @@ dev testlogic base --files=auto_span_config_reconciliation --stress --stream-out bazel info workspace --color=no bazel info workspace --color=no bazel run pkg/cmd/generate-logictest -- -out-dir=crdb-checkout -bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=86400 --test_env=COCKROACH_STRESS=true --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' ' --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=500 --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed exec dev testlogic base --files=auto_span_config_reconciliation --stress --stream-output @@ -68,7 +71,8 @@ dev testlogic base --files=auto_span_config_reconciliation --stress --stream-out bazel info workspace --color=no bazel info workspace --color=no bazel run pkg/cmd/generate-logictest -- -out-dir=crdb-checkout -bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=86400 --test_env=COCKROACH_STRESS=true --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' ' --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=500 --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed exec dev testlogic base --files=auto_span_config_reconciliation --stress --stream-output @@ -76,4 +80,5 @@ dev testlogic base --files=auto_span_config_reconciliation --stress --stream-out bazel info workspace --color=no bazel info workspace --color=no bazel run pkg/cmd/generate-logictest -- -out-dir=crdb-checkout -bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=86400 --test_env=COCKROACH_STRESS=true --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' ' --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed +getenv DEV_I_UNDERSTAND_ABOUT_STRESS +bazel test //pkg/sql/logictest/tests/... --test_env=GOTRACEBACK=all --test_arg -show-sql --test_env=COCKROACH_STRESS=true --notest_keep_going --runs_per_test=500 --test_filter auto_span_config_reconciliation/ --test_sharding_strategy=disabled --test_output streamed diff --git a/pkg/cmd/dev/testlogic.go b/pkg/cmd/dev/testlogic.go index bed296d261b2..c7dfcf02b11a 100644 --- a/pkg/cmd/dev/testlogic.go +++ b/pkg/cmd/dev/testlogic.go @@ -60,7 +60,6 @@ func makeTestLogicCmd(runE func(cmd *cobra.Command, args []string) error) *cobra testLogicCmd.Flags().Bool(noGenFlag, false, "skip generating logic test files before running logic tests") testLogicCmd.Flags().Bool(streamOutputFlag, false, "stream test output during run") testLogicCmd.Flags().Bool(stressFlag, false, "run tests under stress") - testLogicCmd.Flags().String(stressArgsFlag, "", "additional arguments to pass to stress") testLogicCmd.Flags().String(testArgsFlag, "", "additional arguments to pass to go test binary") testLogicCmd.Flags().Bool(showDiffFlag, false, "generate a diff for expectation mismatches when possible") testLogicCmd.Flags().Bool(flexTypesFlag, false, "tolerate when a result column is produced with a different numeric type") @@ -89,7 +88,6 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error { showSQL = mustGetFlagBool(cmd, showSQLFlag) count = mustGetFlagInt(cmd, countFlag) stress = mustGetFlagBool(cmd, stressFlag) - stressCmdArgs = mustGetFlagString(cmd, stressArgsFlag) testArgs = mustGetFlagString(cmd, testArgsFlag) showDiff = mustGetFlagBool(cmd, showDiffFlag) flexTypes = mustGetFlagBool(cmd, flexTypesFlag) @@ -220,9 +218,6 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error { if bigtest { args = append(args, "--test_arg", "-bigtest") } - if count != 1 { - args = append(args, "--test_arg", fmt.Sprintf("-test.count=%d", count)) - } if len(files) > 0 { args = append(args, "--test_arg", "-show-sql") } @@ -248,9 +243,7 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error { if showDiff { args = append(args, "--test_arg", "-show-diff") } - if timeout > 0 && !stress { - // If stress is specified, we'll pad the timeout differently below. - + if timeout > 0 { // The bazel timeout should be higher than the timeout passed to the // test binary (giving it ample time to clean up, 5 seconds is probably // enough). @@ -261,10 +254,20 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error { // -- --test_arg '-test.timeout=X', that'll take precedence further // below. } - if stress { - args = append(args, "--test_sharding_strategy=disabled") - args = append(args, d.getStressArgs(stressCmdArgs, timeout)...) + if count == 1 { + // Default to 500 unless a different count was provided. + // NB: Logic tests are generally big. We use 500 instead + // of 1000 (the default for `dev test`). + count = 500 + } + args = append(args, + "--test_env=COCKROACH_STRESS=true", + "--notest_keep_going", + ) + } + if count != 1 { + args = append(args, fmt.Sprintf("--runs_per_test=%d", count)) } if testArgs != "" { goTestArgs, err := d.getGoTestArgs(ctx, testArgs) @@ -279,9 +282,12 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error { args = append(args, "--test_filter", filesRegexp+"/"+subtests) args = append(args, "--test_sharding_strategy=disabled") } - args = append(args, d.getTestOutputArgs(stress, verbose, showLogs, streamOutput)...) + args = append(args, d.getTestOutputArgs(verbose, showLogs, streamOutput)...) args = append(args, additionalBazelArgs...) logCommand("bazel", args...) + if stress { + d.warnAboutChangeInStressBehavior(timeout) + } if err := d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...); err != nil { return err } diff --git a/pkg/cmd/dev/ui.go b/pkg/cmd/dev/ui.go index d8cddf496676..4649ea5ce132 100644 --- a/pkg/cmd/dev/ui.go +++ b/pkg/cmd/dev/ui.go @@ -549,7 +549,6 @@ Replaces 'make ui-lint'.`, } bazelTestArgs := d.getTestOutputArgs( - false, /* stream */ isVerbose, false, /* showLogs */ false, /* streamOutput */ @@ -806,7 +805,6 @@ Replaces 'make ui-test' and 'make ui-test-watch'.`, } } else { testOutputArg := d.getTestOutputArgs( - false, // stress isVerbose, false, // showLogs isWatch || isStreamOutput, // streamOutput diff --git a/pkg/cmd/dev/util.go b/pkg/cmd/dev/util.go index dc22087b8390..9d76e73c6232 100644 --- a/pkg/cmd/dev/util.go +++ b/pkg/cmd/dev/util.go @@ -130,14 +130,6 @@ func (d *dev) getExecutionRoot(ctx context.Context) (string, error) { return d.getBazelInfo(ctx, "execution_root", []string{}) } -// getDevBin returns the path to the running dev executable. -func (d *dev) getDevBin() string { - if d.knobs.devBinOverride != "" { - return d.knobs.devBinOverride - } - return os.Args[0] -} - // getArchivedCdepString returns a non-empty string iff the force_build_cdeps // config is not being used. This string is the name of the cross config used to // build the pre-built c-deps, minus the "cross" prefix. This can be used to @@ -247,3 +239,13 @@ func sendBepDataToBeaverHubIfNeeded(bepFilepath string) error { _ = os.Remove(bepFilepath) return nil } + +func (d *dev) warnAboutChangeInStressBehavior(timeout time.Duration) { + if e := d.os.Getenv("DEV_I_UNDERSTAND_ABOUT_STRESS"); e == "" { + log.Printf("NOTE: The behavior of `dev test --stress` has changed. The new default behavior is to run the test 1,000 times in parallel (500 for logictests), stopping if any of the tests fail. The number of runs can be tweaked with the `--count` parameter to `dev`.") + if timeout > 0 { + log.Printf("WARNING: The behavior of --timeout under --stress has changed. --timeout controls the timeout of the test, not the entire `stress` invocation.") + } + log.Printf("Set DEV_I_UNDERSTAND_ABOUT_STRESS=1 to squelch this message") + } +} diff --git a/pkg/kv/kvserver/concurrency/lock_table.go b/pkg/kv/kvserver/concurrency/lock_table.go index 4d4ee57be37a..f20ab052549d 100644 --- a/pkg/kv/kvserver/concurrency/lock_table.go +++ b/pkg/kv/kvserver/concurrency/lock_table.go @@ -764,23 +764,28 @@ func (g *lockTableGuardImpl) curStrength() lock.Strength { // request. The value returned by this method are mutable as the request's scan // of the lock table progresses from lock to lock. func (g *lockTableGuardImpl) curLockMode() lock.Mode { - switch g.curStrength() { + return makeLockMode(g.curStrength(), g.txn, g.ts) +} + +// makeLockMode constructs and returns a lock mode. +func makeLockMode(str lock.Strength, txn *roachpb.Transaction, ts hlc.Timestamp) lock.Mode { + switch str { case lock.None: iso := isolation.Serializable - if g.txn != nil { - iso = g.txn.IsoLevel + if txn != nil { + iso = txn.IsoLevel } - return lock.MakeModeNone(g.ts, iso) + return lock.MakeModeNone(ts, iso) case lock.Shared: - assert(g.txn != nil, "only transactional requests can acquire shared locks") + assert(txn != nil, "only transactional requests can acquire shared locks") return lock.MakeModeShared() case lock.Exclusive: - assert(g.txn != nil, "only transactional requests can acquire exclusive locks") - return lock.MakeModeExclusive(g.ts, g.txn.IsoLevel) + assert(txn != nil, "only transactional requests can acquire exclusive locks") + return lock.MakeModeExclusive(ts, txn.IsoLevel) case lock.Intent: - return lock.MakeModeIntent(g.ts) + return lock.MakeModeIntent(ts) default: - panic(fmt.Sprintf("unhandled request strength: %s", g.curStrength())) + panic(fmt.Sprintf("unhandled request strength: %s", str)) } } @@ -919,7 +924,8 @@ func (g *lockTableGuardImpl) resumeScan(notify bool) { // and non-transactional requests. type queuedGuard struct { guard *lockTableGuardImpl - active bool // protected by lockState.mu + mode lock.Mode // protected by lockState.mu + active bool // protected by lockState.mu } // Information about a lock holder for unreplicated locks. @@ -2201,6 +2207,7 @@ func (l *lockState) enqueueLockingRequest(g *lockTableGuardImpl) (maxQueueLength } qg := &queuedGuard{ guard: g, + mode: g.curLockMode(), active: true, } // The request isn't in the queue. Add it in the correct position, based on @@ -2281,13 +2288,7 @@ func (l *lockState) shouldRequestActivelyWait(g *lockTableGuardImpl) bool { // conflicting waiters; no need to actively wait here. return false } - // TODO(arul): Inactive waiters will need to capture the strength at which - // they're trying to acquire a lock in their queuedGuard. We can't simply - // use the guard's curStrength (or curLockMode) -- inactive waiters may have - // mutated these values as they scan. For now, we can just use the intent - // lock mode as that's the only lock strength supported by the lock table. - waiterLockMode := lock.MakeModeIntent(qqg.guard.ts) - if lock.Conflicts(waiterLockMode, g.curLockMode(), &g.lt.settings.SV) { + if lock.Conflicts(qqg.mode, g.curLockMode(), &g.lt.settings.SV) { return true } } @@ -2691,6 +2692,7 @@ func (l *lockState) discoveredLock( // Put self in queue as inactive waiter. qg := &queuedGuard{ guard: g, + mode: makeLockMode(accessStrength, g.txn, g.ts), active: false, } // g is not necessarily first in the queue in the (rare) case (a) above. diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks index bcb3cac71b3b..0369fae69042 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks @@ -722,7 +722,7 @@ num=0 # waiters. # ----------------------------------------------------------------------------- -new-request r=req11 txn=none ts=12,1 spans=exclusive@a +new-request r=req11 txn=none ts=12,1 spans=intent@a ---- scan r=req11 @@ -825,12 +825,12 @@ new-request r=req13 txn=txn6 ts=11,0 spans=exclusive@a+exclusive@b+exclusive@c+e new-request r=req14 txn=txn5 ts=11,0 spans=exclusive@a+exclusive@b ---- -# Non-locking, transactional request +# Non-locking, transactional request. new-request r=req15 txn=txn5 ts=11,0 spans=none@c+none@d ---- -# Non-locking, transactional request -new-request r=req16 txn=none ts=11,0 spans=exclusive@e+exclusive@f +# Non-transactional write request. +new-request r=req16 txn=none ts=11,0 spans=intent@e+intent@f ---- acquire r=req13 k=a durability=u strength=exclusive diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/shared_locks b/pkg/kv/kvserver/concurrency/testdata/lock_table/shared_locks index ef8d29d908d0..daeafde70dc5 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/shared_locks +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/shared_locks @@ -38,6 +38,15 @@ scan r=req3 ---- start-waiting: false +# Another shared locking request should be able to acquire a joint claim as +# well. +new-request r=req4 txn=txn2 ts=10 spans=shared@a +---- + +scan r=req4 +---- +start-waiting: false + print ---- num=1 @@ -45,6 +54,7 @@ num=1 holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] queued writers: active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 + active: false req: 3, txn: 00000000-0000-0000-0000-000000000002 # TODO(arul): This is currently a limitation of the lock table, as it doesn't # allow multiple locks on a single key from different transactions. @@ -52,17 +62,17 @@ acquire r=req3 k=a durability=u strength=shared ---- existing lock cannot be acquired by different transaction -new-request r=req4 txn=txn2 ts=10 spans=exclusive@a +new-request r=req5 txn=txn2 ts=10 spans=exclusive@a ---- -scan r=req4 +scan r=req5 ---- start-waiting: true -new-request r=req5 txn=txn2 ts=10 spans=intent@a +new-request r=req6 txn=txn2 ts=10 spans=intent@a ---- -scan r=req5 +scan r=req6 ---- start-waiting: true @@ -73,9 +83,10 @@ num=1 holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] queued writers: active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 - active: true req: 3, txn: 00000000-0000-0000-0000-000000000002 + active: false req: 3, txn: 00000000-0000-0000-0000-000000000002 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 - distinguished req: 3 + active: true req: 5, txn: 00000000-0000-0000-0000-000000000002 + distinguished req: 4 # ------------------------------------------------------------------------------ # Ensure requests with locking strength shared actively wait if there are active @@ -83,10 +94,10 @@ num=1 # compatible with the shared lock request). # ------------------------------------------------------------------------------ -new-request r=req6 txn=txn2 ts=10 spans=shared@a +new-request r=req7 txn=txn2 ts=10 spans=shared@a ---- -scan r=req6 +scan r=req7 ---- start-waiting: true @@ -97,7 +108,8 @@ num=1 holder: txn: 00000000-0000-0000-0000-000000000001 epoch: 0, iso: Serializable, ts: 10.000000000,0, info: unrepl [(str: Shared seq: 0)] queued writers: active: false req: 2, txn: 00000000-0000-0000-0000-000000000002 - active: true req: 3, txn: 00000000-0000-0000-0000-000000000002 + active: false req: 3, txn: 00000000-0000-0000-0000-000000000002 active: true req: 4, txn: 00000000-0000-0000-0000-000000000002 active: true req: 5, txn: 00000000-0000-0000-0000-000000000002 - distinguished req: 3 + active: true req: 6, txn: 00000000-0000-0000-0000-000000000002 + distinguished req: 4 diff --git a/pkg/server/BUILD.bazel b/pkg/server/BUILD.bazel index b7308338d7d6..757d8629a4d4 100644 --- a/pkg/server/BUILD.bazel +++ b/pkg/server/BUILD.bazel @@ -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", diff --git a/pkg/server/application_api/BUILD.bazel b/pkg/server/application_api/BUILD.bazel index 873a529e897f..2f419cad9265 100644 --- a/pkg/server/application_api/BUILD.bazel +++ b/pkg/server/application_api/BUILD.bazel @@ -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", diff --git a/pkg/server/application_api/contention_test.go b/pkg/server/application_api/contention_test.go index 59dc0c8038aa..953d407ef9e9 100644 --- a/pkg/server/application_api/contention_test.go +++ b/pkg/server/application_api/contention_test.go @@ -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" @@ -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) diff --git a/pkg/server/application_api/sessions_test.go b/pkg/server/application_api/sessions_test.go index 739cc8a44013..b99fd1a92dfc 100644 --- a/pkg/server/application_api/sessions_test.go +++ b/pkg/server/application_api/sessions_test.go @@ -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" @@ -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) @@ -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) diff --git a/pkg/server/application_api/sql_stats_test.go b/pkg/server/application_api/sql_stats_test.go index 74d3e8ff5c22..b4389ab44238 100644 --- a/pkg/server/application_api/sql_stats_test.go +++ b/pkg/server/application_api/sql_stats_test.go @@ -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" @@ -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, @@ -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) @@ -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. }, @@ -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. }, @@ -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, }, diff --git a/pkg/server/statements_test.go b/pkg/server/statements_test.go index 4890592d5709..ea74a091fbd9 100644 --- a/pkg/server/statements_test.go +++ b/pkg/server/statements_test.go @@ -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" @@ -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) @@ -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) diff --git a/pkg/server/stats_test.go b/pkg/server/stats_test.go index 9831b0ad7dd8..e296d9e3aaed 100644 --- a/pkg/server/stats_test.go +++ b/pkg/server/stats_test.go @@ -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() diff --git a/pkg/server/tracedumper/BUILD.bazel b/pkg/server/tracedumper/BUILD.bazel index 6faa4086b52a..fa364f5f982b 100644 --- a/pkg/server/tracedumper/BUILD.bazel +++ b/pkg/server/tracedumper/BUILD.bazel @@ -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", diff --git a/pkg/server/tracedumper/main_test.go b/pkg/server/tracedumper/main_test.go index b1c94043bd4a..2a7175d7b4cc 100644 --- a/pkg/server/tracedumper/main_test.go +++ b/pkg/server/tracedumper/main_test.go @@ -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" @@ -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()) } diff --git a/pkg/server/tracedumper/tracedumper_test.go b/pkg/server/tracedumper/tracedumper_test.go index 125c2bf53b0c..77867f4c2f6c 100644 --- a/pkg/server/tracedumper/tracedumper_test.go +++ b/pkg/server/tracedumper/tracedumper_test.go @@ -18,9 +18,9 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/server/dumpstore" "github.com/cockroachdb/cockroach/pkg/sql/isql" - "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/util/leaktest" @@ -45,8 +45,7 @@ func TestTraceDumperZipCreation(t *testing.T) { store: dumpstore.NewStore(traceDir, nil, nil), } ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s := serverutils.StartServerOnly(t, params) + s := serverutils.StartServerOnly(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) filename := "foo" diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index d6ad4bdfbb30..4092dedd4ca3 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -677,6 +677,7 @@ go_test( "schema_changer_test.go", "scrub_test.go", "sequence_test.go", + "server_params_test.go", "session_migration_test.go", "set_zone_config_test.go", "show_cluster_setting_test.go", diff --git a/pkg/sql/alter_column_type_test.go b/pkg/sql/alter_column_type_test.go index 1ed47ae88ea4..05b1c84b9015 100644 --- a/pkg/sql/alter_column_type_test.go +++ b/pkg/sql/alter_column_type_test.go @@ -22,7 +22,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" - "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" @@ -41,7 +40,7 @@ func TestInsertBeforeOldColumnIsDropped(t *testing.T) { ctx := context.Background() var s serverutils.TestServerInterface - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() childJobStartNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) var doOnce sync.Once @@ -116,7 +115,7 @@ func TestInsertBeforeOldColumnIsDroppedUsingExpr(t *testing.T) { ctx := context.Background() var s serverutils.TestServerInterface - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() childJobStartNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) var doOnce sync.Once @@ -192,7 +191,7 @@ func TestVisibilityDuringAlterColumnType(t *testing.T) { ctx := context.Background() swapNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeComputedColumnSwap: func() { @@ -284,7 +283,7 @@ func TestQueryIntToString(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Decrease the adopt loop interval so that retries happen quickly. params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() @@ -315,7 +314,7 @@ func TestSchemaChangeBeforeAlterColumnType(t *testing.T) { swapNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforePrimaryKeySwap: func() { @@ -362,7 +361,7 @@ func TestSchemaChangeWhileExecutingAlterColumnType(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() childJobStartNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) var doOnce sync.Once diff --git a/pkg/sql/as_of_test.go b/pkg/sql/as_of_test.go index 66d6eac43108..101ab6a28e91 100644 --- a/pkg/sql/as_of_test.go +++ b/pkg/sql/as_of_test.go @@ -24,7 +24,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "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" @@ -37,7 +36,7 @@ func TestAsOfTime(t *testing.T) { defer log.Scope(t).Close(t) ctx, cancel := context.WithCancel(context.Background()) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.GCJob = &sql.GCJobTestingKnobs{RunBeforeResume: func(_ jobspb.JobID) error { <-ctx.Done() return nil @@ -274,7 +273,7 @@ func TestAsOfRetry(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/catalog/descs/BUILD.bazel b/pkg/sql/catalog/descs/BUILD.bazel index 659a405ba025..0a4eae06bf6c 100644 --- a/pkg/sql/catalog/descs/BUILD.bazel +++ b/pkg/sql/catalog/descs/BUILD.bazel @@ -120,7 +120,6 @@ go_test( "//pkg/sql/sessiondata", "//pkg/sql/sqlliveness", "//pkg/sql/sqlliveness/sqllivenesstestutils", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/testutils", "//pkg/testutils/datapathutils", diff --git a/pkg/sql/catalog/descs/collection_test.go b/pkg/sql/catalog/descs/collection_test.go index d3ca71e751c3..c842db74e426 100644 --- a/pkg/sql/catalog/descs/collection_test.go +++ b/pkg/sql/catalog/descs/collection_test.go @@ -43,7 +43,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -443,8 +442,7 @@ func TestMaybeFixSchemaPrivilegesIntegration(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) conn, err := db.Conn(ctx) diff --git a/pkg/sql/catalog/lease/BUILD.bazel b/pkg/sql/catalog/lease/BUILD.bazel index 5f89b8371e45..2ae12b387ba1 100644 --- a/pkg/sql/catalog/lease/BUILD.bazel +++ b/pkg/sql/catalog/lease/BUILD.bazel @@ -106,7 +106,6 @@ go_test( "//pkg/sql/rowenc/keyside", "//pkg/sql/sem/tree", "//pkg/sql/sessiondata", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/storage", "//pkg/testutils", diff --git a/pkg/sql/catalog/lease/kv_writer_test.go b/pkg/sql/catalog/lease/kv_writer_test.go index c2b60ba21606..4af18c2be438 100644 --- a/pkg/sql/catalog/lease/kv_writer_test.go +++ b/pkg/sql/catalog/lease/kv_writer_test.go @@ -33,6 +33,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/errors" "github.com/stretchr/testify/require" @@ -53,6 +54,7 @@ var MoveTablePrimaryIndexIDto2 func( // they are the same. func TestKVWriterMatchesIEWriter(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) ctx := context.Background() s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) diff --git a/pkg/sql/catalog/lease/lease_internal_test.go b/pkg/sql/catalog/lease/lease_internal_test.go index 5c5a46d95e09..3fb8c297e4ae 100644 --- a/pkg/sql/catalog/lease/lease_internal_test.go +++ b/pkg/sql/catalog/lease/lease_internal_test.go @@ -134,6 +134,8 @@ func getNumVersions(ds *descriptorState) int { func TestPurgeOldVersions(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + // We're going to block gossip so it doesn't come randomly and clear up the // leases we're artificially setting up. gossipSem := make(chan struct{}, 1) diff --git a/pkg/sql/catalog/lease/lease_test.go b/pkg/sql/catalog/lease/lease_test.go index 853b21ae7713..7a968dc97cd2 100644 --- a/pkg/sql/catalog/lease/lease_test.go +++ b/pkg/sql/catalog/lease/lease_test.go @@ -49,7 +49,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/rowenc/keyside" "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/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -266,8 +265,10 @@ func (t *leaseTest) node(nodeID uint32) *lease.Manager { func TestLeaseManager(testingT *testing.T) { defer leaktest.AfterTest(testingT)() + defer log.Scope(testingT).Close(testingT) + removalTracker := lease.NewLeaseRemovalTracker() - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -373,17 +374,13 @@ func (t *leaseTest) makeTableForTest() descpb.ID { return descID } -func createTestServerParams() base.TestServerArgs { - params, _ := tests.CreateTestServerParams() - params.Settings = cluster.MakeTestingClusterSettings() - return params -} - func TestLeaseManagerReacquire(testingT *testing.T) { defer leaktest.AfterTest(testingT)() - params := createTestServerParams() - ctx := context.Background() + defer log.Scope(testingT).Close(testingT) + ctx := context.Background() + var params base.TestServerArgs + params.Settings = cluster.MakeTestingClusterSettings() // Set the lease duration such that the next lease acquisition will // require the lease to be reacquired. lease.LeaseDuration.Override(ctx, ¶ms.SV, 0) @@ -429,8 +426,9 @@ func TestLeaseManagerReacquire(testingT *testing.T) { func TestLeaseManagerPublishVersionChanged(testingT *testing.T) { defer leaktest.AfterTest(testingT)() - params := createTestServerParams() - t := newLeaseTest(testingT, params) + defer log.Scope(testingT).Close(testingT) + + t := newLeaseTest(testingT, base.TestServerArgs{}) defer t.cleanup() descID := t.makeTableForTest() @@ -492,8 +490,9 @@ func TestLeaseManagerPublishVersionChanged(testingT *testing.T) { func TestLeaseManagerPublishIllegalVersionChange(testingT *testing.T) { defer leaktest.AfterTest(testingT)() - params := createTestServerParams() - t := newLeaseTest(testingT, params) + defer log.Scope(testingT).Close(testingT) + + t := newLeaseTest(testingT, base.TestServerArgs{}) defer t.cleanup() if _, err := t.node(1).Publish( @@ -516,7 +515,9 @@ func TestLeaseManagerPublishIllegalVersionChange(testingT *testing.T) { func TestLeaseManagerDrain(testingT *testing.T) { defer leaktest.AfterTest(testingT)() - params := createTestServerParams() + defer log.Scope(testingT).Close(testingT) + + var params base.TestServerArgs leaseRemovalTracker := lease.NewLeaseRemovalTracker() params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ @@ -579,7 +580,7 @@ func TestCantLeaseDeletedTable(testingT *testing.T) { var mu syncutil.Mutex clearSchemaChangers := false - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ SchemaChangeJobNoOp: func() bool { @@ -647,6 +648,7 @@ func acquire( // when it expires. func TestLeasesOnDeletedTableAreReleasedImmediately(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) var mu syncutil.Mutex clearSchemaChangers := false @@ -654,7 +656,7 @@ func TestLeasesOnDeletedTableAreReleasedImmediately(t *testing.T) { var waitTableID descpb.ID deleted := make(chan bool) - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ TestingDescriptorRefreshedEvent: func(descriptor *descpb.Descriptor) { @@ -756,13 +758,13 @@ CREATE TABLE test.t(a INT PRIMARY KEY); // properly tracked and released. func TestSubqueryLeases(t *testing.T) { defer leaktest.AfterTest(t)() - params := createTestServerParams() + defer log.Scope(t).Close(t) fooRelease := make(chan struct{}, 10) fooAcquiredCount := int32(0) fooReleaseCount := int32(0) var tableID int64 - + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -836,10 +838,10 @@ SELECT EXISTS(SELECT * FROM t.foo); // Test that an AS OF SYSTEM TIME query uses the table cache. func TestAsOfSystemTimeUsesCache(t *testing.T) { defer leaktest.AfterTest(t)() - params := createTestServerParams() + defer log.Scope(t).Close(t) fooAcquiredCount := int32(0) - + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -888,12 +890,11 @@ CREATE TABLE t.foo (v INT); func TestDescriptorRefreshOnRetry(t *testing.T) { defer leaktest.AfterTest(t)() - params := createTestServerParams() - fooAcquiredCount := int32(0) fooReleaseCount := int32(0) var tableID int64 + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -977,8 +978,9 @@ CREATE TABLE t.foo (v INT); // table descriptor. func TestTxnObeysTableModificationTime(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) - params := createTestServerParams() + var params base.TestServerArgs params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1084,7 +1086,9 @@ INSERT INTO t.kv VALUES ('a', 'b'); // version of a descriptor. func TestLeaseAtLatestVersion(t *testing.T) { defer leaktest.AfterTest(t)() - params := createTestServerParams() + defer log.Scope(t).Close(t) + + var params base.TestServerArgs errChan := make(chan error, 1) params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ @@ -1164,9 +1168,9 @@ INSERT INTO t.timestamp VALUES ('a', 'b'); // parallelism, which is important to also benchmark locking. func BenchmarkLeaseAcquireByNameCached(b *testing.B) { defer leaktest.AfterTest(b)() - params := createTestServerParams() + defer log.Scope(b).Close(b) - t := newLeaseTest(b, params) + t := newLeaseTest(b, base.TestServerArgs{}) defer t.cleanup() if _, err := t.db.Exec(` @@ -1218,11 +1222,13 @@ CREATE TABLE t.test (k CHAR PRIMARY KEY, v CHAR); // lease is renewed. func TestLeaseRenewedAutomatically(testingT *testing.T) { defer leaktest.AfterTest(testingT)() + defer log.Scope(testingT).Close(testingT) + ctx := context.Background() var testAcquiredCount int32 var testAcquisitionBlockCount int32 - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -1245,6 +1251,7 @@ func TestLeaseRenewedAutomatically(testingT *testing.T) { }, }, } + params.Settings = cluster.MakeTestingClusterSettings() // The lease jitter is set to ensure newer leases have higher // expiration timestamps. lease.LeaseJitterFraction.Override(ctx, ¶ms.SV, 0) @@ -1375,8 +1382,10 @@ CREATE TABLE t.test2 (); // table lease. func TestIncrementTableVersion(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + var violations int64 - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ // Disable execution of schema changers after the schema change // transaction commits. This is to prevent executing the default @@ -1477,8 +1486,10 @@ CREATE TABLE t.kv (k CHAR PRIMARY KEY, v CHAR); // user. func TestTwoVersionInvariantRetryError(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + var violations int64 - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ // Disable execution of schema changers after the schema change // transaction commits. This is to prevent executing the default @@ -1589,8 +1600,7 @@ func TestModificationTimeTxnOrdering(testingT *testing.T) { // Which table to exercise the test against. const descID = keys.LeaseTableID - params := createTestServerParams() - t := newLeaseTest(testingT, params) + t := newLeaseTest(testingT, base.TestServerArgs{}) defer t.cleanup() if _, err := t.db.Exec(` @@ -1673,6 +1683,8 @@ CREATE TABLE t.test0 (k CHAR PRIMARY KEY, v CHAR); // TODO(vivek): remove once epoch based leases is implemented. func TestLeaseRenewedPeriodically(testingT *testing.T) { defer leaktest.AfterTest(testingT)() + defer log.Scope(testingT).Close(testingT) + ctx := context.Background() var mu syncutil.Mutex @@ -1681,7 +1693,7 @@ func TestLeaseRenewedPeriodically(testingT *testing.T) { var testAcquisitionBlockCount int32 var expected catalog.DescriptorIDSet - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ LeaseStoreTestingKnobs: lease.StorageTestingKnobs{ @@ -1714,6 +1726,7 @@ func TestLeaseRenewedPeriodically(testingT *testing.T) { }, }, } + params.Settings = cluster.MakeTestingClusterSettings() // The lease jitter is set to ensure newer leases have higher // expiration timestamps. @@ -1810,8 +1823,9 @@ CREATE TABLE t.test2 (); // initiated before the table is dropped succeeds. func TestReadBeforeDrop(t *testing.T) { defer leaktest.AfterTest(t)() - params := createTestServerParams() - s, sqlDB, _ := serverutils.StartServer(t, params) + defer log.Scope(t).Close(t) + + s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := sqlDB.Exec(` @@ -1917,7 +1931,7 @@ INSERT INTO t.kv VALUES ('c', 'd'); func TestDeleteOrphanedLeases(testingT *testing.T) { defer leaktest.AfterTest(testingT)() - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{}, } @@ -1984,9 +1998,10 @@ CREATE TABLE t.after (k CHAR PRIMARY KEY, v CHAR); // pushing any locks held by schema-changing transactions out of their ways. func TestLeaseAcquisitionDoesntBlock(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + ctx := context.Background() - params := createTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) _, err := db.Exec(`CREATE DATABASE t; CREATE TABLE t.test(k CHAR PRIMARY KEY, v CHAR);`) @@ -2037,9 +2052,10 @@ func TestLeaseAcquisitionDoesntBlock(t *testing.T) { // touches the namespace table. func TestLeaseAcquisitionByNameDoesntBlock(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + ctx := context.Background() - params := createTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) _, err := db.Exec(`CREATE DATABASE t`) @@ -2297,7 +2313,7 @@ func TestLeaseWithOfflineTables(t *testing.T) { } ctx := context.Background() - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLLeaseManager = &lmKnobs s, db, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -2777,14 +2793,16 @@ CREATE TABLE d1.t2 (name int); // deadline. func TestLeaseTxnDeadlineExtension(t *testing.T) { defer leaktest.AfterTest(t)() - ctx := context.Background() + defer log.Scope(t).Close(t) + ctx := context.Background() filterMu := syncutil.Mutex{} blockTxn := make(chan struct{}) blockedOnce := false var txnID string - params := createTestServerParams() + var params base.TestServerArgs + params.Settings = cluster.MakeTestingClusterSettings() // Set the lease duration such that the next lease acquisition will // require the lease to be reacquired. lease.LeaseDuration.Override(ctx, ¶ms.SV, 0) @@ -2969,7 +2987,8 @@ func TestLeaseBulkInsertWithImplicitTxn(t *testing.T) { ctx := context.Background() - params := createTestServerParams() + var params base.TestServerArgs + params.Settings = cluster.MakeTestingClusterSettings() // Set the lease duration such that the next lease acquisition will // require the lease to be reacquired. lease.LeaseDuration.Override(ctx, ¶ms.SV, 0) @@ -3196,6 +3215,8 @@ func TestAmbiguousResultIsRetried(t *testing.T) { // this descriptor from "cache" (i.e. manager.mu.descriptor). func TestDescriptorRemovedFromCacheWhenLeaseRenewalForThisDescriptorFails(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + ctx := context.Background() // typeDescID will be set to id of the created type `typ` later. @@ -3213,7 +3234,7 @@ func TestDescriptorRemovedFromCacheWhenLeaseRenewalForThisDescriptorFails(t *tes // 4. This allows refreshSomeLeases fail with a DescriptorNotFound error and trigger the logic that removes this // descriptor entry from the lease manager's cache (namely, manager.mu.descriptor). // 5. Finally, we assert that the entry for `typ` is no longer in the cache. - params := createTestServerParams() + var params base.TestServerArgs params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ TestingBeforeAcquireLeaseDuringRefresh: func(id descpb.ID) error { @@ -3228,6 +3249,7 @@ func TestDescriptorRemovedFromCacheWhenLeaseRenewalForThisDescriptorFails(t *tes }, }, } + params.Settings = cluster.MakeTestingClusterSettings() // Set lease duration to something small so that the periodical lease refresh is kicked off often where the testing // knob will be invoked, and eventually the logic to remove unfound descriptor from cache will be triggered. diff --git a/pkg/sql/catalog/lease/main_test.go b/pkg/sql/catalog/lease/main_test.go index af894f934bef..a6eefdbbbe1d 100644 --- a/pkg/sql/catalog/lease/main_test.go +++ b/pkg/sql/catalog/lease/main_test.go @@ -29,6 +29,5 @@ func TestMain(m *testing.M) { randutil.SeedForTests() serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) - os.Exit(m.Run()) } diff --git a/pkg/sql/catalog/systemschema_test/BUILD.bazel b/pkg/sql/catalog/systemschema_test/BUILD.bazel index 30137da49d54..9f017c619078 100644 --- a/pkg/sql/catalog/systemschema_test/BUILD.bazel +++ b/pkg/sql/catalog/systemschema_test/BUILD.bazel @@ -10,18 +10,18 @@ go_test( data = glob(["testdata/**"]), deps = [ "//pkg/base", + "//pkg/ccl", "//pkg/keys", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/server", - "//pkg/settings/cluster", "//pkg/sql", "//pkg/sql/catalog/schematelemetry", - "//pkg/sql/tests", "//pkg/testutils/datapathutils", "//pkg/testutils/serverutils", "//pkg/testutils/sqlutils", "//pkg/util/leaktest", + "//pkg/util/log", "//pkg/util/log/eventpb", "//pkg/util/randutil", "//pkg/util/uuid", diff --git a/pkg/sql/catalog/systemschema_test/main_test.go b/pkg/sql/catalog/systemschema_test/main_test.go index 5c7a69d7c4c0..33825e7a98c9 100644 --- a/pkg/sql/catalog/systemschema_test/main_test.go +++ b/pkg/sql/catalog/systemschema_test/main_test.go @@ -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" @@ -25,5 +26,6 @@ func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) randutil.SeedForTests() serverutils.InitTestServerFactory(server.TestServerFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/catalog/systemschema_test/systemschema_test.go b/pkg/sql/catalog/systemschema_test/systemschema_test.go index 168dd4dd0a44..0b73af19dd2d 100644 --- a/pkg/sql/catalog/systemschema_test/systemschema_test.go +++ b/pkg/sql/catalog/systemschema_test/systemschema_test.go @@ -12,20 +12,20 @@ package systemschema_test import ( "context" + gosql "database/sql" "regexp" "strings" "testing" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" - "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/schematelemetry" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" "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/cockroachdb/cockroach/pkg/util/log/eventpb" "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/cockroachdb/datadriven" @@ -33,97 +33,107 @@ import ( "github.com/stretchr/testify/require" ) -func createTestServerParams() base.TestServerArgs { - params, _ := tests.CreateTestServerParams() - params.Settings = cluster.MakeTestingClusterSettings() - return params +var hlcRE *regexp.Regexp + +func init() { + hlcRE, _ = regexp.Compile(`"wallTime":"\d*"(,"logical":\d*)?`) } func TestValidateSystemSchemaAfterBootStrap(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) - ctx := context.Background() - hlcRE, err := regexp.Compile(`"wallTime":"\d*"(,"logical":\d*)?`) - require.NoError(t, err) + datadriven.Walk(t, datapathutils.TestDataPath(t, "bootstrap_system"), func(t *testing.T, path string) { + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{ + DefaultTestTenant: base.TestControlsTenantsExplicitly, + }) + defer srv.Stopper().Stop(context.Background()) + execCfg := srv.ExecutorConfig().(sql.ExecutorConfig) + runTest(t, path, db, &execCfg) + }) - datadriven.Walk(t, datapathutils.TestDataPath(t, "bootstrap"), func(t *testing.T, path string) { - // initialize per-test state - // New database for each test file. - s, db, _ := serverutils.StartServer(t, createTestServerParams()) - defer s.Stopper().Stop(ctx) - execCfg := s.ExecutorConfig().(sql.ExecutorConfig) + datadriven.Walk(t, datapathutils.TestDataPath(t, "bootstrap_tenant"), func(t *testing.T, path string) { + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{ + DefaultTestTenant: base.TestTenantAlwaysEnabled, + }) + defer srv.Stopper().Stop(context.Background()) + execCfg := srv.ApplicationLayer().ExecutorConfig().(sql.ExecutorConfig) + runTest(t, path, db, &execCfg) + }) +} - datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string { - switch d.Cmd { - case "show_create": - // Create a connection to the database cluster. - sqlRunner := sqlutils.MakeSQLRunner(db) +func runTest(t *testing.T, path string, db *gosql.DB, execCfg *sql.ExecutorConfig) { + var err error + datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string { + switch d.Cmd { + case "show_create": + // Create a connection to the database cluster. + sqlRunner := sqlutils.MakeSQLRunner(db) - // Execute the SQL query. - rows := sqlRunner.QueryStr(t, d.Input) + // Execute the SQL query. + rows := sqlRunner.QueryStr(t, d.Input) - // Extract results and return. - var sb strings.Builder - for _, row := range rows { - if len(row) != 1 { - d.Fatalf(t, "expect 1 column in %q result set, instead found %d", d.Input, len(row)) - } - sb.WriteString(row[0]) - sb.WriteString("\n") + // Extract results and return. + var sb strings.Builder + for _, row := range rows { + if len(row) != 1 { + d.Fatalf(t, "expect 1 column in %q result set, instead found %d", d.Input, len(row)) } - return sb.String() + sb.WriteString(row[0]) + sb.WriteString("\n") + } + return sb.String() - case "schema_telemetry": - snapshotID := uuid.FastMakeV4() - maxRecords := 100000 - // By default, collect the entirety of the system schema. - // In that case, the snapshot ID won't matter. - // When `max_records` is specified in the command, the record set - // will be truncated accordingly. This is done in a pseudo-random - // fashion and the snapshot ID is used as a seed value. - for _, arg := range d.CmdArgs { - switch arg.Key { - case "snapshot_id": - var snapshotIDString string - arg.Scan(t, 0, &snapshotIDString) - snapshotID, err = uuid.FromString(snapshotIDString) - require.NoErrorf(t, err, "invalid UUID for snapshot_id: %q", snapshotIDString) - case "max_records": - arg.Scan(t, 0, &maxRecords) - } + case "schema_telemetry": + snapshotID := uuid.FastMakeV4() + maxRecords := 100000 + // By default, collect the entirety of the system schema. + // In that case, the snapshot ID won't matter. + // When `max_records` is specified in the command, the record set + // will be truncated accordingly. This is done in a pseudo-random + // fashion and the snapshot ID is used as a seed value. + for _, arg := range d.CmdArgs { + switch arg.Key { + case "snapshot_id": + var snapshotIDString string + arg.Scan(t, 0, &snapshotIDString) + snapshotID, err = uuid.FromString(snapshotIDString) + require.NoErrorf(t, err, "invalid UUID for snapshot_id: %q", snapshotIDString) + case "max_records": + arg.Scan(t, 0, &maxRecords) } - // Collect a projection of the bootstrapped cluster's schema. - events, err := schematelemetry.CollectClusterSchemaForTelemetry(ctx, &execCfg, execCfg.Clock.Now(), snapshotID, maxRecords) - require.NoError(t, err, "expected schema snapshotting to succeed") - require.NotEmpty(t, events) + } + // Collect a projection of the bootstrapped cluster's schema. + events, err := schematelemetry.CollectClusterSchemaForTelemetry(context.Background(), execCfg, execCfg.Clock.Now(), snapshotID, maxRecords) + require.NoError(t, err, "expected schema snapshotting to succeed") + require.NotEmpty(t, events) - // Return the results, one descriptor per line. - var sb strings.Builder - je := jsonpb.Marshaler{} - meta, ok := events[0].(*eventpb.SchemaSnapshotMetadata) - require.Truef(t, ok, "expected a SchemaSnapshotMetadata event, instead got %T", events[0]) - require.EqualValues(t, len(events), 1+meta.NumRecords, "unexpected record count") - for _, event := range events[1:] { - ev, ok := event.(*eventpb.SchemaDescriptor) - require.Truef(t, ok, "expected a SchemaDescriptor event, instead got %T", event) - require.EqualValues(t, meta.SnapshotID, ev.SnapshotID, "unexpected snapshot ID") - if ev.DescID == keys.PublicSchemaID && ev.Desc == nil { - // The public schema of the system database has no descriptor. - continue - } - require.NotNilf(t, ev.Desc, "unexpectedly missing descriptor in %s", ev) - str, err := je.MarshalToString(ev.Desc) - require.NoError(t, err, "unexpected descriptor marshal error") - str = hlcRE.ReplaceAllString(str, `"wallTime":"0"`) - sb.WriteString(str) - sb.WriteRune('\n') + // Return the results, one descriptor per line. + var sb strings.Builder + je := jsonpb.Marshaler{} + meta, ok := events[0].(*eventpb.SchemaSnapshotMetadata) + require.Truef(t, ok, "expected a SchemaSnapshotMetadata event, instead got %T", events[0]) + require.EqualValues(t, len(events), 1+meta.NumRecords, "unexpected record count") + for _, event := range events[1:] { + ev, ok := event.(*eventpb.SchemaDescriptor) + require.Truef(t, ok, "expected a SchemaDescriptor event, instead got %T", event) + require.EqualValues(t, meta.SnapshotID, ev.SnapshotID, "unexpected snapshot ID") + if ev.DescID == keys.PublicSchemaID && ev.Desc == nil { + // The public schema of the system database has no descriptor. + continue } - return sb.String() - - default: - d.Fatalf(t, "unsupported command: %s", d.Cmd) + require.NotNilf(t, ev.Desc, "unexpectedly missing descriptor in %s", ev) + str, err := je.MarshalToString(ev.Desc) + require.NoError(t, err, "unexpected descriptor marshal error") + str = hlcRE.ReplaceAllString(str, `"wallTime":"0"`) + sb.WriteString(str) + sb.WriteRune('\n') } - return "" - }) + return sb.String() + + default: + d.Fatalf(t, "unsupported command: %s", d.Cmd) + } + return "" }) } diff --git a/pkg/sql/catalog/systemschema_test/testdata/bootstrap b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_system similarity index 100% rename from pkg/sql/catalog/systemschema_test/testdata/bootstrap rename to pkg/sql/catalog/systemschema_test/testdata/bootstrap_system diff --git a/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant new file mode 100644 index 000000000000..be1dafb6f0e8 --- /dev/null +++ b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant @@ -0,0 +1,570 @@ +show_create +USE system; SHOW CREATE ALL TABLES; +---- +CREATE TABLE public.descriptor ( + id INT8 NOT NULL, + descriptor BYTES NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id), + FAMILY fam_2_descriptor (descriptor) +); +CREATE TABLE public.users ( + username STRING NOT NULL, + "hashedPassword" BYTES NULL, + "isRole" BOOL NOT NULL DEFAULT false, + user_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (username ASC), + UNIQUE INDEX users_user_id_idx (user_id ASC), + FAMILY "primary" (username, user_id), + FAMILY "fam_2_hashedPassword" ("hashedPassword"), + FAMILY "fam_3_isRole" ("isRole") +); +CREATE TABLE public.zones ( + id INT8 NOT NULL, + config BYTES NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id), + FAMILY fam_2_config (config) +); +CREATE TABLE public.settings ( + name STRING NOT NULL, + value STRING NOT NULL, + "lastUpdated" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "valueType" STRING NULL, + CONSTRAINT "primary" PRIMARY KEY (name ASC), + FAMILY "fam_0_name_value_lastUpdated_valueType" (name, value, "lastUpdated", "valueType") +); +CREATE SEQUENCE public.descriptor_id_seq MINVALUE 1 MAXVALUE 9223372036854775807 INCREMENT 1 START 1; +CREATE TABLE public.lease ( + "descID" INT8 NOT NULL, + version INT8 NOT NULL, + "nodeID" INT8 NOT NULL, + expiration TIMESTAMP NOT NULL, + crdb_region BYTES NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (crdb_region ASC, "descID" ASC, version ASC, expiration ASC, "nodeID" ASC) +); +CREATE TABLE public.eventlog ( + "timestamp" TIMESTAMP NOT NULL, + "eventType" STRING NOT NULL, + "targetID" INT8 NOT NULL, + "reportingID" INT8 NOT NULL, + info STRING NULL, + "uniqueID" BYTES NOT NULL DEFAULT uuid_v4(), + CONSTRAINT "primary" PRIMARY KEY ("timestamp" ASC, "uniqueID" ASC), + FAMILY "primary" ("timestamp", "uniqueID"), + FAMILY "fam_2_eventType" ("eventType"), + FAMILY "fam_3_targetID" ("targetID"), + FAMILY "fam_4_reportingID" ("reportingID"), + FAMILY fam_5_info (info) +); +CREATE TABLE public.rangelog ( + "timestamp" TIMESTAMP NOT NULL, + "rangeID" INT8 NOT NULL, + "storeID" INT8 NOT NULL, + "eventType" STRING NOT NULL, + "otherRangeID" INT8 NULL, + info STRING NULL, + "uniqueID" INT8 NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY ("timestamp" ASC, "uniqueID" ASC), + FAMILY "primary" ("timestamp", "uniqueID"), + FAMILY "fam_2_rangeID" ("rangeID"), + FAMILY "fam_3_storeID" ("storeID"), + FAMILY "fam_4_eventType" ("eventType"), + FAMILY "fam_5_otherRangeID" ("otherRangeID"), + FAMILY fam_6_info (info) +); +CREATE TABLE public.ui ( + key STRING NOT NULL, + value BYTES NULL, + "lastUpdated" TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (key ASC), + FAMILY "primary" (key), + FAMILY fam_2_value (value), + FAMILY "fam_3_lastUpdated" ("lastUpdated") +); +CREATE TABLE public.jobs ( + id INT8 NOT NULL DEFAULT unique_rowid(), + status STRING NOT NULL, + created TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + payload BYTES NULL, + progress BYTES NULL, + created_by_type STRING NULL, + created_by_id INT8 NULL, + claim_session_id BYTES NULL, + claim_instance_id INT8 NULL, + num_runs INT8 NULL, + last_run TIMESTAMP NULL, + job_type STRING NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX jobs_status_created_idx (status ASC, created ASC), + INDEX jobs_created_by_type_created_by_id_idx (created_by_type ASC, created_by_id ASC) STORING (status), + INDEX jobs_run_stats_idx (claim_session_id ASC, status ASC, created ASC) STORING (last_run, num_runs, claim_instance_id) WHERE status IN ('running':::STRING, 'reverting':::STRING, 'pending':::STRING, 'pause-requested':::STRING, 'cancel-requested':::STRING), + INDEX jobs_job_type_idx (job_type ASC), + FAMILY fam_0_id_status_created_payload (id, status, created, payload, created_by_type, created_by_id, job_type), + FAMILY progress (progress), + FAMILY claim (claim_session_id, claim_instance_id, num_runs, last_run) +); +CREATE TABLE public.web_sessions ( + id INT8 NOT NULL DEFAULT unique_rowid(), + "hashedSecret" BYTES NOT NULL, + username STRING NOT NULL, + "createdAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "expiresAt" TIMESTAMP NOT NULL, + "revokedAt" TIMESTAMP NULL, + "lastUsedAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "auditInfo" STRING NULL, + user_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX "web_sessions_expiresAt_idx" ("expiresAt" ASC), + INDEX "web_sessions_createdAt_idx" ("createdAt" ASC), + INDEX "web_sessions_revokedAt_idx" ("revokedAt" ASC), + INDEX "web_sessions_lastUsedAt_idx" ("lastUsedAt" ASC), + FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", user_id) +); +CREATE TABLE public.table_statistics ( + "tableID" INT8 NOT NULL, + "statisticID" INT8 NOT NULL DEFAULT unique_rowid(), + name STRING NULL, + "columnIDs" INT8[] NOT NULL, + "createdAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "rowCount" INT8 NOT NULL, + "distinctCount" INT8 NOT NULL, + "nullCount" INT8 NOT NULL, + histogram BYTES NULL, + "avgSize" INT8 NOT NULL DEFAULT 0:::INT8, + "partialPredicate" STRING NULL, + "fullStatisticID" INT8 NULL, + CONSTRAINT "primary" PRIMARY KEY ("tableID" ASC, "statisticID" ASC), + FAMILY "fam_0_tableID_statisticID_name_columnIDs_createdAt_rowCount_distinctCount_nullCount_histogram" ("tableID", "statisticID", name, "columnIDs", "createdAt", "rowCount", "distinctCount", "nullCount", histogram, "avgSize", "partialPredicate", "fullStatisticID") +); +CREATE TABLE public.locations ( + "localityKey" STRING NOT NULL, + "localityValue" STRING NOT NULL, + latitude DECIMAL(18,15) NOT NULL, + longitude DECIMAL(18,15) NOT NULL, + CONSTRAINT "primary" PRIMARY KEY ("localityKey" ASC, "localityValue" ASC), + FAMILY "fam_0_localityKey_localityValue_latitude_longitude" ("localityKey", "localityValue", latitude, longitude) +); +CREATE TABLE public.role_members ( + "role" STRING NOT NULL, + member STRING NOT NULL, + "isAdmin" BOOL NOT NULL, + role_id OID NOT NULL, + member_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY ("role" ASC, member ASC), + INDEX role_members_role_idx ("role" ASC), + INDEX role_members_member_idx (member ASC), + INDEX role_members_role_id_idx (role_id ASC), + INDEX role_members_member_id_idx (member_id ASC), + UNIQUE INDEX role_members_role_id_member_id_key (role_id ASC, member_id ASC), + FAMILY "primary" ("role", member), + FAMILY "fam_3_isAdmin" ("isAdmin"), + FAMILY fam_4_role_id (role_id), + FAMILY fam_5_member_id (member_id) +); +CREATE TABLE public.comments ( + type INT8 NOT NULL, + object_id INT8 NOT NULL, + sub_id INT8 NOT NULL, + comment STRING NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (type ASC, object_id ASC, sub_id ASC), + FAMILY "primary" (type, object_id, sub_id), + FAMILY fam_4_comment (comment) +); +CREATE TABLE public.replication_constraint_stats ( + zone_id INT8 NOT NULL, + subzone_id INT8 NOT NULL, + type STRING NOT NULL, + config STRING NOT NULL, + report_id INT8 NOT NULL, + violation_start TIMESTAMPTZ NULL, + violating_ranges INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (zone_id ASC, subzone_id ASC, type ASC, config ASC) +); +CREATE TABLE public.replication_critical_localities ( + zone_id INT8 NOT NULL, + subzone_id INT8 NOT NULL, + locality STRING NOT NULL, + report_id INT8 NOT NULL, + at_risk_ranges INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (zone_id ASC, subzone_id ASC, locality ASC) +); +CREATE TABLE public.replication_stats ( + zone_id INT8 NOT NULL, + subzone_id INT8 NOT NULL, + report_id INT8 NOT NULL, + total_ranges INT8 NOT NULL, + unavailable_ranges INT8 NOT NULL, + under_replicated_ranges INT8 NOT NULL, + over_replicated_ranges INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (zone_id ASC, subzone_id ASC) +); +CREATE TABLE public.reports_meta ( + id INT8 NOT NULL, + "generated" TIMESTAMPTZ NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC) +); +CREATE TABLE public.namespace ( + "parentID" INT8 NOT NULL, + "parentSchemaID" INT8 NOT NULL, + name STRING NOT NULL, + id INT8 NULL, + CONSTRAINT "primary" PRIMARY KEY ("parentID" ASC, "parentSchemaID" ASC, name ASC), + FAMILY "primary" ("parentID", "parentSchemaID", name), + FAMILY fam_4_id (id) +); +CREATE TABLE public.protected_ts_meta ( + singleton BOOL NOT NULL DEFAULT true, + version INT8 NOT NULL, + num_records INT8 NOT NULL, + num_spans INT8 NOT NULL, + total_bytes INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (singleton ASC), + CONSTRAINT check_singleton CHECK (singleton) +); +CREATE TABLE public.protected_ts_records ( + id UUID NOT NULL, + ts DECIMAL NOT NULL, + meta_type STRING NOT NULL, + meta BYTES NULL, + num_spans INT8 NOT NULL, + spans BYTES NOT NULL, + verified BOOL NOT NULL DEFAULT false, + target BYTES NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC) +); +CREATE TABLE public.role_options ( + username STRING NOT NULL, + option STRING NOT NULL, + value STRING NULL, + user_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (username ASC, option ASC), + INDEX users_user_id_idx (user_id ASC) +); +CREATE TABLE public.statement_bundle_chunks ( + id INT8 NOT NULL DEFAULT unique_rowid(), + description STRING NULL, + data BYTES NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC) +); +CREATE TABLE public.statement_diagnostics_requests ( + id INT8 NOT NULL DEFAULT unique_rowid(), + completed BOOL NOT NULL DEFAULT false, + statement_fingerprint STRING NOT NULL, + statement_diagnostics_id INT8 NULL, + requested_at TIMESTAMPTZ NOT NULL, + min_execution_latency INTERVAL NULL, + expires_at TIMESTAMPTZ NULL, + sampling_probability FLOAT8 NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX completed_idx (completed ASC, id ASC) STORING (statement_fingerprint, min_execution_latency, expires_at, sampling_probability), + CONSTRAINT check_sampling_probability CHECK (sampling_probability BETWEEN 0.0:::FLOAT8 AND 1.0:::FLOAT8) +); +CREATE TABLE public.statement_diagnostics ( + id INT8 NOT NULL DEFAULT unique_rowid(), + statement_fingerprint STRING NOT NULL, + statement STRING NOT NULL, + collected_at TIMESTAMPTZ NOT NULL, + trace JSONB NULL, + bundle_chunks INT8[] NULL, + error STRING NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC) +); +CREATE TABLE public.scheduled_jobs ( + schedule_id INT8 NOT NULL DEFAULT unique_rowid(), + schedule_name STRING NOT NULL, + created TIMESTAMPTZ NOT NULL DEFAULT now():::TIMESTAMPTZ, + owner STRING NOT NULL, + next_run TIMESTAMPTZ NULL, + schedule_state BYTES NULL, + schedule_expr STRING NULL, + schedule_details BYTES NULL, + executor_type STRING NOT NULL, + execution_args BYTES NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (schedule_id ASC), + INDEX next_run_idx (next_run ASC), + FAMILY sched (schedule_id, next_run, schedule_state), + FAMILY other (schedule_name, created, owner, schedule_expr, schedule_details, executor_type, execution_args) +); +CREATE TABLE public.sqlliveness ( + session_id BYTES NOT NULL, + expiration DECIMAL NOT NULL, + crdb_region BYTES NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (crdb_region ASC, session_id ASC) +); +CREATE TABLE public.migrations ( + major INT8 NOT NULL, + minor INT8 NOT NULL, + patch INT8 NOT NULL, + internal INT8 NOT NULL, + completed_at TIMESTAMPTZ NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (major ASC, minor ASC, patch ASC, internal ASC) +); +CREATE TABLE public.join_tokens ( + id UUID NOT NULL, + secret BYTES NOT NULL, + expiration TIMESTAMPTZ NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC) +); +CREATE TABLE public.statement_statistics ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + transaction_fingerprint_id BYTES NOT NULL, + plan_hash BYTES NOT NULL, + app_name STRING NOT NULL, + node_id INT8 NOT NULL, + agg_interval INTERVAL NOT NULL, + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + plan JSONB NOT NULL, + crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(aggregated_ts, app_name, fingerprint_id, node_id, plan_hash, transaction_fingerprint_id)), 8:::INT8)) STORED, + index_recommendations STRING[] NOT NULL DEFAULT ARRAY[]:::STRING[], + indexes_usage JSONB NULL AS ((statistics->'statistics':::STRING)->'indexes':::STRING) VIRTUAL, + execution_count INT8 NULL AS (((statistics->'statistics':::STRING)->'cnt':::STRING)::INT8) STORED, + service_latency FLOAT8 NULL AS ((((statistics->'statistics':::STRING)->'svcLat':::STRING)->'mean':::STRING)::FLOAT8) STORED, + cpu_sql_nanos FLOAT8 NULL AS ((((statistics->'execution_statistics':::STRING)->'cpuSQLNanos':::STRING)->'mean':::STRING)::FLOAT8) STORED, + contention_time FLOAT8 NULL AS ((((statistics->'execution_statistics':::STRING)->'contentionTime':::STRING)->'mean':::STRING)::FLOAT8) STORED, + total_estimated_execution_time FLOAT8 NULL AS (((statistics->'statistics':::STRING)->>'cnt':::STRING)::FLOAT8 * (((statistics->'statistics':::STRING)->'svcLat':::STRING)->>'mean':::STRING)::FLOAT8) STORED, + p99_latency FLOAT8 NULL AS ((((statistics->'statistics':::STRING)->'latencyInfo':::STRING)->'p99':::STRING)::FLOAT8) STORED, + CONSTRAINT "primary" PRIMARY KEY (aggregated_ts ASC, fingerprint_id ASC, transaction_fingerprint_id ASC, plan_hash ASC, app_name ASC, node_id ASC) USING HASH WITH (bucket_count=8), + INDEX fingerprint_stats_idx (fingerprint_id ASC, transaction_fingerprint_id ASC), + INVERTED INDEX indexes_usage_idx (indexes_usage), + INDEX execution_count_idx (aggregated_ts ASC, app_name ASC, execution_count DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX service_latency_idx (aggregated_ts ASC, app_name ASC, service_latency DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX cpu_sql_nanos_idx (aggregated_ts ASC, app_name ASC, cpu_sql_nanos DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX contention_time_idx (aggregated_ts ASC, app_name ASC, contention_time DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX total_estimated_execution_time_idx (aggregated_ts ASC, app_name ASC, total_estimated_execution_time DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX p99_latency_idx (aggregated_ts ASC, app_name ASC, p99_latency DESC) WHERE app_name NOT LIKE '$ internal%':::STRING +); +CREATE TABLE public.transaction_statistics ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + app_name STRING NOT NULL, + node_id INT8 NOT NULL, + agg_interval INTERVAL NOT NULL, + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(aggregated_ts, app_name, fingerprint_id, node_id)), 8:::INT8)) STORED, + execution_count INT8 NULL AS (((statistics->'statistics':::STRING)->'cnt':::STRING)::INT8) STORED, + service_latency FLOAT8 NULL AS ((((statistics->'statistics':::STRING)->'svcLat':::STRING)->'mean':::STRING)::FLOAT8) STORED, + cpu_sql_nanos FLOAT8 NULL AS ((((statistics->'execution_statistics':::STRING)->'cpuSQLNanos':::STRING)->'mean':::STRING)::FLOAT8) STORED, + contention_time FLOAT8 NULL AS ((((statistics->'execution_statistics':::STRING)->'contentionTime':::STRING)->'mean':::STRING)::FLOAT8) STORED, + total_estimated_execution_time FLOAT8 NULL AS (((statistics->'statistics':::STRING)->>'cnt':::STRING)::FLOAT8 * (((statistics->'statistics':::STRING)->'svcLat':::STRING)->>'mean':::STRING)::FLOAT8) STORED, + p99_latency FLOAT8 NULL AS ((((statistics->'statistics':::STRING)->'latencyInfo':::STRING)->'p99':::STRING)::FLOAT8) STORED, + CONSTRAINT "primary" PRIMARY KEY (aggregated_ts ASC, fingerprint_id ASC, app_name ASC, node_id ASC) USING HASH WITH (bucket_count=8), + INDEX fingerprint_stats_idx (fingerprint_id ASC), + INDEX execution_count_idx (aggregated_ts ASC, app_name ASC, execution_count DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX service_latency_idx (aggregated_ts ASC, app_name ASC, service_latency DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX cpu_sql_nanos_idx (aggregated_ts ASC, app_name ASC, cpu_sql_nanos DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX contention_time_idx (aggregated_ts ASC, app_name ASC, contention_time DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX total_estimated_execution_time_idx (aggregated_ts ASC, app_name ASC, total_estimated_execution_time DESC) WHERE app_name NOT LIKE '$ internal%':::STRING, + INDEX p99_latency_idx (aggregated_ts ASC, app_name ASC, p99_latency DESC) WHERE app_name NOT LIKE '$ internal%':::STRING +); +CREATE TABLE public.database_role_settings ( + database_id OID NOT NULL, + role_name STRING NOT NULL, + settings STRING[] NOT NULL, + role_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (database_id ASC, role_name ASC), + UNIQUE INDEX database_role_settings_database_id_role_id_key (database_id ASC, role_id ASC) STORING (settings) +); +CREATE TABLE public.sql_instances ( + id INT8 NOT NULL, + addr STRING NULL, + session_id BYTES NULL, + locality JSONB NULL, + sql_addr STRING NULL, + crdb_region BYTES NOT NULL, + binary_version STRING NULL, + CONSTRAINT "primary" PRIMARY KEY (crdb_region ASC, id ASC) +); +CREATE SEQUENCE public.role_id_seq MINVALUE 100 MAXVALUE 2147483647 INCREMENT 1 START 100; +CREATE TABLE public.span_count ( + singleton BOOL NOT NULL DEFAULT true, + span_count INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (singleton ASC), + CONSTRAINT single_row CHECK (singleton) +); +CREATE TABLE public.privileges ( + username STRING NOT NULL, + path STRING NOT NULL, + privileges STRING[] NOT NULL, + grant_options STRING[] NOT NULL, + user_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (username ASC, path ASC), + UNIQUE INDEX privileges_path_user_id_key (path ASC, user_id ASC) STORING (privileges, grant_options), + UNIQUE INDEX privileges_path_username_key (path ASC, username ASC) STORING (privileges, grant_options) +); +CREATE TABLE public.external_connections ( + connection_name STRING NOT NULL, + created TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + updated TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + connection_type STRING NOT NULL, + connection_details BYTES NOT NULL, + owner STRING NOT NULL, + owner_id OID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (connection_name ASC) +); +CREATE TABLE public.job_info ( + job_id INT8 NOT NULL, + info_key STRING NOT NULL, + written TIMESTAMPTZ NOT NULL DEFAULT now():::TIMESTAMPTZ, + value BYTES NULL, + CONSTRAINT "primary" PRIMARY KEY (job_id ASC, info_key ASC, written DESC) +); +CREATE TABLE public.span_stats_unique_keys ( + id UUID NOT NULL DEFAULT gen_random_uuid(), + key_bytes BYTES NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + UNIQUE INDEX unique_keys_key_bytes_idx (key_bytes ASC) +); +CREATE TABLE public.span_stats_buckets ( + id UUID NOT NULL DEFAULT gen_random_uuid(), + sample_id UUID NOT NULL, + start_key_id UUID NOT NULL, + end_key_id UUID NOT NULL, + requests INT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX buckets_sample_id_idx (sample_id ASC) +); +CREATE TABLE public.span_stats_samples ( + id UUID NOT NULL DEFAULT gen_random_uuid(), + sample_time TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + UNIQUE INDEX samples_sample_time_idx (sample_time ASC) +); +CREATE TABLE public.span_stats_tenant_boundaries ( + tenant_id INT8 NOT NULL, + boundaries BYTES NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (tenant_id ASC) +); +CREATE TABLE public.statement_activity ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + transaction_fingerprint_id BYTES NOT NULL, + plan_hash BYTES NOT NULL, + app_name STRING NOT NULL, + agg_interval INTERVAL NOT NULL, + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + plan JSONB NOT NULL, + index_recommendations STRING[] NOT NULL DEFAULT ARRAY[]:::STRING[], + execution_count INT8 NOT NULL, + execution_total_seconds FLOAT8 NOT NULL, + execution_total_cluster_seconds FLOAT8 NOT NULL, + contention_time_avg_seconds FLOAT8 NOT NULL, + cpu_sql_avg_nanos FLOAT8 NOT NULL, + service_latency_avg_seconds FLOAT8 NOT NULL, + service_latency_p99_seconds FLOAT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (aggregated_ts ASC, fingerprint_id ASC, transaction_fingerprint_id ASC, plan_hash ASC, app_name ASC), + INDEX fingerprint_id_idx (fingerprint_id ASC, transaction_fingerprint_id ASC), + INDEX execution_count_idx (aggregated_ts ASC, execution_count DESC), + INDEX execution_total_seconds_idx (aggregated_ts ASC, execution_total_seconds DESC), + INDEX contention_time_avg_seconds_idx (aggregated_ts ASC, contention_time_avg_seconds DESC), + INDEX cpu_sql_avg_nanos_idx (aggregated_ts ASC, cpu_sql_avg_nanos DESC), + INDEX service_latency_avg_seconds_idx (aggregated_ts ASC, service_latency_avg_seconds DESC), + INDEX service_latency_p99_seconds_idx (aggregated_ts ASC, service_latency_p99_seconds DESC) +); +CREATE TABLE public.transaction_activity ( + aggregated_ts TIMESTAMPTZ NOT NULL, + fingerprint_id BYTES NOT NULL, + app_name STRING NOT NULL, + agg_interval INTERVAL NOT NULL, + metadata JSONB NOT NULL, + statistics JSONB NOT NULL, + query STRING NOT NULL, + execution_count INT8 NOT NULL, + execution_total_seconds FLOAT8 NOT NULL, + execution_total_cluster_seconds FLOAT8 NOT NULL, + contention_time_avg_seconds FLOAT8 NOT NULL, + cpu_sql_avg_nanos FLOAT8 NOT NULL, + service_latency_avg_seconds FLOAT8 NOT NULL, + service_latency_p99_seconds FLOAT8 NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (aggregated_ts ASC, fingerprint_id ASC, app_name ASC), + INDEX fingerprint_id_idx (fingerprint_id ASC), + INDEX execution_count_idx (aggregated_ts ASC, execution_count DESC), + INDEX execution_total_seconds_idx (aggregated_ts ASC, execution_total_seconds DESC), + INDEX contention_time_avg_seconds_idx (aggregated_ts ASC, contention_time_avg_seconds DESC), + INDEX cpu_sql_avg_nanos_idx (aggregated_ts ASC, cpu_sql_avg_nanos DESC), + INDEX service_latency_avg_seconds_idx (aggregated_ts ASC, service_latency_avg_seconds DESC), + INDEX service_latency_p99_seconds_idx (aggregated_ts ASC, service_latency_p99_seconds DESC) +); + +schema_telemetry +---- +{"database":{"name":"defaultdb","id":100,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":2},"schemas":{"public":{"id":101}},"defaultPrivileges":{}}} +{"database":{"name":"postgres","id":102,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":2},"schemas":{"public":{"id":103}},"defaultPrivileges":{}}} +{"database":{"name":"system","id":1,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2048","withGrantOption":"2048"},{"userProto":"root","privileges":"2048","withGrantOption":"2048"}],"ownerProto":"node","version":2}}} +{"table":{"name":"comments","id":24,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"type","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"object_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"sub_id","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"comment","id":4,"type":{"family":"StringFamily","oid":25}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["type","object_id","sub_id"],"columnIds":[1,2,3]},{"name":"fam_4_comment","id":4,"columnNames":["comment"],"columnIds":[4],"defaultColumnId":4}],"nextFamilyId":5,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["type","object_id","sub_id"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["comment"],"keyColumnIds":[1,2,3],"storeColumnIds":[4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"public","privileges":"32"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"database_role_settings","id":44,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"database_id","id":1,"type":{"family":"OidFamily","oid":26}},{"name":"role_name","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"settings","id":3,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}}},{"name":"role_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["database_id","role_name","settings","role_id"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["database_id","role_name"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings","role_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"database_role_settings_database_id_role_id_key","id":2,"unique":true,"version":3,"keyColumnNames":["database_id","role_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings"],"keyColumnIds":[1,4],"keySuffixColumnIds":[2],"storeColumnIds":[3],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"descriptor","id":3,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"descriptor","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_descriptor","id":2,"columnNames":["descriptor"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["descriptor"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"descriptor_id_seq","id":7,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"value","id":1,"type":{"family":"IntFamily","width":64,"oid":20}}],"families":[{"name":"primary","columnNames":["value"],"columnIds":[1],"defaultColumnId":1}],"primaryIndex":{"name":"primary","id":1,"version":4,"keyColumnNames":["value"],"keyColumnDirections":["ASC"],"keyColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{}},"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"formatVersion":3,"sequenceOpts":{"increment":"1","minValue":"1","maxValue":"9223372036854775807","start":"1","sequenceOwner":{},"cacheSize":"1"},"replacementOf":{"time":{}},"createAsOfTime":{}}} +{"table":{"name":"eventlog","id":12,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"timestamp","id":1,"type":{"family":"TimestampFamily","oid":1114}},{"name":"eventType","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"targetID","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"reportingID","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"info","id":5,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"uniqueID","id":6,"type":{"family":"BytesFamily","oid":17},"defaultExpr":"uuid_v4()"}],"nextColumnId":7,"families":[{"name":"primary","columnNames":["timestamp","uniqueID"],"columnIds":[1,6]},{"name":"fam_2_eventType","id":2,"columnNames":["eventType"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_targetID","id":3,"columnNames":["targetID"],"columnIds":[3],"defaultColumnId":3},{"name":"fam_4_reportingID","id":4,"columnNames":["reportingID"],"columnIds":[4],"defaultColumnId":4},{"name":"fam_5_info","id":5,"columnNames":["info"],"columnIds":[5],"defaultColumnId":5}],"nextFamilyId":6,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["timestamp","uniqueID"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["eventType","targetID","reportingID","info"],"keyColumnIds":[1,6],"storeColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"external_connections","id":52,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"connection_name","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"created","id":2,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"updated","id":3,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"connection_type","id":4,"type":{"family":"StringFamily","oid":25}},{"name":"connection_details","id":5,"type":{"family":"BytesFamily","oid":17}},{"name":"owner","id":6,"type":{"family":"StringFamily","oid":25}},{"name":"owner_id","id":7,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["connection_name","created","updated","connection_type","connection_details","owner","owner_id"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["connection_name"],"keyColumnDirections":["ASC"],"storeColumnNames":["created","updated","connection_type","connection_details","owner","owner_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"job_info","id":53,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"job_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"info_key","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"written","id":3,"type":{"family":"TimestampTZFamily","oid":1184},"defaultExpr":"now():::TIMESTAMPTZ"},{"name":"value","id":4,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["job_id","info_key","written","value"],"columnIds":[1,2,3,4],"defaultColumnId":4}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["job_id","info_key","written"],"keyColumnDirections":["ASC","ASC","DESC"],"storeColumnNames":["value"],"keyColumnIds":[1,2,3],"storeColumnIds":[4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"jobs","id":15,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"status","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"created","id":3,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"payload","id":4,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"progress","id":5,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"created_by_type","id":6,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"created_by_id","id":7,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"claim_session_id","id":8,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"claim_instance_id","id":9,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"num_runs","id":10,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"last_run","id":11,"type":{"family":"TimestampFamily","oid":1114},"nullable":true},{"name":"job_type","id":12,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":13,"families":[{"name":"fam_0_id_status_created_payload","columnNames":["id","status","created","payload","created_by_type","created_by_id","job_type"],"columnIds":[1,2,3,4,6,7,12]},{"name":"progress","id":1,"columnNames":["progress"],"columnIds":[5],"defaultColumnId":5},{"name":"claim","id":2,"columnNames":["claim_session_id","claim_instance_id","num_runs","last_run"],"columnIds":[8,9,10,11]}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["status","created","payload","progress","created_by_type","created_by_id","claim_session_id","claim_instance_id","num_runs","last_run","job_type"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8,9,10,11,12],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"jobs_status_created_idx","id":2,"version":3,"keyColumnNames":["status","created"],"keyColumnDirections":["ASC","ASC"],"keyColumnIds":[2,3],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"jobs_created_by_type_created_by_id_idx","id":3,"version":3,"keyColumnNames":["created_by_type","created_by_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["status"],"keyColumnIds":[6,7],"keySuffixColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"jobs_run_stats_idx","id":4,"version":3,"keyColumnNames":["claim_session_id","status","created"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["last_run","num_runs","claim_instance_id"],"keyColumnIds":[8,2,3],"keySuffixColumnIds":[1],"storeColumnIds":[11,10,9],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"status IN ('_':::STRING, '_':::STRING, '_':::STRING, '_':::STRING, '_':::STRING)"},{"name":"jobs_job_type_idx","id":5,"version":3,"keyColumnNames":["job_type"],"keyColumnDirections":["ASC"],"keyColumnIds":[12],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":6,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"join_tokens","id":41,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950}},{"name":"secret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"expiration","id":3,"type":{"family":"TimestampTZFamily","oid":1184}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["id","secret","expiration"],"columnIds":[1,2,3]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["secret","expiration"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"lease","id":11,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"descID","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"version","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"nodeID","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"expiration","id":4,"type":{"family":"TimestampFamily","oid":1114}},{"name":"crdb_region","id":5,"type":{"family":"BytesFamily","oid":17}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["descID","version","nodeID","expiration","crdb_region"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":2,"unique":true,"version":4,"keyColumnNames":["crdb_region","descID","version","expiration","nodeID"],"keyColumnDirections":["ASC","ASC","ASC","ASC","ASC"],"keyColumnIds":[5,1,2,4,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"locations","id":21,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"localityKey","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"localityValue","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"latitude","id":3,"type":{"family":"DecimalFamily","width":15,"precision":18,"oid":1700}},{"name":"longitude","id":4,"type":{"family":"DecimalFamily","width":15,"precision":18,"oid":1700}}],"nextColumnId":5,"families":[{"name":"fam_0_localityKey_localityValue_latitude_longitude","columnNames":["localityKey","localityValue","latitude","longitude"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["localityKey","localityValue"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["latitude","longitude"],"keyColumnIds":[1,2],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"migrations","id":40,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"major","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"minor","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"patch","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"internal","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"completed_at","id":5,"type":{"family":"TimestampTZFamily","oid":1184}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["major","minor","patch","internal","completed_at"],"columnIds":[1,2,3,4,5],"defaultColumnId":5}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["major","minor","patch","internal"],"keyColumnDirections":["ASC","ASC","ASC","ASC"],"storeColumnNames":["completed_at"],"keyColumnIds":[1,2,3,4],"storeColumnIds":[5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"namespace","id":30,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"parentID","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"parentSchemaID","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"name","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"id","id":4,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["parentID","parentSchemaID","name"],"columnIds":[1,2,3]},{"name":"fam_4_id","id":4,"columnNames":["id"],"columnIds":[4],"defaultColumnId":4}],"nextFamilyId":5,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["parentID","parentSchemaID","name"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["id"],"keyColumnIds":[1,2,3],"storeColumnIds":[4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"privileges","id":51,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"path","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"privileges","id":3,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}}},{"name":"grant_options","id":4,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}}},{"name":"user_id","id":5,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["username","path","privileges","grant_options","user_id"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username","path"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["privileges","grant_options","user_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":3},"indexes":[{"name":"privileges_path_user_id_key","id":2,"unique":true,"version":3,"keyColumnNames":["path","user_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["privileges","grant_options"],"keyColumnIds":[2,5],"keySuffixColumnIds":[1],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1},{"name":"privileges_path_username_key","id":3,"unique":true,"version":3,"keyColumnNames":["path","username"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["privileges","grant_options"],"keyColumnIds":[2,1],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":2}],"nextIndexId":4,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":4}} +{"table":{"name":"protected_ts_meta","id":31,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"singleton","id":1,"type":{"oid":16},"defaultExpr":"true"},{"name":"version","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"num_records","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"num_spans","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"total_bytes","id":5,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["singleton","version","num_records","num_spans","total_bytes"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["singleton"],"keyColumnDirections":["ASC"],"storeColumnNames":["version","num_records","num_spans","total_bytes"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"singleton","name":"check_singleton","columnIds":[1],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"protected_ts_records","id":32,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950}},{"name":"ts","id":2,"type":{"family":"DecimalFamily","oid":1700}},{"name":"meta_type","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"meta","id":4,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"num_spans","id":5,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"spans","id":6,"type":{"family":"BytesFamily","oid":17}},{"name":"verified","id":7,"type":{"oid":16},"defaultExpr":"false"},{"name":"target","id":8,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":9,"families":[{"name":"primary","columnNames":["id","ts","meta_type","meta","num_spans","spans","verified","target"],"columnIds":[1,2,3,4,5,6,7,8]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["ts","meta_type","meta","num_spans","spans","verified","target"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"rangelog","id":13,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"timestamp","id":1,"type":{"family":"TimestampFamily","oid":1114}},{"name":"rangeID","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"storeID","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"eventType","id":4,"type":{"family":"StringFamily","oid":25}},{"name":"otherRangeID","id":5,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"info","id":6,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"uniqueID","id":7,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["timestamp","uniqueID"],"columnIds":[1,7]},{"name":"fam_2_rangeID","id":2,"columnNames":["rangeID"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_storeID","id":3,"columnNames":["storeID"],"columnIds":[3],"defaultColumnId":3},{"name":"fam_4_eventType","id":4,"columnNames":["eventType"],"columnIds":[4],"defaultColumnId":4},{"name":"fam_5_otherRangeID","id":5,"columnNames":["otherRangeID"],"columnIds":[5],"defaultColumnId":5},{"name":"fam_6_info","id":6,"columnNames":["info"],"columnIds":[6],"defaultColumnId":6}],"nextFamilyId":7,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["timestamp","uniqueID"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["rangeID","storeID","eventType","otherRangeID","info"],"keyColumnIds":[1,7],"storeColumnIds":[2,3,4,5,6],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"replication_constraint_stats","id":25,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"zone_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"subzone_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"type","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"config","id":4,"type":{"family":"StringFamily","oid":25}},{"name":"report_id","id":5,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"violation_start","id":6,"type":{"family":"TimestampTZFamily","oid":1184},"nullable":true},{"name":"violating_ranges","id":7,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["zone_id","subzone_id","type","config","report_id","violation_start","violating_ranges"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["zone_id","subzone_id","type","config"],"keyColumnDirections":["ASC","ASC","ASC","ASC"],"storeColumnNames":["report_id","violation_start","violating_ranges"],"keyColumnIds":[1,2,3,4],"storeColumnIds":[5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"replication_critical_localities","id":26,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"zone_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"subzone_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"locality","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"report_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"at_risk_ranges","id":5,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["zone_id","subzone_id","locality","report_id","at_risk_ranges"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["zone_id","subzone_id","locality"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["report_id","at_risk_ranges"],"keyColumnIds":[1,2,3],"storeColumnIds":[4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"replication_stats","id":27,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"zone_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"subzone_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"report_id","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"total_ranges","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"unavailable_ranges","id":5,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"under_replicated_ranges","id":6,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"over_replicated_ranges","id":7,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["zone_id","subzone_id","report_id","total_ranges","unavailable_ranges","under_replicated_ranges","over_replicated_ranges"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["zone_id","subzone_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["report_id","total_ranges","unavailable_ranges","under_replicated_ranges","over_replicated_ranges"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"reports_meta","id":28,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"generated","id":2,"type":{"family":"TimestampTZFamily","oid":1184}}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id","generated"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["generated"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"role_id_seq","id":48,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"value","id":1,"type":{"family":"IntFamily","width":64,"oid":20}}],"families":[{"name":"primary","columnNames":["value"],"columnIds":[1],"defaultColumnId":1}],"primaryIndex":{"name":"primary","id":1,"version":4,"keyColumnNames":["value"],"keyColumnDirections":["ASC"],"keyColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{}},"privileges":{"users":[{"userProto":"admin","privileges":"800","withGrantOption":"800"},{"userProto":"root","privileges":"800","withGrantOption":"800"}],"ownerProto":"node","version":2},"formatVersion":3,"sequenceOpts":{"increment":"1","minValue":"100","maxValue":"2147483647","start":"100","sequenceOwner":{},"cacheSize":"1"},"replacementOf":{"time":{}},"createAsOfTime":{}}} +{"table":{"name":"role_members","id":23,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"role","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"member","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"isAdmin","id":3,"type":{"oid":16}},{"name":"role_id","id":4,"type":{"family":"OidFamily","oid":26}},{"name":"member_id","id":5,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["role","member"],"columnIds":[1,2]},{"name":"fam_3_isAdmin","id":3,"columnNames":["isAdmin"],"columnIds":[3],"defaultColumnId":3},{"name":"fam_4_role_id","id":4,"columnNames":["role_id"],"columnIds":[4],"defaultColumnId":4},{"name":"fam_5_member_id","id":5,"columnNames":["member_id"],"columnIds":[5],"defaultColumnId":5}],"nextFamilyId":6,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["role","member"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["isAdmin","role_id","member_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"role_members_role_idx","id":2,"version":3,"keyColumnNames":["role"],"keyColumnDirections":["ASC"],"keyColumnIds":[1],"keySuffixColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"role_members_member_idx","id":3,"version":3,"keyColumnNames":["member"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"role_members_role_id_idx","id":4,"version":3,"keyColumnNames":["role_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1,2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"role_members_member_id_idx","id":5,"version":3,"keyColumnNames":["member_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[5],"keySuffixColumnIds":[1,2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"role_members_role_id_member_id_key","id":6,"unique":true,"version":3,"keyColumnNames":["role_id","member_id"],"keyColumnDirections":["ASC","ASC"],"keyColumnIds":[4,5],"keySuffixColumnIds":[1,2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":7,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"role_options","id":33,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"option","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"value","id":3,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"user_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["username","option","value","user_id"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username","option"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["value","user_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"users_user_id_idx","id":2,"version":3,"keyColumnNames":["user_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1,2],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"scheduled_jobs","id":37,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"schedule_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"schedule_name","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"created","id":3,"type":{"family":"TimestampTZFamily","oid":1184},"defaultExpr":"now():::TIMESTAMPTZ"},{"name":"owner","id":4,"type":{"family":"StringFamily","oid":25}},{"name":"next_run","id":5,"type":{"family":"TimestampTZFamily","oid":1184},"nullable":true},{"name":"schedule_state","id":6,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"schedule_expr","id":7,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"schedule_details","id":8,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"executor_type","id":9,"type":{"family":"StringFamily","oid":25}},{"name":"execution_args","id":10,"type":{"family":"BytesFamily","oid":17}}],"nextColumnId":11,"families":[{"name":"sched","columnNames":["schedule_id","next_run","schedule_state"],"columnIds":[1,5,6]},{"name":"other","id":1,"columnNames":["schedule_name","created","owner","schedule_expr","schedule_details","executor_type","execution_args"],"columnIds":[2,3,4,7,8,9,10]}],"nextFamilyId":2,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["schedule_id"],"keyColumnDirections":["ASC"],"storeColumnNames":["schedule_name","created","owner","next_run","schedule_state","schedule_expr","schedule_details","executor_type","execution_args"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8,9,10],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"next_run_idx","id":2,"version":3,"keyColumnNames":["next_run"],"keyColumnDirections":["ASC"],"keyColumnIds":[5],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"settings","id":6,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"name","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"value","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"lastUpdated","id":3,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"valueType","id":4,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":5,"families":[{"name":"fam_0_name_value_lastUpdated_valueType","columnNames":["name","value","lastUpdated","valueType"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["name"],"keyColumnDirections":["ASC"],"storeColumnNames":["value","lastUpdated","valueType"],"keyColumnIds":[1],"storeColumnIds":[2,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"span_count","id":50,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"singleton","id":1,"type":{"oid":16},"defaultExpr":"true"},{"name":"span_count","id":2,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["singleton","span_count"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["singleton"],"keyColumnDirections":["ASC"],"storeColumnNames":["span_count"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"singleton","name":"single_row","columnIds":[1],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"span_stats_buckets","id":55,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950},"defaultExpr":"gen_random_uuid()"},{"name":"sample_id","id":2,"type":{"family":"UuidFamily","oid":2950}},{"name":"start_key_id","id":3,"type":{"family":"UuidFamily","oid":2950}},{"name":"end_key_id","id":4,"type":{"family":"UuidFamily","oid":2950}},{"name":"requests","id":5,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["id","sample_id","start_key_id","end_key_id","requests"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["sample_id","start_key_id","end_key_id","requests"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"buckets_sample_id_idx","id":2,"version":3,"keyColumnNames":["sample_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"span_stats_samples","id":56,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950},"defaultExpr":"gen_random_uuid()"},{"name":"sample_time","id":2,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id","sample_time"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["sample_time"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"samples_sample_time_idx","id":2,"unique":true,"version":3,"keyColumnNames":["sample_time"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"span_stats_tenant_boundaries","id":57,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"tenant_id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"boundaries","id":2,"type":{"family":"BytesFamily","oid":17}}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["tenant_id","boundaries"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["tenant_id"],"keyColumnDirections":["ASC"],"storeColumnNames":["boundaries"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"span_stats_unique_keys","id":54,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950},"defaultExpr":"gen_random_uuid()"},{"name":"key_bytes","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id","key_bytes"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["key_bytes"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"unique_keys_key_bytes_idx","id":2,"unique":true,"version":3,"keyColumnNames":["key_bytes"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"sql_instances","id":46,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"addr","id":2,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"session_id","id":3,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"locality","id":4,"type":{"family":"JsonFamily","oid":3802},"nullable":true},{"name":"sql_addr","id":5,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"crdb_region","id":6,"type":{"family":"BytesFamily","oid":17}},{"name":"binary_version","id":7,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["id","addr","session_id","locality","sql_addr","crdb_region","binary_version"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":2,"unique":true,"version":4,"keyColumnNames":["crdb_region","id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["addr","session_id","locality","sql_addr","binary_version"],"keyColumnIds":[6,1],"storeColumnIds":[2,3,4,5,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"sqlliveness","id":39,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"session_id","id":1,"type":{"family":"BytesFamily","oid":17}},{"name":"expiration","id":2,"type":{"family":"DecimalFamily","oid":1700}},{"name":"crdb_region","id":3,"type":{"family":"BytesFamily","oid":17}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["crdb_region","session_id","expiration"],"columnIds":[3,1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":2,"unique":true,"version":4,"keyColumnNames":["crdb_region","session_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["expiration"],"keyColumnIds":[3,1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_activity","id":58,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"aggregated_ts","id":1,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"fingerprint_id","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"transaction_fingerprint_id","id":3,"type":{"family":"BytesFamily","oid":17}},{"name":"plan_hash","id":4,"type":{"family":"BytesFamily","oid":17}},{"name":"app_name","id":5,"type":{"family":"StringFamily","oid":25}},{"name":"agg_interval","id":6,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}}},{"name":"metadata","id":7,"type":{"family":"JsonFamily","oid":3802}},{"name":"statistics","id":8,"type":{"family":"JsonFamily","oid":3802}},{"name":"plan","id":9,"type":{"family":"JsonFamily","oid":3802}},{"name":"index_recommendations","id":10,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}},"defaultExpr":"ARRAY[]:::STRING[]"},{"name":"execution_count","id":11,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"execution_total_seconds","id":12,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"execution_total_cluster_seconds","id":13,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"contention_time_avg_seconds","id":14,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"cpu_sql_avg_nanos","id":15,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"service_latency_avg_seconds","id":16,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"service_latency_p99_seconds","id":17,"type":{"family":"FloatFamily","width":64,"oid":701}}],"nextColumnId":18,"families":[{"name":"primary","columnNames":["aggregated_ts","fingerprint_id","transaction_fingerprint_id","plan_hash","app_name","agg_interval","metadata","statistics","plan","index_recommendations","execution_count","execution_total_seconds","execution_total_cluster_seconds","contention_time_avg_seconds","cpu_sql_avg_nanos","service_latency_avg_seconds","service_latency_p99_seconds"],"columnIds":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["aggregated_ts","fingerprint_id","transaction_fingerprint_id","plan_hash","app_name"],"keyColumnDirections":["ASC","ASC","ASC","ASC","ASC"],"storeColumnNames":["agg_interval","metadata","statistics","plan","index_recommendations","execution_count","execution_total_seconds","execution_total_cluster_seconds","contention_time_avg_seconds","cpu_sql_avg_nanos","service_latency_avg_seconds","service_latency_p99_seconds"],"keyColumnIds":[1,2,3,4,5],"storeColumnIds":[6,7,8,9,10,11,12,13,14,15,16,17],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"fingerprint_id_idx","id":2,"version":3,"keyColumnNames":["fingerprint_id","transaction_fingerprint_id"],"keyColumnDirections":["ASC","ASC"],"keyColumnIds":[2,3],"keySuffixColumnIds":[1,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"execution_count_idx","id":3,"version":3,"keyColumnNames":["aggregated_ts","execution_count"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,11],"keySuffixColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"execution_total_seconds_idx","id":4,"version":3,"keyColumnNames":["aggregated_ts","execution_total_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,12],"keySuffixColumnIds":[2,3,4,5],"compositeColumnIds":[12],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"contention_time_avg_seconds_idx","id":5,"version":3,"keyColumnNames":["aggregated_ts","contention_time_avg_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,14],"keySuffixColumnIds":[2,3,4,5],"compositeColumnIds":[14],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"cpu_sql_avg_nanos_idx","id":6,"version":3,"keyColumnNames":["aggregated_ts","cpu_sql_avg_nanos"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,15],"keySuffixColumnIds":[2,3,4,5],"compositeColumnIds":[15],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"service_latency_avg_seconds_idx","id":7,"version":3,"keyColumnNames":["aggregated_ts","service_latency_avg_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,16],"keySuffixColumnIds":[2,3,4,5],"compositeColumnIds":[16],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"service_latency_p99_seconds_idx","id":8,"version":3,"keyColumnNames":["aggregated_ts","service_latency_p99_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,17],"keySuffixColumnIds":[2,3,4,5],"compositeColumnIds":[17],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":9,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_bundle_chunks","id":34,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"description","id":2,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"data","id":3,"type":{"family":"BytesFamily","oid":17}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["id","description","data"],"columnIds":[1,2,3]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["description","data"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics","id":36,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"statement_fingerprint","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"statement","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"collected_at","id":4,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"trace","id":5,"type":{"family":"JsonFamily","oid":3802},"nullable":true},{"name":"bundle_chunks","id":6,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}},"nullable":true},{"name":"error","id":7,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["id","statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics_requests","id":35,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"completed","id":2,"type":{"oid":16},"defaultExpr":"false"},{"name":"statement_fingerprint","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"statement_diagnostics_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"requested_at","id":5,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"min_execution_latency","id":6,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}},"nullable":true},{"name":"expires_at","id":7,"type":{"family":"TimestampTZFamily","oid":1184},"nullable":true},{"name":"sampling_probability","id":8,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true}],"nextColumnId":9,"families":[{"name":"primary","columnNames":["id","completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"columnIds":[1,2,3,4,5,6,7,8]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"completed_idx","id":2,"version":3,"keyColumnNames":["completed","id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["statement_fingerprint","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[2,1],"storeColumnIds":[3,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"sampling_probability BETWEEN _:::FLOAT8 AND _:::FLOAT8","name":"check_sampling_probability","columnIds":[8],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"statement_statistics","id":42,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"aggregated_ts","id":1,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"fingerprint_id","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"transaction_fingerprint_id","id":3,"type":{"family":"BytesFamily","oid":17}},{"name":"plan_hash","id":4,"type":{"family":"BytesFamily","oid":17}},{"name":"app_name","id":5,"type":{"family":"StringFamily","oid":25}},{"name":"node_id","id":6,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"agg_interval","id":7,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}}},{"name":"metadata","id":8,"type":{"family":"JsonFamily","oid":3802}},{"name":"statistics","id":9,"type":{"family":"JsonFamily","oid":3802}},{"name":"plan","id":10,"type":{"family":"JsonFamily","oid":3802}},{"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8","id":11,"type":{"family":"IntFamily","width":32,"oid":23},"hidden":true,"computeExpr":"mod(fnv32(crdb_internal.datums_to_bytes(aggregated_ts, app_name, fingerprint_id, node_id, plan_hash, transaction_fingerprint_id)), _:::INT8)"},{"name":"index_recommendations","id":12,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}},"defaultExpr":"ARRAY[]:::STRING[]"},{"name":"indexes_usage","id":13,"type":{"family":"JsonFamily","oid":3802},"nullable":true,"computeExpr":"(statistics-\u003e'_':::STRING)-\u003e'_':::STRING","virtual":true},{"name":"execution_count","id":14,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true,"computeExpr":"((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)::INT8"},{"name":"service_latency","id":15,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"cpu_sql_nanos","id":16,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"contention_time","id":17,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"total_estimated_execution_time","id":18,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"((statistics-\u003e'_':::STRING)-\u003e\u003e'_':::STRING)::FLOAT8 * (((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e\u003e'_':::STRING)::FLOAT8"},{"name":"p99_latency","id":19,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"}],"nextColumnId":20,"families":[{"name":"primary","columnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8","aggregated_ts","fingerprint_id","transaction_fingerprint_id","plan_hash","app_name","node_id","agg_interval","metadata","statistics","plan","index_recommendations","execution_count","service_latency","cpu_sql_nanos","contention_time","total_estimated_execution_time","p99_latency"],"columnIds":[11,1,2,3,4,5,6,7,8,9,10,12,14,15,16,17,18,19]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8","aggregated_ts","fingerprint_id","transaction_fingerprint_id","plan_hash","app_name","node_id"],"keyColumnDirections":["ASC","ASC","ASC","ASC","ASC","ASC","ASC"],"storeColumnNames":["agg_interval","metadata","statistics","plan","index_recommendations","execution_count","service_latency","cpu_sql_nanos","contention_time","total_estimated_execution_time","p99_latency"],"keyColumnIds":[11,1,2,3,4,5,6],"storeColumnIds":[7,8,9,10,12,14,15,16,17,18,19],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{"isSharded":true,"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8","shardBuckets":8,"columnNames":["aggregated_ts","app_name","fingerprint_id","node_id","plan_hash","transaction_fingerprint_id"]},"geoConfig":{},"constraintId":1},"indexes":[{"name":"fingerprint_stats_idx","id":2,"version":3,"keyColumnNames":["fingerprint_id","transaction_fingerprint_id"],"keyColumnDirections":["ASC","ASC"],"keyColumnIds":[2,3],"keySuffixColumnIds":[11,1,4,5,6],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"indexes_usage_idx","id":3,"version":3,"keyColumnNames":["indexes_usage"],"keyColumnDirections":["ASC"],"invertedColumnKinds":["DEFAULT"],"keyColumnIds":[13],"keySuffixColumnIds":[11,1,2,3,4,5,6],"foreignKey":{},"interleave":{},"partitioning":{},"type":"INVERTED","sharded":{},"geoConfig":{}},{"name":"execution_count_idx","id":4,"version":3,"keyColumnNames":["aggregated_ts","app_name","execution_count"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,14],"keySuffixColumnIds":[11,2,3,4,6],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"service_latency_idx","id":5,"version":3,"keyColumnNames":["aggregated_ts","app_name","service_latency"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,15],"keySuffixColumnIds":[11,2,3,4,6],"compositeColumnIds":[15],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"cpu_sql_nanos_idx","id":6,"version":3,"keyColumnNames":["aggregated_ts","app_name","cpu_sql_nanos"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,16],"keySuffixColumnIds":[11,2,3,4,6],"compositeColumnIds":[16],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"contention_time_idx","id":7,"version":3,"keyColumnNames":["aggregated_ts","app_name","contention_time"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,17],"keySuffixColumnIds":[11,2,3,4,6],"compositeColumnIds":[17],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"total_estimated_execution_time_idx","id":8,"version":3,"keyColumnNames":["aggregated_ts","app_name","total_estimated_execution_time"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,18],"keySuffixColumnIds":[11,2,3,4,6],"compositeColumnIds":[18],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"p99_latency_idx","id":9,"version":3,"keyColumnNames":["aggregated_ts","app_name","p99_latency"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,5,19],"keySuffixColumnIds":[11,2,3,4,6],"compositeColumnIds":[19],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"}],"nextIndexId":10,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8 IN (_:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8)","name":"check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8","columnIds":[11],"fromHashShardedColumn":true,"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"table_statistics","id":20,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"tableID","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"statisticID","id":2,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"name","id":3,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"columnIDs","id":4,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}}},{"name":"createdAt","id":5,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"rowCount","id":6,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"distinctCount","id":7,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"nullCount","id":8,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"histogram","id":9,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"avgSize","id":10,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"_:::INT8"},{"name":"partialPredicate","id":11,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"fullStatisticID","id":12,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true}],"nextColumnId":13,"families":[{"name":"fam_0_tableID_statisticID_name_columnIDs_createdAt_rowCount_distinctCount_nullCount_histogram","columnNames":["tableID","statisticID","name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"columnIds":[1,2,3,4,5,6,7,8,9,10,11,12]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["tableID","statisticID"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5,6,7,8,9,10,11,12],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"transaction_activity","id":59,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"aggregated_ts","id":1,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"fingerprint_id","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"app_name","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"agg_interval","id":4,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}}},{"name":"metadata","id":5,"type":{"family":"JsonFamily","oid":3802}},{"name":"statistics","id":6,"type":{"family":"JsonFamily","oid":3802}},{"name":"query","id":7,"type":{"family":"StringFamily","oid":25}},{"name":"execution_count","id":8,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"execution_total_seconds","id":9,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"execution_total_cluster_seconds","id":10,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"contention_time_avg_seconds","id":11,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"cpu_sql_avg_nanos","id":12,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"service_latency_avg_seconds","id":13,"type":{"family":"FloatFamily","width":64,"oid":701}},{"name":"service_latency_p99_seconds","id":14,"type":{"family":"FloatFamily","width":64,"oid":701}}],"nextColumnId":15,"families":[{"name":"primary","columnNames":["aggregated_ts","fingerprint_id","app_name","agg_interval","metadata","statistics","query","execution_count","execution_total_seconds","execution_total_cluster_seconds","contention_time_avg_seconds","cpu_sql_avg_nanos","service_latency_avg_seconds","service_latency_p99_seconds"],"columnIds":[1,2,3,4,5,6,7,8,9,10,11,12,13,14]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["aggregated_ts","fingerprint_id","app_name"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["agg_interval","metadata","statistics","query","execution_count","execution_total_seconds","execution_total_cluster_seconds","contention_time_avg_seconds","cpu_sql_avg_nanos","service_latency_avg_seconds","service_latency_p99_seconds"],"keyColumnIds":[1,2,3],"storeColumnIds":[4,5,6,7,8,9,10,11,12,13,14],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"fingerprint_id_idx","id":2,"version":3,"keyColumnNames":["fingerprint_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1,3],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"execution_count_idx","id":3,"version":3,"keyColumnNames":["aggregated_ts","execution_count"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,8],"keySuffixColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"execution_total_seconds_idx","id":4,"version":3,"keyColumnNames":["aggregated_ts","execution_total_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,9],"keySuffixColumnIds":[2,3],"compositeColumnIds":[9],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"contention_time_avg_seconds_idx","id":5,"version":3,"keyColumnNames":["aggregated_ts","contention_time_avg_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,11],"keySuffixColumnIds":[2,3],"compositeColumnIds":[11],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"cpu_sql_avg_nanos_idx","id":6,"version":3,"keyColumnNames":["aggregated_ts","cpu_sql_avg_nanos"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,12],"keySuffixColumnIds":[2,3],"compositeColumnIds":[12],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"service_latency_avg_seconds_idx","id":7,"version":3,"keyColumnNames":["aggregated_ts","service_latency_avg_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,13],"keySuffixColumnIds":[2,3],"compositeColumnIds":[13],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"service_latency_p99_seconds_idx","id":8,"version":3,"keyColumnNames":["aggregated_ts","service_latency_p99_seconds"],"keyColumnDirections":["ASC","DESC"],"keyColumnIds":[1,14],"keySuffixColumnIds":[2,3],"compositeColumnIds":[14],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":9,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"transaction_statistics","id":43,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"aggregated_ts","id":1,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"fingerprint_id","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"app_name","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"node_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"agg_interval","id":5,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}}},{"name":"metadata","id":6,"type":{"family":"JsonFamily","oid":3802}},{"name":"statistics","id":7,"type":{"family":"JsonFamily","oid":3802}},{"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","id":8,"type":{"family":"IntFamily","width":32,"oid":23},"hidden":true,"computeExpr":"mod(fnv32(crdb_internal.datums_to_bytes(aggregated_ts, app_name, fingerprint_id, node_id)), _:::INT8)"},{"name":"execution_count","id":9,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true,"computeExpr":"((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)::INT8"},{"name":"service_latency","id":10,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"cpu_sql_nanos","id":11,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"contention_time","id":12,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"},{"name":"total_estimated_execution_time","id":13,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"((statistics-\u003e'_':::STRING)-\u003e\u003e'_':::STRING)::FLOAT8 * (((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e\u003e'_':::STRING)::FLOAT8"},{"name":"p99_latency","id":14,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true,"computeExpr":"(((statistics-\u003e'_':::STRING)-\u003e'_':::STRING)-\u003e'_':::STRING)::FLOAT8"}],"nextColumnId":15,"families":[{"name":"primary","columnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","aggregated_ts","fingerprint_id","app_name","node_id","agg_interval","metadata","statistics","execution_count","service_latency","cpu_sql_nanos","contention_time","total_estimated_execution_time","p99_latency"],"columnIds":[8,1,2,3,4,5,6,7,9,10,11,12,13,14]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","aggregated_ts","fingerprint_id","app_name","node_id"],"keyColumnDirections":["ASC","ASC","ASC","ASC","ASC"],"storeColumnNames":["agg_interval","metadata","statistics","execution_count","service_latency","cpu_sql_nanos","contention_time","total_estimated_execution_time","p99_latency"],"keyColumnIds":[8,1,2,3,4],"storeColumnIds":[5,6,7,9,10,11,12,13,14],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{"isSharded":true,"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","shardBuckets":8,"columnNames":["aggregated_ts","app_name","fingerprint_id","node_id"]},"geoConfig":{},"constraintId":1},"indexes":[{"name":"fingerprint_stats_idx","id":2,"version":3,"keyColumnNames":["fingerprint_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[8,1,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"execution_count_idx","id":3,"version":3,"keyColumnNames":["aggregated_ts","app_name","execution_count"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,9],"keySuffixColumnIds":[8,2,4],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"service_latency_idx","id":4,"version":3,"keyColumnNames":["aggregated_ts","app_name","service_latency"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,10],"keySuffixColumnIds":[8,2,4],"compositeColumnIds":[10],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"cpu_sql_nanos_idx","id":5,"version":3,"keyColumnNames":["aggregated_ts","app_name","cpu_sql_nanos"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,11],"keySuffixColumnIds":[8,2,4],"compositeColumnIds":[11],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"contention_time_idx","id":6,"version":3,"keyColumnNames":["aggregated_ts","app_name","contention_time"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,12],"keySuffixColumnIds":[8,2,4],"compositeColumnIds":[12],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"total_estimated_execution_time_idx","id":7,"version":3,"keyColumnNames":["aggregated_ts","app_name","total_estimated_execution_time"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,13],"keySuffixColumnIds":[8,2,4],"compositeColumnIds":[13],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"},{"name":"p99_latency_idx","id":8,"version":3,"keyColumnNames":["aggregated_ts","app_name","p99_latency"],"keyColumnDirections":["ASC","ASC","DESC"],"keyColumnIds":[1,3,14],"keySuffixColumnIds":[8,2,4],"compositeColumnIds":[14],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"predicate":"app_name NOT LIKE '_':::STRING"}],"nextIndexId":9,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (_:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8)","name":"check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","columnIds":[8],"fromHashShardedColumn":true,"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"ui","id":14,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"key","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"value","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"lastUpdated","id":3,"type":{"family":"TimestampFamily","oid":1114}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["key"],"columnIds":[1]},{"name":"fam_2_value","id":2,"columnNames":["value"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_lastUpdated","id":3,"columnNames":["lastUpdated"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["key"],"keyColumnDirections":["ASC"],"storeColumnNames":["value","lastUpdated"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"users","id":4,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"hashedPassword","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"isRole","id":3,"type":{"oid":16},"defaultExpr":"false"},{"name":"user_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["username","user_id"],"columnIds":[1,4],"defaultColumnId":4},{"name":"fam_2_hashedPassword","id":2,"columnNames":["hashedPassword"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_isRole","id":3,"columnNames":["isRole"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedPassword","isRole","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"users_user_id_idx","id":2,"unique":true,"version":3,"keyColumnNames":["user_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"web_sessions","id":19,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"hashedSecret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"username","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"createdAt","id":4,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"expiresAt","id":5,"type":{"family":"TimestampFamily","oid":1114}},{"name":"revokedAt","id":6,"type":{"family":"TimestampFamily","oid":1114},"nullable":true},{"name":"lastUsedAt","id":7,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"auditInfo","id":8,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"user_id","id":9,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":10,"families":[{"name":"fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo","columnNames":["id","hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo","user_id"],"columnIds":[1,2,3,4,5,6,7,8,9]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8,9],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"web_sessions_expiresAt_idx","id":2,"version":3,"keyColumnNames":["expiresAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[5],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_createdAt_idx","id":3,"version":3,"keyColumnNames":["createdAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_revokedAt_idx","id":4,"version":3,"keyColumnNames":["revokedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[6],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_lastUsedAt_idx","id":5,"version":3,"keyColumnNames":["lastUsedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[7],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":6,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"zones","id":5,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"config","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_config","id":2,"columnNames":["config"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["config"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"schema":{"name":"public","id":101,"modificationTime":{"wallTime":"0"},"version":"1","parentId":100,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} +{"schema":{"name":"public","id":103,"modificationTime":{"wallTime":"0"},"version":"1","parentId":102,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} + +schema_telemetry snapshot_id=7cd8a9ae-f35c-4cd2-970a-757174600874 max_records=10 +---- +{"table":{"name":"descriptor","id":3,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"descriptor","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_descriptor","id":2,"columnNames":["descriptor"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["descriptor"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"join_tokens","id":41,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950}},{"name":"secret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"expiration","id":3,"type":{"family":"TimestampTZFamily","oid":1184}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["id","secret","expiration"],"columnIds":[1,2,3]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["secret","expiration"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"span_count","id":50,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"singleton","id":1,"type":{"oid":16},"defaultExpr":"true"},{"name":"span_count","id":2,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["singleton","span_count"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["singleton"],"keyColumnDirections":["ASC"],"storeColumnNames":["span_count"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"singleton","name":"single_row","columnIds":[1],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"span_stats_buckets","id":55,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950},"defaultExpr":"gen_random_uuid()"},{"name":"sample_id","id":2,"type":{"family":"UuidFamily","oid":2950}},{"name":"start_key_id","id":3,"type":{"family":"UuidFamily","oid":2950}},{"name":"end_key_id","id":4,"type":{"family":"UuidFamily","oid":2950}},{"name":"requests","id":5,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["id","sample_id","start_key_id","end_key_id","requests"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["sample_id","start_key_id","end_key_id","requests"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"buckets_sample_id_idx","id":2,"version":3,"keyColumnNames":["sample_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics","id":36,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"statement_fingerprint","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"statement","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"collected_at","id":4,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"trace","id":5,"type":{"family":"JsonFamily","oid":3802},"nullable":true},{"name":"bundle_chunks","id":6,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}},"nullable":true},{"name":"error","id":7,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["id","statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics_requests","id":35,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"completed","id":2,"type":{"oid":16},"defaultExpr":"false"},{"name":"statement_fingerprint","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"statement_diagnostics_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"requested_at","id":5,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"min_execution_latency","id":6,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}},"nullable":true},{"name":"expires_at","id":7,"type":{"family":"TimestampTZFamily","oid":1184},"nullable":true},{"name":"sampling_probability","id":8,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true}],"nextColumnId":9,"families":[{"name":"primary","columnNames":["id","completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"columnIds":[1,2,3,4,5,6,7,8]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"completed_idx","id":2,"version":3,"keyColumnNames":["completed","id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["statement_fingerprint","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[2,1],"storeColumnIds":[3,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"sampling_probability BETWEEN _:::FLOAT8 AND _:::FLOAT8","name":"check_sampling_probability","columnIds":[8],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"table_statistics","id":20,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"tableID","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"statisticID","id":2,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"name","id":3,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"columnIDs","id":4,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}}},{"name":"createdAt","id":5,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"rowCount","id":6,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"distinctCount","id":7,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"nullCount","id":8,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"histogram","id":9,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"avgSize","id":10,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"_:::INT8"},{"name":"partialPredicate","id":11,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"fullStatisticID","id":12,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true}],"nextColumnId":13,"families":[{"name":"fam_0_tableID_statisticID_name_columnIDs_createdAt_rowCount_distinctCount_nullCount_histogram","columnNames":["tableID","statisticID","name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"columnIds":[1,2,3,4,5,6,7,8,9,10,11,12]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["tableID","statisticID"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5,6,7,8,9,10,11,12],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"users","id":4,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"hashedPassword","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"isRole","id":3,"type":{"oid":16},"defaultExpr":"false"},{"name":"user_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["username","user_id"],"columnIds":[1,4],"defaultColumnId":4},{"name":"fam_2_hashedPassword","id":2,"columnNames":["hashedPassword"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_isRole","id":3,"columnNames":["isRole"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedPassword","isRole","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"users_user_id_idx","id":2,"unique":true,"version":3,"keyColumnNames":["user_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"zones","id":5,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"config","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_config","id":2,"columnNames":["config"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["config"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"schema":{"name":"public","id":101,"modificationTime":{"wallTime":"0"},"version":"1","parentId":100,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} + +schema_telemetry snapshot_id=7cd8a9ae-f35c-4cd2-970a-757174600874 max_records=10 +---- +{"table":{"name":"descriptor","id":3,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"descriptor","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_descriptor","id":2,"columnNames":["descriptor"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["descriptor"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"join_tokens","id":41,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950}},{"name":"secret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"expiration","id":3,"type":{"family":"TimestampTZFamily","oid":1184}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["id","secret","expiration"],"columnIds":[1,2,3]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["secret","expiration"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"span_count","id":50,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"singleton","id":1,"type":{"oid":16},"defaultExpr":"true"},{"name":"span_count","id":2,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["singleton","span_count"],"columnIds":[1,2],"defaultColumnId":2}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["singleton"],"keyColumnDirections":["ASC"],"storeColumnNames":["span_count"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"singleton","name":"single_row","columnIds":[1],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"span_stats_buckets","id":55,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"UuidFamily","oid":2950},"defaultExpr":"gen_random_uuid()"},{"name":"sample_id","id":2,"type":{"family":"UuidFamily","oid":2950}},{"name":"start_key_id","id":3,"type":{"family":"UuidFamily","oid":2950}},{"name":"end_key_id","id":4,"type":{"family":"UuidFamily","oid":2950}},{"name":"requests","id":5,"type":{"family":"IntFamily","width":64,"oid":20}}],"nextColumnId":6,"families":[{"name":"primary","columnNames":["id","sample_id","start_key_id","end_key_id","requests"],"columnIds":[1,2,3,4,5]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["sample_id","start_key_id","end_key_id","requests"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"buckets_sample_id_idx","id":2,"version":3,"keyColumnNames":["sample_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics","id":36,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"statement_fingerprint","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"statement","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"collected_at","id":4,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"trace","id":5,"type":{"family":"JsonFamily","oid":3802},"nullable":true},{"name":"bundle_chunks","id":6,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}},"nullable":true},{"name":"error","id":7,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":8,"families":[{"name":"primary","columnNames":["id","statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"columnIds":[1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["statement_fingerprint","statement","collected_at","trace","bundle_chunks","error"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"statement_diagnostics_requests","id":35,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"completed","id":2,"type":{"oid":16},"defaultExpr":"false"},{"name":"statement_fingerprint","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"statement_diagnostics_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true},{"name":"requested_at","id":5,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"min_execution_latency","id":6,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}},"nullable":true},{"name":"expires_at","id":7,"type":{"family":"TimestampTZFamily","oid":1184},"nullable":true},{"name":"sampling_probability","id":8,"type":{"family":"FloatFamily","width":64,"oid":701},"nullable":true}],"nextColumnId":9,"families":[{"name":"primary","columnNames":["id","completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"columnIds":[1,2,3,4,5,6,7,8]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["completed","statement_fingerprint","statement_diagnostics_id","requested_at","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"completed_idx","id":2,"version":3,"keyColumnNames":["completed","id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["statement_fingerprint","min_execution_latency","expires_at","sampling_probability"],"keyColumnIds":[2,1],"storeColumnIds":[3,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"sampling_probability BETWEEN _:::FLOAT8 AND _:::FLOAT8","name":"check_sampling_probability","columnIds":[8],"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"table_statistics","id":20,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"tableID","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"statisticID","id":2,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"name","id":3,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"columnIDs","id":4,"type":{"family":"ArrayFamily","width":64,"arrayElemType":"IntFamily","oid":1016,"arrayContents":{"family":"IntFamily","width":64,"oid":20}}},{"name":"createdAt","id":5,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"rowCount","id":6,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"distinctCount","id":7,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"nullCount","id":8,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"histogram","id":9,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"avgSize","id":10,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"_:::INT8"},{"name":"partialPredicate","id":11,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"fullStatisticID","id":12,"type":{"family":"IntFamily","width":64,"oid":20},"nullable":true}],"nextColumnId":13,"families":[{"name":"fam_0_tableID_statisticID_name_columnIDs_createdAt_rowCount_distinctCount_nullCount_histogram","columnNames":["tableID","statisticID","name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"columnIds":[1,2,3,4,5,6,7,8,9,10,11,12]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["tableID","statisticID"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["name","columnIDs","createdAt","rowCount","distinctCount","nullCount","histogram","avgSize","partialPredicate","fullStatisticID"],"keyColumnIds":[1,2],"storeColumnIds":[3,4,5,6,7,8,9,10,11,12],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"table":{"name":"users","id":4,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"hashedPassword","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"isRole","id":3,"type":{"oid":16},"defaultExpr":"false"},{"name":"user_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["username","user_id"],"columnIds":[1,4],"defaultColumnId":4},{"name":"fam_2_hashedPassword","id":2,"columnNames":["hashedPassword"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_isRole","id":3,"columnNames":["isRole"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedPassword","isRole","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"users_user_id_idx","id":2,"unique":true,"version":3,"keyColumnNames":["user_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} +{"table":{"name":"zones","id":5,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"config","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_config","id":2,"columnNames":["config"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["config"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} +{"schema":{"name":"public","id":101,"modificationTime":{"wallTime":"0"},"version":"1","parentId":100,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} diff --git a/pkg/sql/colenc/BUILD.bazel b/pkg/sql/colenc/BUILD.bazel index 4c3fbe4b1ab5..2d378eccdced 100644 --- a/pkg/sql/colenc/BUILD.bazel +++ b/pkg/sql/colenc/BUILD.bazel @@ -77,7 +77,6 @@ go_test( "//pkg/sql/row", "//pkg/sql/sem/eval", "//pkg/sql/sem/tree", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/testutils/serverutils", "//pkg/testutils/sqlutils", diff --git a/pkg/sql/colenc/bench_test.go b/pkg/sql/colenc/bench_test.go index 42ac10ef8080..f24bffe5ad3c 100644 --- a/pkg/sql/colenc/bench_test.go +++ b/pkg/sql/colenc/bench_test.go @@ -16,6 +16,7 @@ import ( "net/url" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" @@ -28,7 +29,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/randgen" "github.com/cockroachdb/cockroach/pkg/sql/sem/eval" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -91,8 +91,7 @@ func BenchmarkTCPHLineItem(b *testing.B) { defer log.Scope(b).Close(b) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, _, kvdb := serverutils.StartServer(b, params) + s, _, kvdb := serverutils.StartServer(b, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) url, cleanup := sqlutils.PGUrl(b, s.AdvSQLAddr(), "copytest", url.User(username.RootUser)) diff --git a/pkg/sql/comment_on_column_test.go b/pkg/sql/comment_on_column_test.go index 75f2b84cdaa6..ed565fef4ac1 100644 --- a/pkg/sql/comment_on_column_test.go +++ b/pkg/sql/comment_on_column_test.go @@ -16,7 +16,6 @@ import ( "fmt" "testing" - "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" @@ -223,7 +222,7 @@ func runCommentOnTests(t *testing.T, testFunc func(db *gosql.DB)) { `SET use_declarative_schema_changer = 'off'`, } { func() { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) _, err := db.Exec(setupQuery) diff --git a/pkg/sql/conn_executor_test.go b/pkg/sql/conn_executor_test.go index 09d608bc83fc..3a8d6cba26ab 100644 --- a/pkg/sql/conn_executor_test.go +++ b/pkg/sql/conn_executor_test.go @@ -43,7 +43,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sqlliveness" "github.com/cockroachdb/cockroach/pkg/sql/sqlliveness/sqllivenesstestutils" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/pgtest" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -123,7 +122,7 @@ func TestSessionFinishRollsBackTxn(t *testing.T) { defer log.Scope(t).Close(t) aborter := NewTxnAborter() defer aborter.Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, mainDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -417,7 +416,7 @@ func TestHalloweenProblemAvoidance(t *testing.T) { defer mutations.ResetMaxBatchSizeForTests() numRows := smallerKvBatchSize + smallerInsertBatchSize + 10 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Insecure = true params.Knobs.DistSQL = &execinfra.TestingKnobs{ TableReaderBatchBytesLimit: 10, @@ -471,7 +470,7 @@ func TestAppNameStatisticsInitialization(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Insecure = true s := serverutils.StartServerOnly(t, params) diff --git a/pkg/sql/contention/txnidcache/BUILD.bazel b/pkg/sql/contention/txnidcache/BUILD.bazel index 4ad7f85b5c8d..37ad5ff8bdba 100644 --- a/pkg/sql/contention/txnidcache/BUILD.bazel +++ b/pkg/sql/contention/txnidcache/BUILD.bazel @@ -38,6 +38,8 @@ go_test( data = glob(["testdata/**"]), embed = [":txnidcache"], deps = [ + "//pkg/base", + "//pkg/ccl", "//pkg/kv", "//pkg/security/securityassets", "//pkg/security/securitytest", @@ -47,7 +49,6 @@ go_test( "//pkg/sql/appstatspb", "//pkg/sql/contentionpb", "//pkg/sql/sessiondata", - "//pkg/sql/tests", "//pkg/testutils", "//pkg/testutils/datapathutils", "//pkg/testutils/serverutils", diff --git a/pkg/sql/contention/txnidcache/main_test.go b/pkg/sql/contention/txnidcache/main_test.go index 52d48b32e0b7..5ea65f49c638 100644 --- a/pkg/sql/contention/txnidcache/main_test.go +++ b/pkg/sql/contention/txnidcache/main_test.go @@ -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" @@ -25,5 +26,6 @@ func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/contention/txnidcache/txn_id_cache_test.go b/pkg/sql/contention/txnidcache/txn_id_cache_test.go index fdd8695aa56a..7c2a8eb5e3bb 100644 --- a/pkg/sql/contention/txnidcache/txn_id_cache_test.go +++ b/pkg/sql/contention/txnidcache/txn_id_cache_test.go @@ -17,6 +17,7 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql" @@ -24,7 +25,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/contention/txnidcache" "github.com/cockroachdb/cockroach/pkg/sql/contentionpb" "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" @@ -43,8 +43,6 @@ func TestTransactionIDCache(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - appName := "txnIDCacheTest" expectedTxnIDToUUIDMapping := make(map[uuid.UUID]appstatspb.TransactionFingerprintID) injector := runtimeHookInjector{} @@ -59,15 +57,13 @@ func TestTransactionIDCache(t *testing.T) { } }) + var params base.TestServerArgs params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ BeforeTxnStatsRecorded: injector.hook, } - - testServer, sqlConn, kvDB := serverutils.StartServer(t, params) - defer func() { - require.NoError(t, sqlConn.Close()) - testServer.Stopper().Stop(ctx) - }() + srv, sqlConn, kvDB := serverutils.StartServer(t, params) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() testConn := sqlutils.MakeSQLRunner(sqlConn) @@ -135,7 +131,7 @@ func TestTransactionIDCache(t *testing.T) { } } - ie := testServer.InternalExecutor().(*sql.InternalExecutor) + ie := s.InternalExecutor().(*sql.InternalExecutor) for _, tc := range testCases { // Send statements one by one since internal executor doesn't support @@ -171,7 +167,7 @@ func TestTransactionIDCache(t *testing.T) { expectedTxnIDCacheSize := len(testCases)*2 + 1 - 3 require.Equal(t, expectedTxnIDCacheSize, len(expectedTxnIDToUUIDMapping)) - sqlServer := testServer.SQLServer().(*sql.Server) + sqlServer := s.SQLServer().(*sql.Server) txnIDCache := sqlServer.GetTxnIDCache() txnIDCache.DrainWriteBuffer() diff --git a/pkg/sql/copy/BUILD.bazel b/pkg/sql/copy/BUILD.bazel index e228a6d82b66..8376f40c60d9 100644 --- a/pkg/sql/copy/BUILD.bazel +++ b/pkg/sql/copy/BUILD.bazel @@ -12,8 +12,8 @@ go_test( data = glob(["testdata/**"]), deps = [ "//pkg/base", + "//pkg/ccl", "//pkg/cli/clisqlclient", - "//pkg/keys", "//pkg/kv/kvpb", "//pkg/security/securityassets", "//pkg/security/securitytest", @@ -27,7 +27,6 @@ go_test( "//pkg/sql/randgen", "//pkg/sql/sem/tree", "//pkg/sql/sqltestutils", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/testutils", "//pkg/testutils/datapathutils", diff --git a/pkg/sql/copy/copy_in_test.go b/pkg/sql/copy/copy_in_test.go index 6a08f095baa0..487feba6e7b9 100644 --- a/pkg/sql/copy/copy_in_test.go +++ b/pkg/sql/copy/copy_in_test.go @@ -31,7 +31,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/randgen" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sqltestutils" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -51,8 +50,7 @@ func TestCopyFromNullInfNaN(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := db.Exec(` @@ -152,8 +150,7 @@ func TestCopyFromRandom(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := db.Exec(` @@ -307,10 +304,10 @@ func TestCopyFromBinary(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) sqlDB := sqlutils.MakeSQLRunner(db) - defer s.Stopper().Stop(ctx) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() pgURL, cleanupGoDB := sqlutils.PGUrl( t, s.AdvSQLAddr(), "StartServer" /* prefix */, url.User(username.RootUser)) @@ -374,8 +371,7 @@ func TestCopyFromError(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := db.Exec(` @@ -502,7 +498,7 @@ func TestCopyFromRetries(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs var attemptNumber int params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ BeforeCopyFromInsert: func() error { @@ -510,8 +506,9 @@ func TestCopyFromRetries(t *testing.T) { return tc.hook(attemptNumber) }, } - s, db, _ := serverutils.StartServer(t, params) - defer s.Stopper().Stop(context.Background()) + srv, db, _ := serverutils.StartServer(t, params) + defer srv.Stopper().Stop(context.Background()) + s := srv.ApplicationLayer() _, err := db.Exec( `CREATE TABLE t ( @@ -575,8 +572,7 @@ func TestCopyTransaction(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := db.Exec(` @@ -629,8 +625,7 @@ func TestCopyFromFKCheck(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) db.SetMaxOpenConns(1) @@ -675,10 +670,10 @@ func TestCopyInReleasesLeases(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() tdb := sqlutils.MakeSQLRunner(db) - defer s.Stopper().Stop(ctx) tdb.Exec(t, `CREATE TABLE t (k INT8 PRIMARY KEY)`) tdb.Exec(t, `CREATE USER foo WITH PASSWORD 'testabc'`) tdb.Exec(t, `GRANT admin TO foo`) @@ -720,8 +715,7 @@ func TestMessageSizeTooBig(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s := serverutils.StartServerOnly(t, params) + s := serverutils.StartServerOnly(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) url, cleanup := sqlutils.PGUrl(t, s.AdvSQLAddr(), "copytest", url.User(username.RootUser)) diff --git a/pkg/sql/copy/copy_out_test.go b/pkg/sql/copy/copy_out_test.go index 1c04ce4237de..60d9fd462500 100644 --- a/pkg/sql/copy/copy_out_test.go +++ b/pkg/sql/copy/copy_out_test.go @@ -23,7 +23,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/randgen" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -42,10 +41,9 @@ func TestCopyOutTransaction(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) - defer s.Stopper().Stop(ctx) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() _, err := db.Exec(` CREATE TABLE t ( @@ -90,9 +88,9 @@ func TestCopyOutRandom(t *testing.T) { const numRows = 100 ctx := context.Background() - - tc := serverutils.StartNewTestCluster(t, 1, base.TestClusterArgs{}) - defer tc.Stopper().Stop(ctx) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() colNames := []string{"id"} colTypes := []*types.T{types.Int} @@ -106,7 +104,7 @@ func TestCopyOutRandom(t *testing.T) { rng := randutil.NewTestRandWithSeed(0) sqlutils.CreateTable( - t, tc.ServerConn(0), "t", + t, db, "t", colStr, numRows, func(row int) []tree.Datum { @@ -122,7 +120,6 @@ func TestCopyOutRandom(t *testing.T) { // Use pgx for this next bit as it allows selecting rows by raw values. // Furthermore, it handles CopyTo! - s := tc.Server(0) pgURL, cleanupGoDB, err := sqlutils.PGUrlE( s.AdvSQLAddr(), "StartServer", /* prefix */ diff --git a/pkg/sql/copy/copy_test.go b/pkg/sql/copy/copy_test.go index e702380c39ac..fcffd3dc0464 100644 --- a/pkg/sql/copy/copy_test.go +++ b/pkg/sql/copy/copy_test.go @@ -28,7 +28,6 @@ import ( "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" - "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/security/username" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql" @@ -37,7 +36,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/randgen" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" @@ -554,7 +552,7 @@ func TestLargeDynamicRows(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs var batchNumber int params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ BeforeCopyFromInsert: func() error { @@ -619,8 +617,7 @@ func TestTinyRows(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s := serverutils.StartServerOnly(t, params) + s := serverutils.StartServerOnly(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) url, cleanup := sqlutils.PGUrl(t, s.AdvSQLAddr(), "copytest", url.User(username.RootUser)) @@ -675,8 +672,9 @@ func TestLargeCopy(t *testing.T) { skip.UnderRace(t) ctx := context.Background() - s, _, kvdb := serverutils.StartServer(t, base.TestServerArgs{}) - defer s.Stopper().Stop(ctx) + srv, _, kvdb := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() url, cleanup := sqlutils.PGUrl(t, s.AdvSQLAddr(), "copytest", url.User(username.RootUser)) defer cleanup() @@ -686,7 +684,7 @@ func TestLargeCopy(t *testing.T) { err := conn.Exec(ctx, lineitemSchemaMunged) require.NoError(t, err) - desc := desctestutils.TestingGetTableDescriptor(kvdb, keys.SystemSQLCodec, "defaultdb", "public", "lineitem") + desc := desctestutils.TestingGetPublicTableDescriptor(kvdb, s.Codec(), "defaultdb", "lineitem") require.NotNil(t, desc, "Failed to lookup descriptor") err = conn.Exec(ctx, "SET copy_from_atomic_enabled = false") diff --git a/pkg/sql/copy/main_test.go b/pkg/sql/copy/main_test.go index 98fdcb951d2b..03babf6b43c2 100644 --- a/pkg/sql/copy/main_test.go +++ b/pkg/sql/copy/main_test.go @@ -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" @@ -27,5 +28,6 @@ func TestMain(m *testing.M) { randutil.SeedForTests() serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/copy_test.go b/pkg/sql/copy_test.go index 215e3d4a66f8..ef943a2ca710 100644 --- a/pkg/sql/copy_test.go +++ b/pkg/sql/copy_test.go @@ -17,8 +17,8 @@ import ( "net/url" "testing" + "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" @@ -42,8 +42,7 @@ func TestCopyLogging(t *testing.T) { {`SET CLUSTER SETTING sql.log.admin_audit.enabled = true`}, } { t.Run(strings[0], func(t *testing.T) { - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) _, err := db.Exec(`CREATE TABLE t (i INT PRIMARY KEY);`) @@ -70,7 +69,7 @@ func TestCopyLogging(t *testing.T) { // We have to start a new connection every time to exercise all possible paths. t.Run("success during COPY FROM", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { @@ -102,7 +101,7 @@ func TestCopyLogging(t *testing.T) { }) t.Run("error in statement", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { @@ -114,7 +113,7 @@ func TestCopyLogging(t *testing.T) { }) t.Run("error during COPY FROM", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { @@ -130,7 +129,7 @@ func TestCopyLogging(t *testing.T) { }) t.Run("error in statement during COPY FROM", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { @@ -142,7 +141,7 @@ func TestCopyLogging(t *testing.T) { }) t.Run("error during insert phase of COPY FROM", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { @@ -171,7 +170,7 @@ func TestCopyLogging(t *testing.T) { }) t.Run("error during copy during COPY FROM", func(t *testing.T) { - db := s.SQLConn(t, params.UseDatabase) + db := s.SQLConn(t, "") txn, err := db.Begin() require.NoError(t, err) { diff --git a/pkg/sql/crdb_internal_test.go b/pkg/sql/crdb_internal_test.go index e15d2463c7bd..9c5037c80247 100644 --- a/pkg/sql/crdb_internal_test.go +++ b/pkg/sql/crdb_internal_test.go @@ -56,7 +56,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/eval" "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/storage/enginepb" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -85,7 +84,7 @@ func TestGetAllNamesInternal(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, _ /* sqlDB */, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -168,7 +167,8 @@ func TestRangeLocalityBasedOnNodeIDs(t *testing.T) { func TestGossipAlertsTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + + params, _ := createTestServerParams() s := serverutils.StartServerOnly(t, params) defer s.Stopper().Stop(context.Background()) ctx := context.Background() @@ -213,7 +213,7 @@ func TestOldBitColumnMetadata(t *testing.T) { defer lease.TestingDisableTableLeases()() ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -434,7 +434,7 @@ func TestInvalidObjects(t *testing.T) { defer lease.TestingDisableTableLeases()() ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ Store: &kvserver.StoreTestingKnobs{ DisableMergeQueue: true, diff --git a/pkg/sql/create_function_test.go b/pkg/sql/create_function_test.go index 0bc32bc4433c..315fe9668ffa 100644 --- a/pkg/sql/create_function_test.go +++ b/pkg/sql/create_function_test.go @@ -26,7 +26,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "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" @@ -154,7 +153,7 @@ func TestVersionGatingUDFInCheckConstraints(t *testing.T) { defer leaktest.AfterTest(t)() t.Run("new_schema_changer_version_enabled", func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Override binary version to be older. params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), @@ -171,7 +170,7 @@ func TestVersionGatingUDFInCheckConstraints(t *testing.T) { }) t.Run("new_schema_changer_version_disabled", func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Override binary version to be older. params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), @@ -196,7 +195,7 @@ func TestVersionGatingUDFInColumnDefault(t *testing.T) { defer leaktest.AfterTest(t)() t.Run("new_schema_changer_version_enabled", func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Override binary version to be older. params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), @@ -215,7 +214,7 @@ func TestVersionGatingUDFInColumnDefault(t *testing.T) { }) t.Run("new_schema_changer_version_disabled", func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Override binary version to be older. params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), diff --git a/pkg/sql/create_test.go b/pkg/sql/create_test.go index a22259c1c6c7..76e655228612 100644 --- a/pkg/sql/create_test.go +++ b/pkg/sql/create_test.go @@ -26,7 +26,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descidgen" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" - "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" @@ -252,7 +251,7 @@ func TestParallelCreateConflictingTables(t *testing.T) { func TestTableReadErrorsBeforeTableCreation(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/delete_preserving_index_test.go b/pkg/sql/delete_preserving_index_test.go index b25393bb00f3..f9475c41033e 100644 --- a/pkg/sql/delete_preserving_index_test.go +++ b/pkg/sql/delete_preserving_index_test.go @@ -44,7 +44,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/eval" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/ctxgroup" "github.com/cockroachdb/cockroach/pkg/util/intsets" @@ -64,7 +63,7 @@ import ( func TestDeletePreservingIndexEncoding(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() mergeFinished := make(chan struct{}) completeSchemaChange := make(chan struct{}) errorChan := make(chan error, 1) @@ -254,7 +253,7 @@ func TestDeletePreservingIndexEncodingUsesNormalDeletesInDeleteOnly(t *testing.T // so disable leases on tables. defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) @@ -318,7 +317,7 @@ func TestDeletePreservingIndexEncodingWithEmptyValues(t *testing.T) { // so disable leases on tables. defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) setupSQL := ` @@ -519,7 +518,7 @@ func TestMergeProcessor(t *testing.T) { defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() type TestCase struct { name string diff --git a/pkg/sql/descriptor_mutation_test.go b/pkg/sql/descriptor_mutation_test.go index 43cce3574653..ca52c30fc540 100644 --- a/pkg/sql/descriptor_mutation_test.go +++ b/pkg/sql/descriptor_mutation_test.go @@ -27,7 +27,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease" "github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" - "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" @@ -173,7 +172,7 @@ func TestUpsertWithColumnMutationAndNotNullDefault(t *testing.T) { // so disable leases on tables. defer lease.TestingDisableTableLeases()() // Disable external processing of mutations. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) ctx := context.Background() defer server.Stopper().Stop(ctx) @@ -234,7 +233,7 @@ func TestOperationsWithColumnMutation(t *testing.T) { defer lease.TestingDisableTableLeases()() // Disable external processing of mutations. ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(ctx) sqlRunner := sqlutils.MakeSQLRunner(sqlDB) @@ -500,7 +499,7 @@ func TestOperationsWithIndexMutation(t *testing.T) { // The descriptor changes made must have an immediate effect. defer lease.TestingDisableTableLeases()() // Disable external processing of mutations. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) sqlRunner := sqlutils.MakeSQLRunner(sqlDB) @@ -667,7 +666,7 @@ func TestOperationsWithColumnAndIndexMutation(t *testing.T) { // The descriptor changes made must have an immediate effect // so disable leases on tables. defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) ctx := context.Background() defer server.Stopper().Stop(ctx) @@ -883,7 +882,7 @@ func TestSchemaChangeCommandsWithPendingMutations(t *testing.T) { // so disable leases on tables. defer lease.TestingDisableTableLeases()() // Disable external processing of mutations. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ SchemaChangeJobNoOp: func() bool { @@ -1103,7 +1102,7 @@ func TestTableMutationQueue(t *testing.T) { defer log.Scope(t).Close(t) // Disable synchronous and asynchronous schema change processing so that // the mutations get queued up. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ SchemaChangeJobNoOp: func() bool { @@ -1219,7 +1218,7 @@ func TestAddingFKs(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/distsql_plan_changefeed_test.go b/pkg/sql/distsql_plan_changefeed_test.go index 7a95e5f5a183..e46c7223a33d 100644 --- a/pkg/sql/distsql_plan_changefeed_test.go +++ b/pkg/sql/distsql_plan_changefeed_test.go @@ -33,7 +33,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/rowenc" "github.com/cockroachdb/cockroach/pkg/sql/rowenc/keyside" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -56,8 +55,7 @@ func TestChangefeedLogicalPlan(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()) defer tree.TestingEnableFamilyIndexHint()() @@ -454,8 +452,7 @@ func TestChangefeedStreamsResults(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()) sqlDB := sqlutils.MakeSQLRunner(db) diff --git a/pkg/sql/drop_test.go b/pkg/sql/drop_test.go index 592cc2ddd99c..177436448b09 100644 --- a/pkg/sql/drop_test.go +++ b/pkg/sql/drop_test.go @@ -107,7 +107,7 @@ func descExists(sqlDB *gosql.DB, exists bool, id descpb.ID) error { func TestDropDatabase(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() ctx, cancel := context.WithCancel(context.Background()) params.Knobs.GCJob = &sql.GCJobTestingKnobs{ RunBeforeResume: func(jobID jobspb.JobID) error { @@ -267,7 +267,7 @@ CREATE DATABASE t; func TestDropDatabaseDeleteData(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Speed up mvcc queue scan. params.ScanMaxIdleTime = time.Millisecond @@ -408,7 +408,7 @@ func TestDropIndex(t *testing.T) { defer log.Scope(t).Close(t) const chunkSize = 200 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ BackfillChunkSize: chunkSize, @@ -498,7 +498,7 @@ func TestDropIndexWithZoneConfigOSS(t *testing.T) { const chunkSize = 200 const numRows = 2*chunkSize + 1 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{BackfillChunkSize: chunkSize}, } @@ -561,7 +561,7 @@ func TestDropTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() ctx, cancel := context.WithCancel(context.Background()) params.Knobs.GCJob = &sql.GCJobTestingKnobs{ RunBeforeResume: func(jobID jobspb.JobID) error { @@ -661,7 +661,7 @@ func TestDropTable(t *testing.T) { func TestDropTableDeleteData(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Speed up mvcc queue scan. params.ScanMaxIdleTime = time.Millisecond @@ -797,7 +797,7 @@ func TestDropTableWhileUpgradingFormat(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.ScanMaxIdleTime = time.Millisecond s, sqlDBRaw, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -866,7 +866,7 @@ func TestDropTableWhileUpgradingFormat(t *testing.T) { func TestDropTableInTxn(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -903,7 +903,7 @@ CREATE TABLE t.kv (k CHAR PRIMARY KEY, v CHAR); func TestDropAndCreateTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.UseDatabase = "test" s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -947,7 +947,7 @@ func TestCommandsWhileTableBeingDropped(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Block schema changers so that the table we're about to DROP is not // actually dropped; it will be left in the "deleted" state. params.Knobs = base.TestingKnobs{ @@ -1139,7 +1139,7 @@ func TestDropIndexOnHashShardedIndexWithStoredShardColumn(t *testing.T) { // Start a test server and connect to it with notice handler (so we can get and check notices from running queries). ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s := serverutils.StartServerOnly(t, params) defer s.Stopper().Stop(ctx) url, cleanup := sqlutils.PGUrl(t, s.AdvSQLAddr(), t.Name(), url.User(username.RootUser)) @@ -1222,7 +1222,7 @@ func TestDropIndexOnHashShardedIndexWithStoredShardColumn(t *testing.T) { func TestDropDatabaseWithForeignKeys(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1278,7 +1278,7 @@ ORDER BY func TestDropPhysicalTableGC(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/err_count_test.go b/pkg/sql/err_count_test.go index 4ebad09768b3..e1f28fa95c54 100644 --- a/pkg/sql/err_count_test.go +++ b/pkg/sql/err_count_test.go @@ -17,7 +17,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/server/telemetry" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" - "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" @@ -31,7 +30,7 @@ func TestErrorCounts(t *testing.T) { telemetry.GetFeatureCounts(telemetry.Raw, telemetry.ResetCounts) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -71,7 +70,7 @@ func TestUnimplementedCounts(t *testing.T) { telemetry.GetFeatureCounts(telemetry.Raw, telemetry.ResetCounts) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -101,7 +100,7 @@ func TestTransactionRetryErrorCounts(t *testing.T) { // in pgwire (pgwire.convertToErrWithPGCode). Make sure we're // reporting errors at a level that allows this code to be recorded. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/explain_test.go b/pkg/sql/explain_test.go index 07f656e5ef60..e4443fa928c7 100644 --- a/pkg/sql/explain_test.go +++ b/pkg/sql/explain_test.go @@ -519,7 +519,7 @@ func TestExplainRedact(t *testing.T) { rng, seed := randutil.NewTestRand() t.Log("seed:", seed) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) defer sqlDB.Close() diff --git a/pkg/sql/flowinfra/BUILD.bazel b/pkg/sql/flowinfra/BUILD.bazel index b725c428fa2f..c75b64dc4a9b 100644 --- a/pkg/sql/flowinfra/BUILD.bazel +++ b/pkg/sql/flowinfra/BUILD.bazel @@ -73,7 +73,6 @@ go_test( "//pkg/base", "//pkg/ccl/kvccl/kvtenantccl", "//pkg/gossip", - "//pkg/keys", "//pkg/kv", "//pkg/kv/kvpb", "//pkg/kv/kvserver", @@ -102,7 +101,6 @@ go_test( "//pkg/sql/sem/tree", "//pkg/sql/sessiondatapb", "//pkg/sql/sqlstats", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/testutils", "//pkg/testutils/distsqlutils", diff --git a/pkg/sql/flowinfra/cluster_test.go b/pkg/sql/flowinfra/cluster_test.go index 2355c56bd7fa..c5d43c0a6969 100644 --- a/pkg/sql/flowinfra/cluster_test.go +++ b/pkg/sql/flowinfra/cluster_test.go @@ -20,7 +20,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" _ "github.com/cockroachdb/cockroach/pkg/ccl/kvccl/kvtenantccl" - "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/kv/kvpb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" @@ -37,12 +36,10 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/rowenc" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "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/encoding" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -53,14 +50,13 @@ import ( func runTestClusterFlow( t *testing.T, - codec keys.SQLCodec, - kvDB *kv.DB, servers []serverutils.ApplicationLayerInterface, conns []*gosql.DB, clients []execinfrapb.DistSQLClient, ) { ctx := context.Background() const numRows = 100 + kvDB, codec := servers[0].DB(), servers[0].Codec() sumDigitsFn := func(row int) tree.Datum { sum := 0 @@ -263,49 +259,45 @@ func TestClusterFlow(t *testing.T) { const numNodes = 3 args := base.TestClusterArgs{ReplicationMode: base.ReplicationManual} - tci := serverutils.StartNewTestCluster(t, numNodes, args) - tc := tci.(*testcluster.TestCluster) + tc := serverutils.StartNewTestCluster(t, numNodes, args) defer tc.Stopper().Stop(context.Background()) servers := make([]serverutils.ApplicationLayerInterface, numNodes) conns := make([]*gosql.DB, numNodes) clients := make([]execinfrapb.DistSQLClient, numNodes) for i := 0; i < numNodes; i++ { - s := tc.Server(i) + s := tc.Server(i).ApplicationLayer() servers[i] = s - conns[i] = tc.ServerConn(i) + conns[i] = s.SQLConn(t, "") conn := s.RPCClientConn(t, username.RootUserName()) clients[i] = execinfrapb.NewDistSQLClient(conn) } - runTestClusterFlow(t, keys.SystemSQLCodec, tc.Server(0).DB(), servers, conns, clients) + runTestClusterFlow(t, servers, conns, clients) } func TestTenantClusterFlow(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) + ctx := context.Background() const numPods = 3 - serverParams, _ := tests.CreateTestServerParams() - args := base.TestClusterArgs{ReplicationMode: base.ReplicationManual, ServerArgs: serverParams} - tci := serverutils.StartNewTestCluster(t, 1, args) - tc := tci.(*testcluster.TestCluster) - defer tc.Stopper().Stop(context.Background()) + args := base.TestClusterArgs{ReplicationMode: base.ReplicationManual} + args.ServerArgs.DefaultTestTenant = base.TestControlsTenantsExplicitly + tc := serverutils.StartNewTestCluster(t, 1, args) + defer tc.Stopper().Stop(ctx) - testingKnobs := base.TestingKnobs{ - SQLStatsKnobs: &sqlstats.TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", - }, - } pods := make([]serverutils.ApplicationLayerInterface, numPods) podConns := make([]*gosql.DB, numPods) clients := make([]execinfrapb.DistSQLClient, numPods) tenantID := serverutils.TestTenantID() for i := 0; i < numPods; i++ { - pods[i], podConns[i] = serverutils.StartTenant(t, tci.Server(0), base.TestTenantArgs{ - TenantID: tenantID, - TestingKnobs: testingKnobs, + pods[i], podConns[i] = serverutils.StartTenant(t, tc.Server(0), base.TestTenantArgs{ + TenantID: tenantID, + TestingKnobs: base.TestingKnobs{ + SQLStatsKnobs: sqlstats.CreateTestingKnobs(), + }, }) defer podConns[i].Close() pod := pods[i] @@ -316,7 +308,7 @@ func TestTenantClusterFlow(t *testing.T) { clients[i] = execinfrapb.NewDistSQLClient(conn) } - runTestClusterFlow(t, keys.MakeSQLCodec(tenantID), tc.Server(0).DB(), pods, podConns, clients) + runTestClusterFlow(t, pods, podConns, clients) } // TestLimitedBufferingDeadlock sets up a scenario which leads to deadlock if diff --git a/pkg/sql/flowinfra/server_test.go b/pkg/sql/flowinfra/server_test.go index 9cf3eebb030d..5ffbb81aea3f 100644 --- a/pkg/sql/flowinfra/server_test.go +++ b/pkg/sql/flowinfra/server_test.go @@ -17,7 +17,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/gossip" - "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/security/username" @@ -43,8 +42,9 @@ func TestServer(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) - defer s.Stopper().Stop(ctx) + srv, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() conn := s.RPCClientConn(t, username.RootUserName()) r := sqlutils.MakeSQLRunner(sqlDB) @@ -53,20 +53,20 @@ func TestServer(t *testing.T) { r.Exec(t, `CREATE TABLE test.t (a INT PRIMARY KEY, b INT)`) r.Exec(t, `INSERT INTO test.t VALUES (1, 10), (2, 20), (3, 30)`) - td := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "test", "t") + td := desctestutils.TestingGetPublicTableDescriptor(kvDB, s.Codec(), "test", "t") ts := execinfrapb.TableReaderSpec{ Reverse: false, - Spans: []roachpb.Span{td.PrimaryIndexSpan(keys.SystemSQLCodec)}, + Spans: []roachpb.Span{td.PrimaryIndexSpan(s.Codec())}, } if err := rowenc.InitIndexFetchSpec( - &ts.FetchSpec, keys.SystemSQLCodec, td, td.GetPrimaryIndex(), + &ts.FetchSpec, s.Codec(), td, td.GetPrimaryIndex(), []descpb.ColumnID{1, 2}, // a b ); err != nil { t.Fatal(err) } - txn := kv.NewTxn(ctx, kvDB, s.NodeID()) + txn := kv.NewTxn(ctx, kvDB, srv.NodeID()) leafInputState, err := txn.GetLeafTxnInputState(ctx) if err != nil { t.Fatal(err) @@ -163,7 +163,7 @@ func TestDistSQLServerGossipsVersion(t *testing.T) { // then run to completion. The result rows are returned. All metadata except for // errors is ignored. func runLocalFlow( - ctx context.Context, s serverutils.TestServerInterface, req *execinfrapb.SetupFlowRequest, + ctx context.Context, s serverutils.ApplicationLayerInterface, req *execinfrapb.SetupFlowRequest, ) (rowenc.EncDatumRows, error) { evalCtx := eval.MakeTestingEvalContext(s.ClusterSettings()) defer evalCtx.Stop(ctx) diff --git a/pkg/sql/gcjob_test/BUILD.bazel b/pkg/sql/gcjob_test/BUILD.bazel index 8521a3998504..bf6f408446bc 100644 --- a/pkg/sql/gcjob_test/BUILD.bazel +++ b/pkg/sql/gcjob_test/BUILD.bazel @@ -33,7 +33,6 @@ go_test( "//pkg/sql/gcjob", "//pkg/sql/isql", "//pkg/sql/sem/catid", - "//pkg/sql/tests", "//pkg/storage", "//pkg/testutils", "//pkg/testutils/jobutils", diff --git a/pkg/sql/gcjob_test/gc_job_test.go b/pkg/sql/gcjob_test/gc_job_test.go index 70c92a7e54f7..d0da2e9240c4 100644 --- a/pkg/sql/gcjob_test/gc_job_test.go +++ b/pkg/sql/gcjob_test/gc_job_test.go @@ -40,7 +40,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/gcjob" "github.com/cockroachdb/cockroach/pkg/sql/isql" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/storage" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/jobutils" @@ -679,7 +678,9 @@ SELECT descriptor_id, index_id func TestLegacyIndexGCSucceedsWithMissingDescriptor(t *testing.T) { defer leaktest.AfterTest(t)() - params, _ := tests.CreateTestServerParams() + defer log.Scope(t).Close(t) + + var params base.TestServerArgs // Override binary version to be older. params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), diff --git a/pkg/sql/grant_revoke_test.go b/pkg/sql/grant_revoke_test.go index ffd6be5416a4..57e41a24eedb 100644 --- a/pkg/sql/grant_revoke_test.go +++ b/pkg/sql/grant_revoke_test.go @@ -20,7 +20,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "github.com/cockroachdb/cockroach/pkg/sql/privilege" - "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" @@ -34,7 +33,7 @@ import ( func TestNoOpGrant(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) tdb := sqlutils.MakeSQLRunner(sqlDB) @@ -155,7 +154,7 @@ func TestNoOpGrant(t *testing.T) { func TestNoOpRevoke(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) tdb := sqlutils.MakeSQLRunner(sqlDB) diff --git a/pkg/sql/grant_role_test.go b/pkg/sql/grant_role_test.go index 52d6c35115c3..1ef6e05a1e2e 100644 --- a/pkg/sql/grant_role_test.go +++ b/pkg/sql/grant_role_test.go @@ -16,7 +16,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" - "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" @@ -30,7 +29,7 @@ import ( func TestNoOpGrantRole(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) tdb := sqlutils.MakeSQLRunner(sqlDB) diff --git a/pkg/sql/idxrecommendations/BUILD.bazel b/pkg/sql/idxrecommendations/BUILD.bazel index de8e819a0380..9aae848114a5 100644 --- a/pkg/sql/idxrecommendations/BUILD.bazel +++ b/pkg/sql/idxrecommendations/BUILD.bazel @@ -27,11 +27,12 @@ go_test( args = ["-test.timeout=295s"], deps = [ ":idxrecommendations", + "//pkg/base", + "//pkg/ccl", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/server", "//pkg/sql/opt/indexrec", - "//pkg/sql/tests", "//pkg/testutils/serverutils", "//pkg/testutils/sqlutils", "//pkg/testutils/testcluster", diff --git a/pkg/sql/idxrecommendations/idx_recommendations_cache_test.go b/pkg/sql/idxrecommendations/idx_recommendations_cache_test.go index edeaee3a8dce..6a8370a93be0 100644 --- a/pkg/sql/idxrecommendations/idx_recommendations_cache_test.go +++ b/pkg/sql/idxrecommendations/idx_recommendations_cache_test.go @@ -14,9 +14,9 @@ import ( "context" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/sql/idxrecommendations" "github.com/cockroachdb/cockroach/pkg/sql/opt/indexrec" - "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" @@ -29,12 +29,8 @@ func TestIndexRecommendationsStats(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - testServer, sqlConn, _ := serverutils.StartServer(t, params) - defer func() { - require.NoError(t, sqlConn.Close()) - testServer.Stopper().Stop(ctx) - }() + testServer, sqlConn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer testServer.Stopper().Stop(ctx) testConn := sqlutils.MakeSQLRunner(sqlConn) testConn.Exec(t, "CREATE DATABASE idxrectest") diff --git a/pkg/sql/idxrecommendations/main_test.go b/pkg/sql/idxrecommendations/main_test.go index 709aa7334652..78159e9e3178 100644 --- a/pkg/sql/idxrecommendations/main_test.go +++ b/pkg/sql/idxrecommendations/main_test.go @@ -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" @@ -25,5 +26,6 @@ func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/index_mutation_test.go b/pkg/sql/index_mutation_test.go index aa887a501a01..960ee38696b9 100644 --- a/pkg/sql/index_mutation_test.go +++ b/pkg/sql/index_mutation_test.go @@ -24,7 +24,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease" "github.com/cockroachdb/cockroach/pkg/sql/sem/eval" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" @@ -43,7 +42,7 @@ func TestIndexMutationKVOps(t *testing.T) { defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Decrease the adopt loop interval so that retries happen quickly. params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() params.Knobs.SQLEvalContext = &eval.TestingKnobs{ diff --git a/pkg/sql/indexbackfiller_test.go b/pkg/sql/indexbackfiller_test.go index 25062ab23914..0c9d87366bf9 100644 --- a/pkg/sql/indexbackfiller_test.go +++ b/pkg/sql/indexbackfiller_test.go @@ -39,7 +39,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/rowenc" "github.com/cockroachdb/cockroach/pkg/sql/rowinfra" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -56,7 +55,7 @@ func TestIndexBackfiller(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() moveToTDelete := make(chan bool) moveToTWrite := make(chan bool) diff --git a/pkg/sql/internal_test.go b/pkg/sql/internal_test.go index 81bf029ee60c..4e3a032353b1 100644 --- a/pkg/sql/internal_test.go +++ b/pkg/sql/internal_test.go @@ -31,7 +31,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb" "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/util/leaktest" @@ -47,7 +46,7 @@ func TestInternalExecutor(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -130,7 +129,7 @@ func TestInternalFullTableScan(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -181,7 +180,7 @@ func TestInternalStmtFingerprintLimit(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -205,7 +204,7 @@ func TestQueryIsAdminWithNoTxn(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -252,7 +251,7 @@ func TestQueryHasRoleOptionWithNoTxn(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -313,7 +312,7 @@ func TestSessionBoundInternalExecutor(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -360,7 +359,7 @@ func TestInternalExecAppNameInitialization(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Insecure = true // sem will be fired every time pg_sleep(1337666) is called. @@ -539,7 +538,7 @@ func TestInternalExecutorPushDetectionInTxn(t *testing.T) { tt.serializable, tt.pushed, tt.refreshable) t.Run(name, func(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, _, db := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -725,7 +724,7 @@ func TestInternalExecutorEncountersRetry(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) diff --git a/pkg/sql/jobs_profiler_execution_details_test.go b/pkg/sql/jobs_profiler_execution_details_test.go index b1aad28aa0fe..60cc0c229837 100644 --- a/pkg/sql/jobs_profiler_execution_details_test.go +++ b/pkg/sql/jobs_profiler_execution_details_test.go @@ -33,7 +33,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/isql" "github.com/cockroachdb/cockroach/pkg/sql/physicalplan" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/jobutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -119,7 +118,7 @@ func TestJobsExecutionDetails(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, time.Minute*2) defer cancel() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() defer jobs.ResetConstructors()() s, sqlDB, _ := serverutils.StartServer(t, params) @@ -163,7 +162,7 @@ func TestReadWriteProfilerExecutionDetails(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, time.Minute*2) defer cancel() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() defer jobs.ResetConstructors()() s, sqlDB, _ := serverutils.StartServer(t, params) @@ -312,7 +311,7 @@ func TestListProfilerExecutionDetails(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, time.Minute*2) defer cancel() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() defer jobs.ResetConstructors()() s, sqlDB, _ := serverutils.StartServer(t, params) diff --git a/pkg/sql/logictest/logic.go b/pkg/sql/logictest/logic.go index 75cf03cad167..d40de49cbb7d 100644 --- a/pkg/sql/logictest/logic.go +++ b/pkg/sql/logictest/logic.go @@ -1361,9 +1361,7 @@ func (t *logicTest) newCluster( DeterministicExplain: true, UseTransactionalDescIDGenerator: true, } - knobs.SQLStatsKnobs = &sqlstats.TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } + knobs.SQLStatsKnobs = sqlstats.CreateTestingKnobs() if serverArgs.DeclarativeCorpusCollection && t.declarativeCorpusCollector != nil { knobs.SQLDeclarativeSchemaChanger = &scexec.TestingKnobs{ BeforeStage: t.declarativeCorpusCollector.GetBeforeStage(t.rootT.Name(), t.t()), diff --git a/pkg/sql/materialized_view_test.go b/pkg/sql/materialized_view_test.go index b270b8b58c00..267ba1145e21 100644 --- a/pkg/sql/materialized_view_test.go +++ b/pkg/sql/materialized_view_test.go @@ -19,7 +19,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "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" @@ -37,7 +36,7 @@ func TestMaterializedViewClearedAfterRefresh(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -104,7 +103,7 @@ func TestMaterializedViewRefreshVisibility(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() waitForCommit, waitToProceed, refreshDone := make(chan struct{}), make(chan struct{}), make(chan struct{}) params.Knobs = base.TestingKnobs{ @@ -152,7 +151,7 @@ func TestMaterializedViewCleansUpOnRefreshFailure(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Protects shouldError var mu syncutil.Mutex @@ -218,7 +217,7 @@ func TestDropMaterializedView(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlRaw, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) diff --git a/pkg/sql/metric_test.go b/pkg/sql/metric_test.go index 26b41892b244..3c94a0168193 100644 --- a/pkg/sql/metric_test.go +++ b/pkg/sql/metric_test.go @@ -21,7 +21,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease" - "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/util/leaktest" @@ -57,7 +56,7 @@ func TestQueryCounts(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLLeaseManager: &lease.ManagerTestingKnobs{ // Disable SELECT called for delete orphaned leases to keep @@ -178,7 +177,7 @@ func TestAbortCountConflictingWrites(t *testing.T) { defer log.Scope(t).Close(t) testutils.RunTrueAndFalse(t, "retry loop", func(t *testing.T, retry bool) { - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -283,7 +282,7 @@ func TestAbortCountConflictingWrites(t *testing.T) { func TestAbortCountErrorDuringTransaction(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -318,7 +317,7 @@ func TestSavepointMetrics(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/mutation_test.go b/pkg/sql/mutation_test.go index 5b07b0d07602..6b9ea7fb91e7 100644 --- a/pkg/sql/mutation_test.go +++ b/pkg/sql/mutation_test.go @@ -15,7 +15,6 @@ import ( gosql "database/sql" "testing" - "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/util/leaktest" @@ -30,7 +29,7 @@ func TestConstraintValidationBeforeBuffering(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/mvcc_backfiller_test.go b/pkg/sql/mvcc_backfiller_test.go index 1b573ce33a6d..031a549f54b2 100644 --- a/pkg/sql/mvcc_backfiller_test.go +++ b/pkg/sql/mvcc_backfiller_test.go @@ -37,7 +37,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scop" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan" "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/skip" @@ -66,7 +65,7 @@ func TestIndexBackfillMergeRetry(t *testing.T) { skip.UnderStressRace(t, "TODO(ssd) test times outs under race") skip.UnderRace(t, "TODO(ssd) test times outs under race") - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() writesPopulated := false var writesFn func() error @@ -183,7 +182,7 @@ func TestIndexBackfillFractionTracking(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const ( rowCount = 2000 @@ -291,7 +290,7 @@ func TestRaceWithIndexBackfillMerge(t *testing.T) { maxValue = 200 } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() initMergeNotification := func() chan struct{} { mu.Lock() defer mu.Unlock() @@ -487,7 +486,7 @@ func TestInvertedIndexMergeEveryStateWrite(t *testing.T) { var initialRows = 10000 rowIdx := 0 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var writeMore func() error params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -556,7 +555,7 @@ func TestIndexBackfillMergeTxnRetry(t *testing.T) { additionalRowsForMerge = 10 ) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ // Ensure that the temp index has work to do. @@ -743,7 +742,7 @@ func TestIndexMergeEveryChunkWrite(t *testing.T) { rowIdx := 0 mergeSerializeCh := make(chan struct{}, 1) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var writeMore func() error params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ @@ -849,7 +848,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v int);` // Wait for the beginning of the Merge step of the schema change. // Write data to the temp index and split it at the hazardous // points. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLDeclarativeSchemaChanger: &scexec.TestingKnobs{ BeforeStage: func(p scplan.Plan, stageIdx int) error { diff --git a/pkg/sql/pgrepl/BUILD.bazel b/pkg/sql/pgrepl/BUILD.bazel index 216710cec44b..d7d7a2f6f017 100644 --- a/pkg/sql/pgrepl/BUILD.bazel +++ b/pkg/sql/pgrepl/BUILD.bazel @@ -4,16 +4,17 @@ go_test( name = "pgrepl_test", srcs = [ "connect_test.go", - "pgrepl_test.go", + "main_test.go", ], args = ["-test.timeout=295s"], deps = [ + "//pkg/base", + "//pkg/ccl", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/security/username", "//pkg/server", "//pkg/sql/pgwire/pgcode", - "//pkg/sql/tests", "//pkg/testutils/serverutils", "//pkg/testutils/sqlutils", "//pkg/util/leaktest", diff --git a/pkg/sql/pgrepl/connect_test.go b/pkg/sql/pgrepl/connect_test.go index e0697fb5ab07..a2c93222a3ac 100644 --- a/pkg/sql/pgrepl/connect_test.go +++ b/pkg/sql/pgrepl/connect_test.go @@ -16,9 +16,9 @@ import ( "net/url" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/security/username" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" - "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" @@ -33,10 +33,9 @@ func TestReplicationConnect(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()) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(context.Background()) + s := srv.ApplicationLayer() sqlDB := sqlutils.MakeSQLRunner(db) diff --git a/pkg/sql/pgrepl/pgrepl_test.go b/pkg/sql/pgrepl/main_test.go similarity index 91% rename from pkg/sql/pgrepl/pgrepl_test.go rename to pkg/sql/pgrepl/main_test.go index 3a349949c804..2a10a35968b4 100644 --- a/pkg/sql/pgrepl/pgrepl_test.go +++ b/pkg/sql/pgrepl/main_test.go @@ -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" @@ -25,5 +26,6 @@ import ( func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) serverutils.InitTestServerFactory(server.TestServerFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/pgwire/BUILD.bazel b/pkg/sql/pgwire/BUILD.bazel index 7d9207651f2b..b939d9bb9653 100644 --- a/pkg/sql/pgwire/BUILD.bazel +++ b/pkg/sql/pgwire/BUILD.bazel @@ -138,7 +138,6 @@ go_test( "//pkg/sql/sem/tree", "//pkg/sql/sessiondata", "//pkg/sql/sessiondatapb", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/testutils", "//pkg/testutils/datapathutils", diff --git a/pkg/sql/pgwire/conn_test.go b/pkg/sql/pgwire/conn_test.go index 9d4f2cdaee78..25e4a9562d18 100644 --- a/pkg/sql/pgwire/conn_test.go +++ b/pkg/sql/pgwire/conn_test.go @@ -41,7 +41,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb" - "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" @@ -193,9 +192,8 @@ func TestConnMessageTooBig(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - srv, mainDB, _ := serverutils.StartServer(t, params) - defer srv.Stopper().Stop(context.Background()) + srv, mainDB, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) s := srv.ApplicationLayer() // Form a 1MB string. diff --git a/pkg/sql/pgwire/main_test.go b/pkg/sql/pgwire/main_test.go index f9b6a9948d29..0549a0d0cb11 100644 --- a/pkg/sql/pgwire/main_test.go +++ b/pkg/sql/pgwire/main_test.go @@ -23,11 +23,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/randutil" ) -func init() { - securityassets.SetLoader(securitytest.EmbeddedAssets) -} - func TestMain(m *testing.M) { + securityassets.SetLoader(securitytest.EmbeddedAssets) randutil.SeedForTests() serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) diff --git a/pkg/sql/privileged_accessor_test.go b/pkg/sql/privileged_accessor_test.go index 9824ba93dddb..935f5ba4296b 100644 --- a/pkg/sql/privileged_accessor_test.go +++ b/pkg/sql/privileged_accessor_test.go @@ -18,7 +18,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" - "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" @@ -32,7 +31,7 @@ func TestLookupNamespaceID(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) diff --git a/pkg/sql/rand_test.go b/pkg/sql/rand_test.go index a24cb7529f1f..69147a214b85 100644 --- a/pkg/sql/rand_test.go +++ b/pkg/sql/rand_test.go @@ -14,8 +14,8 @@ import ( "context" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/sql/randgen" - "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" @@ -25,8 +25,7 @@ func TestGenerateRandInterestingTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) // Ensure that we can create the random table. - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(context.Background()) if _, err := db.Exec("CREATE DATABASE d"); err != nil { t.Fatal(err) diff --git a/pkg/sql/run_control_test.go b/pkg/sql/run_control_test.go index b43d6e0c500a..9920d64c8e4b 100644 --- a/pkg/sql/run_control_test.go +++ b/pkg/sql/run_control_test.go @@ -31,7 +31,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descs" "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/skip" @@ -410,7 +409,7 @@ func TestCancelWithSubquery(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, conn, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/schema_changer_test.go b/pkg/sql/schema_changer_test.go index 77950e635f98..b1662a466fe7 100644 --- a/pkg/sql/schema_changer_test.go +++ b/pkg/sql/schema_changer_test.go @@ -51,7 +51,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/sqltestutils" "github.com/cockroachdb/cockroach/pkg/sql/stats" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/jobutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -90,7 +89,7 @@ func TestSchemaChangeProcess(t *testing.T) { // so disable leases on tables. defer lease.TestingDisableTableLeases()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -218,7 +217,7 @@ func TestAsyncSchemaChanger(t *testing.T) { defer lease.TestingDisableTableLeases()() // Disable synchronous schema change execution so the asynchronous schema // changer executes all schema changes. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -437,7 +436,7 @@ func TestRollbackOfAddingTable(t *testing.T) { var mu syncutil.Mutex shouldError := true - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeQueryBackfill: func() error { @@ -519,7 +518,7 @@ func TestUniqueViolationsAreCaught(t *testing.T) { readyToMerge := make(chan struct{}) startMerge := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -575,7 +574,7 @@ func TestRaceWithBackfill(t *testing.T) { maxValue = 200 } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() initBackfillNotification := func() chan struct{} { mu.Lock() defer mu.Unlock() @@ -755,7 +754,7 @@ func TestDropWhileBackfill(t *testing.T) { maxValue = 200 } ctx, cancel := context.WithCancel(context.Background()) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() notifyBackfill := func() { mu.Lock() defer mu.Unlock() @@ -887,7 +886,7 @@ func TestBackfillErrors(t *testing.T) { defer log.Scope(t).Close(t) const numNodes, chunkSize, maxValue = 5, 100, 4000 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() blockGC := make(chan struct{}) params.Knobs = base.TestingKnobs{ @@ -999,7 +998,7 @@ func TestAbortSchemaChangeBackfill(t *testing.T) { defer log.Scope(t).Close(t) var backfillNotification, commandsDone chan struct{} var dontAbortBackfill uint32 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const maxValue = 100 backfillCount := int64(0) retriedBackfill := int64(0) @@ -1279,7 +1278,7 @@ func dropIndexSchemaChange( func TestDropColumn(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1345,7 +1344,7 @@ func TestSchemaChangeRetry(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() currChunk := 0 seenSpan := roachpb.Span{} @@ -1438,7 +1437,7 @@ func TestSchemaChangeRetryOnVersionChange(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var upTableVersion func() const maxValue = 2000 currChunk := 0 @@ -1593,7 +1592,7 @@ func TestSchemaChangePurgeFailure(t *testing.T) { // currently implemented. Previously this test disabled the async schema // changer so that we don't retry the cleanup of the failed schema change // until a certain point in the test. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const chunkSize = 200 var enableAsyncSchemaChanges uint32 var attempts int32 @@ -1716,7 +1715,7 @@ func TestSchemaChangeFailureAfterCheckpointing(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) defer gcjob.SetSmallMaxGCIntervalForTest()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const chunkSize = 200 attempts := 0 // attempt 1: write two chunks of the column. @@ -1825,7 +1824,7 @@ func TestSchemaChangeReverseMutations(t *testing.T) { // correctly when run sequentially, which is not as interesting. The previous // comments are kept around to describe the intended results of the test, but // they don't reflect what's happening now. - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const chunkSize = 200 // Disable synchronous schema change processing so that the mutations get // processed asynchronously. @@ -2083,7 +2082,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v INT8); func TestParseSentinelValueWithNewColumnInSentinelFamily(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) @@ -2192,7 +2191,7 @@ CREATE TABLE t.test ( func TestAddColumnDuringColumnDrop(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() backfillNotification := make(chan struct{}) continueBackfillNotification := make(chan struct{}) params.Knobs = base.TestingKnobs{ @@ -2267,7 +2266,7 @@ func TestSchemaUniqueColumnDropFailure(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) waitUntilRevert := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const chunkSize = 200 attempts := 0 // DROP UNIQUE COLUMN is executed in two steps: drop index and drop column. @@ -2373,7 +2372,7 @@ ALTER TABLE t.test DROP column v`) func TestDropIndexNoRevert(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, _ := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) @@ -2410,7 +2409,7 @@ INSERT INTO t VALUES (1, 1, 1), (2, 2, 1); func TestOldRevertedDropIndexesAreIgnored(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var ( server serverutils.TestServerInterface @@ -2469,7 +2468,7 @@ func TestVisibilityDuringPrimaryKeyChange(t *testing.T) { ctx := context.Background() swapNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforePrimaryKeySwap: func() { @@ -2582,7 +2581,7 @@ func TestPrimaryKeyChangeWithPrecedingIndexCreation(t *testing.T) { <-continueNotification } } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ BackfillChunkSize: chunkSize, @@ -2682,7 +2681,7 @@ func TestSchemaChangeWhileExecutingPrimaryKeyChange(t *testing.T) { backfillNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(_ roachpb.Span) error { @@ -2757,7 +2756,7 @@ func TestPrimaryKeyChangeWithOperations(t *testing.T) { var mu syncutil.Mutex backfillNotification := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() initBackfillNotification := func() chan struct{} { mu.Lock() defer mu.Unlock() @@ -3022,7 +3021,7 @@ func TestPrimaryKeyChangeKVOps(t *testing.T) { waitBeforeContinuing := make(chan struct{}) var doOnce sync.Once - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(_ roachpb.Span) error { @@ -3253,7 +3252,7 @@ func TestPrimaryKeyChangeWithCancel(t *testing.T) { ctx := context.Background() var db *gosql.DB shouldCancel := true - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ BackfillChunkSize: chunkSize, @@ -3338,7 +3337,7 @@ func TestPrimaryKeyDropIndexNotCancelable(t *testing.T) { var shouldAttemptCancel syncutil.AtomicBool shouldAttemptCancel.Set(true) hasAttemptedCancel := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ GCJob: &sql.GCJobTestingKnobs{ RunBeforeResume: func(jobID jobspb.JobID) error { @@ -3392,7 +3391,7 @@ func TestMultiplePrimaryKeyChanges(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{}, // Decrease the adopt loop interval so that retries happen quickly. @@ -3437,7 +3436,7 @@ func TestGrantRevokeWhileIndexBackfill(t *testing.T) { backfillCompleteNotification := make(chan bool) continueSchemaChangeNotification := make(chan bool) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -3537,7 +3536,7 @@ func TestCRUDWhileColumnBackfill(t *testing.T) { backfillCompleteNotification := make(chan bool) continueSchemaChangeNotification := make(chan bool) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -3785,7 +3784,7 @@ func TestBackfillCompletesOnChunkBoundary(t *testing.T) { // a chunk boundary. const maxValue = 3*chunkSize - 1 ctx, cancel := context.WithCancel(context.Background()) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ BackfillChunkSize: chunkSize, @@ -3870,7 +3869,7 @@ func TestBackfillCompletesOnChunkBoundary(t *testing.T) { func TestSchemaChangeInTxn(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -3977,7 +3976,7 @@ INSERT INTO t.kv VALUES ('a', 'b'); func TestSecondaryIndexWithOldStoringEncoding(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() server, sqlDB, kvDB := serverutils.StartServer(t, params) defer server.Stopper().Stop(context.Background()) @@ -4098,7 +4097,7 @@ func TestSchemaChangeEvalContext(t *testing.T) { const numNodes = 3 const chunkSize = 200 const maxValue = 5000 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Disable asynchronous schema change execution. params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -4176,7 +4175,7 @@ func TestTruncateInternals(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) const maxValue = 2000 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Disable schema changes. blockGC := make(chan struct{}) params.Knobs = base.TestingKnobs{ @@ -4270,7 +4269,7 @@ func TestTruncateCompletion(t *testing.T) { defer gcjob.SetSmallMaxGCIntervalForTest()() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Decrease the adopt loop interval so that retries happen quickly. params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() @@ -4395,7 +4394,7 @@ func TestTruncateCompletion(t *testing.T) { func TestSchemaChangeErrorOnCommit(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -4447,7 +4446,7 @@ func TestIndexBackfillAfterGC(t *testing.T) { return nil } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -4500,7 +4499,7 @@ func TestAddComputedColumn(t *testing.T) { var db *gosql.DB done := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -4538,7 +4537,7 @@ func TestNoBackfillForVirtualColumn(t *testing.T) { defer log.Scope(t).Close(t) sawBackfill := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ DistSQL: &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -4571,7 +4570,7 @@ func TestNoBackfillForVirtualColumn(t *testing.T) { func TestSchemaChangeAfterCreateInTxn(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) codec := s.ApplicationLayer().Codec() @@ -4709,7 +4708,7 @@ func TestCancelSchemaChange(t *testing.T) { var sqlDB *sqlutils.SQLRunner var db *gosql.DB - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() doCancel := false var enableAsyncSchemaChanges uint32 params.Knobs = base.TestingKnobs{ @@ -4896,7 +4895,7 @@ func TestSchemaChangeRetryError(t *testing.T) { defer log.Scope(t).Close(t) const numNodes = 3 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() tc := serverutils.StartNewTestCluster(t, numNodes, base.TestClusterArgs{ @@ -4961,7 +4960,7 @@ func TestCancelSchemaChangeContext(t *testing.T) { notifyBackfill := make(chan struct{}) cancelSessionDone := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeBackfill: func() error { @@ -5040,7 +5039,7 @@ func TestSchemaChangeGRPCError(t *testing.T) { defer log.Scope(t).Close(t) const maxValue = 100 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() seenNodeUnavailable := false params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -5097,7 +5096,7 @@ func TestBlockedSchemaChange(t *testing.T) { notifyBackfill := make(chan struct{}) tableRenameDone := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeBackfill: func() error { @@ -5163,7 +5162,7 @@ func TestBlockedSchemaChange(t *testing.T) { func TestIndexBackfillValidation(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const maxValue = 1000 backfillCount := int64(0) var db *kv.DB @@ -5231,7 +5230,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v INT); func TestInvertedIndexBackfillValidation(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const maxValue = 1000 backfillCount := int64(0) var db *kv.DB @@ -5302,7 +5301,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v JSON); func TestMultipleIndexBackfills(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() const maxValue = 1000 params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -5416,7 +5415,7 @@ func TestCreateStatsAfterSchemaChange(t *testing.T) { func TestTableValidityWhileAddingFK(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() publishWriteNotification := make(chan struct{}) continuePublishWriteNotification := make(chan struct{}) @@ -5500,7 +5499,7 @@ SET use_declarative_schema_changer = off; func TestTableValidityWhileAddingUniqueConstraint(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() publishWriteNotification := make(chan struct{}) continuePublishWriteNotification := make(chan struct{}) @@ -5582,7 +5581,7 @@ SET use_declarative_schema_changer = off; func TestWritesWithChecksBeforeDefaultColumnBackfill(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() publishWriteNotification := make(chan struct{}) continuePublishWriteNotification := make(chan struct{}) @@ -5678,7 +5677,7 @@ SET use_declarative_schema_changer = off; func TestWritesWithChecksBeforeComputedColumnBackfill(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() publishWriteNotification := make(chan struct{}) continuePublishWriteNotification := make(chan struct{}) @@ -5778,7 +5777,7 @@ func TestIntentRaceWithIndexBackfill(t *testing.T) { const numNodes = 1 var maxValue = 2000 - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ BackfillChunkSize: 100, @@ -5911,7 +5910,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v INT); func TestSchemaChangeJobRunningStatusValidation(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var runBeforeConstraintValidation func() error params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -5959,7 +5958,7 @@ func TestFKReferencesAddedOnlyOnceOnRetry(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var runBeforeConstraintValidation func() error errorReturned := false params.Knobs = base.TestingKnobs{ @@ -6023,7 +6022,7 @@ func TestMultipleRevert(t *testing.T) { ranCancelCommand := false shouldRetryAfterReversingMutations := true - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var db *gosql.DB params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), @@ -6148,7 +6147,7 @@ SELECT usage_count t.Run("error-before-backfill", func(t *testing.T) { onFailOrCancelStarted := false injectedError := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeOnFailOrCancel: func(_ jobspb.JobID) error { @@ -6175,7 +6174,7 @@ SELECT usage_count t.Run("error-before-reversing-mutations", func(t *testing.T) { onFailOrCancelStarted := false injectedError := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeOnFailOrCancel: func(_ jobspb.JobID) error { @@ -6212,7 +6211,7 @@ func TestDropTableWhileSchemaChangeReverting(t *testing.T) { beforeOnFailOrCancelNotification := make(chan struct{}) // Closed when we're ready to continue with the schema change (rollback). continueNotification := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeOnFailOrCancel: func(_ jobspb.JobID) error { @@ -6312,7 +6311,7 @@ CREATE UNIQUE INDEX i ON t.test(v); t.Run("error-before-backfill", func(t *testing.T) { onFailOrCancelStarted := false injectedError := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeOnFailOrCancel: func(_ jobspb.JobID) error { @@ -6341,7 +6340,7 @@ CREATE UNIQUE INDEX i ON t.test(v); t.Run("error-before-reversing-mutations", func(t *testing.T) { onFailOrCancelStarted := false injectedError := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeOnFailOrCancel: func(_ jobspb.JobID) error { @@ -6375,7 +6374,7 @@ func TestPartialIndexBackfill(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -6414,7 +6413,7 @@ func TestAddingTableResolution(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ // Don't run the schema change to take the table out of the adding state. SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -6449,7 +6448,7 @@ func TestFailureToMarkCanceledReversalLeadsToCanceledStatus(t *testing.T) { ctx := context.Background() canProceed := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() jobCancellationsToFail := struct { syncutil.Mutex jobs map[jobspb.JobID]struct{} @@ -6546,7 +6545,7 @@ func TestCancelMultipleQueued(t *testing.T) { ctx := context.Background() canProceed := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeBackfill: func() error { @@ -6653,7 +6652,7 @@ func TestRollbackForeignKeyAddition(t *testing.T) { beforeBackfillNotification := make(chan struct{}) // Closed when we're ready to continue with the schema change. continueNotification := make(chan struct{}) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeBackfill: func() error { @@ -6758,7 +6757,7 @@ func TestRevertingJobsOnDatabasesAndSchemas(t *testing.T) { t.Run("failed due to injected error", func(t *testing.T) { var injectedError bool var s serverutils.TestServerInterface - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeResume: func(jobID jobspb.JobID) error { @@ -6843,7 +6842,7 @@ func TestRevertingJobsOnDatabasesAndSchemas(t *testing.T) { } var s serverutils.TestServerInterface - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeResume: func(jobID jobspb.JobID) error { @@ -6911,7 +6910,7 @@ func TestCheckConstraintDropAndColumn(t *testing.T) { delayNotify := make(chan struct{}) routineResults := make(chan error) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() var s serverutils.TestServerInterface params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -7085,7 +7084,7 @@ func TestShardColumnConstraintSkipValidation(t *testing.T) { ctx := context.Background() constraintsToValidate := make(chan []catalog.Constraint, 1) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeConstraintValidation: func(constraints []catalog.Constraint) error { @@ -7141,7 +7140,7 @@ func TestHashShardedIndexRangePreSplit(t *testing.T) { var runBeforePreSplitting func(tbl *tabledesc.Mutable, kvDB *kv.DB, codec keys.SQLCodec) error var runAfterPreSplitting func(tbl *tabledesc.Mutable, kvDB *kv.DB, codec keys.SQLCodec) error - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ RunBeforeHashShardedIndexRangePreSplit: func(tbl *tabledesc.Mutable, kvDB *kv.DB, codec keys.SQLCodec) error { @@ -7390,7 +7389,7 @@ ALTER TABLE t.test SET (ttl_expire_after = '10 hours'); knobs := &sql.SchemaChangerTestingKnobs{} - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLSchemaChanger = knobs s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx) @@ -7506,7 +7505,7 @@ CREATE TABLE t.test (x INT) WITH (ttl_expire_after = '10 minutes');`, for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() childJobStartNotification := make(chan struct{}) waitBeforeContinuing := make(chan struct{}) var doOnce sync.Once @@ -7580,7 +7579,7 @@ func TestPauseBeforeRandomDescTxn(t *testing.T) { count int32 // accessed atomically shouldCount int32 // accessed atomically ) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -7609,7 +7608,7 @@ func TestPauseBeforeRandomDescTxn(t *testing.T) { jobID jobspb.JobID ) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -7700,7 +7699,7 @@ func TestOperationAtRandomStateTransition(t *testing.T) { count int32 // accessed atomically shouldCount int32 // accessed atomically ) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -7732,7 +7731,7 @@ func TestOperationAtRandomStateTransition(t *testing.T) { kvDB *kv.DB ) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs = base.TestingKnobs{ JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{ @@ -7968,7 +7967,7 @@ func TestColumnBackfillProcessingDoesNotHoldLockOnJobsTable(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() chCh := make(chan chan error) params.Knobs.DistSQL = &execinfra.TestingKnobs{ RunBeforeBackfillChunk: func(sp roachpb.Span) error { @@ -8025,7 +8024,7 @@ func TestLegacySchemaChangerWaitsForOtherSchemaChanges(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() s, sqlDB, _ := serverutils.StartServer(t, params) diff --git a/pkg/sql/schemachanger/scbuild/builder_test.go b/pkg/sql/schemachanger/scbuild/builder_test.go index 9d6fb15fae22..207091aa7327 100644 --- a/pkg/sql/schemachanger/scbuild/builder_test.go +++ b/pkg/sql/schemachanger/scbuild/builder_test.go @@ -300,6 +300,7 @@ func TestBuildIsMemoryMonitored(t *testing.T) { }, }) defer s.Stopper().Stop(ctx) + tdb := sqlutils.MakeSQLRunner(db) tdb.Exec(t, `use defaultdb;`) tdb.Exec(t, `select crdb_internal.generate_test_objects('test', 5000);`) diff --git a/pkg/sql/tests/server_params.go b/pkg/sql/server_params_test.go similarity index 68% rename from pkg/sql/tests/server_params.go rename to pkg/sql/server_params_test.go index ea494a0c17e5..129bcbee51a8 100644 --- a/pkg/sql/tests/server_params.go +++ b/pkg/sql/server_params_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 The Cockroach Authors. +// Copyright 2023 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. @@ -8,23 +8,23 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package tests +package sql_test import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase" - "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" + "github.com/cockroachdb/cockroach/pkg/sql/tests" ) -// CreateTestServerParams creates a set of params suitable for SQL tests. It +// createTestServerParams creates a set of params suitable for SQL tests. It // enables some EndTxn sanity checking and installs a flexible // TestingEvalFilter. // TODO(andrei): this function is not used consistently by SQL tests. Figure out // if the EndTxn checks are important. -func CreateTestServerParams() (base.TestServerArgs, *CommandFilters) { - var cmdFilters CommandFilters +func createTestServerParams() (base.TestServerArgs, *tests.CommandFilters) { + var cmdFilters tests.CommandFilters params := base.TestServerArgs{} // Disable the default test tenant as limits to the number of spans in a // secondary tenant cause this test to fail. Tracked with #76378. @@ -37,13 +37,3 @@ func CreateTestServerParams() (base.TestServerArgs, *CommandFilters) { } return params, &cmdFilters } - -// CreateTestTenantParams creates a set of params suitable for SQL Tenant Tests. -func CreateTestTenantParams(tenantID roachpb.TenantID) base.TestTenantArgs { - return base.TestTenantArgs{ - TenantID: tenantID, - TestingKnobs: base.TestingKnobs{ - SQLStatsKnobs: sqlstats.CreateTestingKnobs(), - }, - } -} diff --git a/pkg/sql/show_create_all_tables_builtin_test.go b/pkg/sql/show_create_all_tables_builtin_test.go index bb63dfee10de..9b4689941df4 100644 --- a/pkg/sql/show_create_all_tables_builtin_test.go +++ b/pkg/sql/show_create_all_tables_builtin_test.go @@ -14,7 +14,6 @@ import ( "context" "testing" - "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" @@ -28,7 +27,7 @@ func TestRecreateTables(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/show_test.go b/pkg/sql/show_test.go index 222cfdc52c6b..577f5c895d7f 100644 --- a/pkg/sql/show_test.go +++ b/pkg/sql/show_test.go @@ -29,7 +29,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "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/skip" @@ -302,7 +301,7 @@ func TestShowCreateView(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -399,7 +398,7 @@ func TestShowCreateSequence(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -979,7 +978,7 @@ func TestShowSessionPrivileges(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Insecure = true s, rawSQLDBroot, _ := serverutils.StartServer(t, params) sqlDBroot := sqlutils.MakeSQLRunner(rawSQLDBroot) @@ -1061,7 +1060,7 @@ func TestShowRedactedActiveStatements(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Insecure = true ctx, cancel := context.WithCancel(context.Background()) s, rawSQLDBroot, _ := serverutils.StartServer(t, params) @@ -1204,7 +1203,7 @@ func TestLintClusterSettingNames(t *testing.T) { skip.UnderDeadlock(t, "lint only test") skip.UnderStress(t, "lint only test") - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/sort_test.go b/pkg/sql/sort_test.go index a905fc834fa6..aa16492287e1 100644 --- a/pkg/sql/sort_test.go +++ b/pkg/sql/sort_test.go @@ -14,7 +14,6 @@ import ( "context" "testing" - "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" @@ -24,7 +23,7 @@ func TestOrderByRandom(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/span/BUILD.bazel b/pkg/sql/span/BUILD.bazel index 76c7651fe711..ca69a41cb996 100644 --- a/pkg/sql/span/BUILD.bazel +++ b/pkg/sql/span/BUILD.bazel @@ -39,14 +39,14 @@ go_test( args = ["-test.timeout=55s"], deps = [ ":span", - "//pkg/keys", + "//pkg/base", + "//pkg/ccl", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/server", "//pkg/sql/catalog", "//pkg/sql/catalog/desctestutils", "//pkg/sql/catalog/systemschema", - "//pkg/sql/tests", "//pkg/testutils/serverutils", "//pkg/util/intsets", "//pkg/util/leaktest", diff --git a/pkg/sql/span/main_test.go b/pkg/sql/span/main_test.go index 75e011dd0864..bae3849c3121 100644 --- a/pkg/sql/span/main_test.go +++ b/pkg/sql/span/main_test.go @@ -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" @@ -25,5 +26,6 @@ func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) randutil.SeedForTests() serverutils.InitTestServerFactory(server.TestServerFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/span/span_splitter_test.go b/pkg/sql/span/span_splitter_test.go index 2794c5ebf595..26184766bab9 100644 --- a/pkg/sql/span/span_splitter_test.go +++ b/pkg/sql/span/span_splitter_test.go @@ -15,12 +15,11 @@ import ( "fmt" "testing" - "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/span" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/intsets" "github.com/cockroachdb/cockroach/pkg/util/leaktest" @@ -42,10 +41,11 @@ func TestSpanSplitterDoesNotSplitSystemTableFamilySpans(t *testing.T) { func TestSpanSplitterCanSplitSpan(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) - defer s.Stopper().Stop(ctx) + srv, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + codec := srv.ApplicationLayer().Codec() tcs := []struct { sql string index string @@ -127,7 +127,7 @@ func TestSpanSplitterCanSplitSpan(t *testing.T) { if _, err := sqlDB.Exec(sql); err != nil { t.Fatal(err) } - desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "t", "t") + desc := desctestutils.TestingGetPublicTableDescriptor(kvDB, codec, "t", "t") idx, err := catalog.MustFindIndexByName(desc, tc.index) if err != nil { t.Fatal(err) diff --git a/pkg/sql/split_test.go b/pkg/sql/split_test.go index 80de35e35430..2172662ab284 100644 --- a/pkg/sql/split_test.go +++ b/pkg/sql/split_test.go @@ -17,7 +17,6 @@ import ( "testing" "github.com/cockroachdb/cockroach/pkg/roachpb" - "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" @@ -28,7 +27,7 @@ func TestSplitAt(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/sql_activity_update_job_test.go b/pkg/sql/sql_activity_update_job_test.go index 2aac82541ae0..ec83b5298a3d 100644 --- a/pkg/sql/sql_activity_update_job_test.go +++ b/pkg/sql/sql_activity_update_job_test.go @@ -45,10 +45,8 @@ func TestSqlActivityUpdateJob(t *testing.T) { ctx := context.Background() stubTime := timeutil.Now().Truncate(time.Hour) - sqlStatsKnobs := &sqlstats.TestingKnobs{ - StubTimeNow: func() time.Time { return stubTime }, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.StubTimeNow = func() time.Time { return stubTime } // Start the cluster. // Disable the job since it is called manually from a new instance to avoid @@ -166,10 +164,8 @@ func TestSqlActivityUpdateTopLimitJob(t *testing.T) { defer log.Scope(t).Close(t) stubTime := timeutil.Now().Truncate(time.Hour) - sqlStatsKnobs := &sqlstats.TestingKnobs{ - StubTimeNow: func() time.Time { return stubTime }, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.StubTimeNow = func() time.Time { return stubTime } // Start the cluster. ctx := context.Background() @@ -307,10 +303,6 @@ func TestSqlActivityJobRunsAfterStatsFlush(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - sqlStatsKnobs := &sqlstats.TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } - // Start the cluster. ctx := context.Background() st := cluster.MakeTestingClusterSettings() @@ -318,7 +310,7 @@ func TestSqlActivityJobRunsAfterStatsFlush(t *testing.T) { Insecure: true, Settings: st, Knobs: base.TestingKnobs{ - SQLStatsKnobs: sqlStatsKnobs, + SQLStatsKnobs: sqlstats.CreateTestingKnobs(), JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), }, }) @@ -368,10 +360,8 @@ func TestTransactionActivityMetadata(t *testing.T) { ctx := context.Background() stubTime := timeutil.Now().Truncate(time.Hour) - sqlStatsKnobs := &sqlstats.TestingKnobs{ - StubTimeNow: func() time.Time { return stubTime }, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.StubTimeNow = func() time.Time { return stubTime } s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{ Insecure: true, Knobs: base.TestingKnobs{ @@ -436,10 +426,8 @@ func TestActivityStatusCombineAPI(t *testing.T) { ctx := context.Background() stubTime := timeutil.Now().Truncate(time.Hour) - sqlStatsKnobs := &sqlstats.TestingKnobs{ - StubTimeNow: func() time.Time { return stubTime }, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - } + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.StubTimeNow = func() time.Time { return stubTime } s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{ Insecure: true, Knobs: base.TestingKnobs{ diff --git a/pkg/sql/sqlnoccltest/BUILD.bazel b/pkg/sql/sqlnoccltest/BUILD.bazel index 2dee6658ad45..b0111d004280 100644 --- a/pkg/sql/sqlnoccltest/BUILD.bazel +++ b/pkg/sql/sqlnoccltest/BUILD.bazel @@ -8,6 +8,7 @@ go_test( ], args = ["-test.timeout=295s"], deps = [ + "//pkg/base", "//pkg/config/zonepb", "//pkg/keys", "//pkg/security/securityassets", diff --git a/pkg/sql/sqlnoccltest/partition_test.go b/pkg/sql/sqlnoccltest/partition_test.go index 8b5861e17e74..da638d863150 100644 --- a/pkg/sql/sqlnoccltest/partition_test.go +++ b/pkg/sql/sqlnoccltest/partition_test.go @@ -14,6 +14,7 @@ import ( "context" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys" @@ -35,8 +36,7 @@ func TestRemovePartitioningOSS(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, sqlDBRaw, kvDB := serverutils.StartServer(t, params) + s, sqlDBRaw, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) sqlDB := sqlutils.MakeSQLRunner(sqlDBRaw) defer s.Stopper().Stop(ctx) diff --git a/pkg/sql/sqlstats/BUILD.bazel b/pkg/sql/sqlstats/BUILD.bazel index 559b5c96635f..08b3e3e9aaf5 100644 --- a/pkg/sql/sqlstats/BUILD.bazel +++ b/pkg/sql/sqlstats/BUILD.bazel @@ -10,7 +10,6 @@ go_library( importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats", visibility = ["//visibility:public"], deps = [ - "//pkg/base", "//pkg/roachpb", "//pkg/settings", "//pkg/sql/appstatspb", diff --git a/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel b/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel index db50e74800f9..995582da1621 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel +++ b/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel @@ -97,7 +97,6 @@ go_test( "//pkg/sql/sem/tree", "//pkg/sql/sessiondata", "//pkg/sql/sqlstats", - "//pkg/sql/tests", "//pkg/testutils", "//pkg/testutils/datapathutils", "//pkg/testutils/serverutils", diff --git a/pkg/sql/sqlstats/persistedsqlstats/compaction_test.go b/pkg/sql/sqlstats/persistedsqlstats/compaction_test.go index 957aad184edf..0dba22fb565e 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/compaction_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/compaction_test.go @@ -34,7 +34,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "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/encoding" @@ -131,15 +130,14 @@ func TestSQLStatsCompactor(t *testing.T) { kvInterceptor := kvScanInterceptor{} cleanupInterceptor := cleanupInterceptor{} + knobs := sqlstats.CreateTestingKnobs() + knobs.StubTimeNow = func() time.Time { + return timeutil.Now().Add(-2 * time.Hour) + } srv, conn, _ := serverutils.StartServer( t, base.TestServerArgs{ Knobs: base.TestingKnobs{ - SQLStatsKnobs: &sqlstats.TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", - StubTimeNow: func() time.Time { - return timeutil.Now().Add(-2 * time.Hour) - }, - }, + SQLStatsKnobs: knobs, Store: &kvserver.StoreTestingKnobs{ TestingRequestFilter: kvInterceptor.intercept, DisableLoadBasedSplitting: true, @@ -216,17 +214,13 @@ func TestSQLStatsCompactor(t *testing.T) { generateFingerprints(t, sqlConn, tc.stmtCount) serverSQLStats.Flush(ctx) + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.OnCleanupStartForShard = cleanupInterceptor.intercept statsCompactor := persistedsqlstats.NewStatsCompactor( server.ClusterSettings(), server.InternalDB().(isql.DB), metric.NewCounter(metric.Metadata{}), - &sqlstats.TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", - OnCleanupStartForShard: cleanupInterceptor.intercept, - StubTimeNow: func() time.Time { - return timeutil.Now() - }, - }, + sqlStatsKnobs, ) // Initial compaction should remove the all the oldest entries. @@ -293,18 +287,19 @@ func TestSQLStatsCompactionJobMarkedAsAutomatic(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() t.Logf("starting test server") ctx := context.Background() server, conn, _ := serverutils.StartServer(t, params) defer server.Stopper().Stop(ctx) + s := server.ApplicationLayer() sqlDB := sqlutils.MakeSQLRunner(conn) t.Logf("launching the stats compaction job") - jobID, err := launchSQLStatsCompactionJob(server) + jobID, err := launchSQLStatsCompactionJob(s) require.NoError(t, err) t.Logf("checking the job status") diff --git a/pkg/sql/sqlstats/persistedsqlstats/controller_test.go b/pkg/sql/sqlstats/persistedsqlstats/controller_test.go index 85eb6753219f..d9b78db35c1e 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/controller_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/controller_test.go @@ -20,7 +20,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" - "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" @@ -35,22 +34,17 @@ func TestPersistedSQLStatsReset(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - - cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{ - ServerArgs: params, - }) - - server := cluster.Server(0 /* idx */) + cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{}) + defer cluster.Stopper().Stop(ctx) + server := cluster.Server(0 /* idx */).ApplicationLayer() // Open two connections so that we can run statements without messing up // the SQL stats. - testConn := cluster.ServerConn(0 /* idx */) - observerConn := cluster.ServerConn(1 /* idx */) + testConn := server.SQLConn(t, "") + observerConn := cluster.Server(1).ApplicationLayer().SQLConn(t, "") sqlDB := sqlutils.MakeSQLRunner(testConn) observer := sqlutils.MakeSQLRunner(observerConn) - defer cluster.Stopper().Stop(ctx) testCasesForDisk := map[string]string{ "SELECT _": "SELECT 1", diff --git a/pkg/sql/sqlstats/persistedsqlstats/datadriven_test.go b/pkg/sql/sqlstats/persistedsqlstats/datadriven_test.go index 9d4600c977f2..0a469f9b9b8b 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/datadriven_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/datadriven_test.go @@ -24,7 +24,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" - "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" @@ -75,17 +74,19 @@ func TestSQLStatsDataDriven(t *testing.T) { injector := newRuntimeKnobsInjector() ctx := context.Background() - params, _ := tests.CreateTestServerParams() - params.Knobs.SQLStatsKnobs.(*sqlstats.TestingKnobs).StubTimeNow = stubTime.Now - params.Knobs.SQLStatsKnobs.(*sqlstats.TestingKnobs).OnStmtStatsFlushFinished = injector.invokePostStmtStatsFlushCallback - params.Knobs.SQLStatsKnobs.(*sqlstats.TestingKnobs).OnTxnStatsFlushFinished = injector.invokePostTxnStatsFlushCallback + var params base.TestServerArgs + knobs := sqlstats.CreateTestingKnobs() + knobs.StubTimeNow = stubTime.Now + knobs.OnStmtStatsFlushFinished = injector.invokePostStmtStatsFlushCallback + knobs.OnTxnStatsFlushFinished = injector.invokePostTxnStatsFlushCallback + params.Knobs.SQLStatsKnobs = knobs cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{ ServerArgs: params, }) defer cluster.Stopper().Stop(ctx) - server := cluster.Server(0 /* idx */) + server := cluster.Server(0 /* idx */).ApplicationLayer() sqlStats := server.SQLServer().(*sql.Server).GetSQLStatsProvider().(*persistedsqlstats.PersistedSQLStats) appStats := sqlStats.GetApplicationStats("app1", false) diff --git a/pkg/sql/sqlstats/persistedsqlstats/flush_test.go b/pkg/sql/sqlstats/persistedsqlstats/flush_test.go index 72f742a0e7bb..290ed1a5f7c9 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/flush_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/flush_test.go @@ -23,7 +23,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/appstatspb" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" - "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" @@ -209,8 +208,7 @@ func TestSQLStatsInitialDelay(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() - srv := serverutils.StartServerOnly(t, params) + srv := serverutils.StartServerOnly(t, base.TestServerArgs{}) defer srv.Stopper().Stop(context.Background()) s := srv.ApplicationLayer() @@ -237,12 +235,12 @@ func TestSQLStatsMinimumFlushInterval(t *testing.T) { } fakeTime.setTime(timeutil.Now()) - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLStatsKnobs = &sqlstats.TestingKnobs{ StubTimeNow: fakeTime.Now, } srv, conn, _ := serverutils.StartServer(t, params) - defer srv.Stopper().Stop(context.Background()) + defer srv.Stopper().Stop(ctx) s := srv.ApplicationLayer() sqlConn := sqlutils.MakeSQLRunner(conn) @@ -303,9 +301,8 @@ func TestInMemoryStatsDiscard(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - srv, conn, _ := serverutils.StartServer(t, params) - defer srv.Stopper().Stop(context.Background()) + srv, conn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) s := srv.ApplicationLayer() observer := s.SQLConn(t, "") @@ -415,9 +412,8 @@ func TestSQLStatsGatewayNodeSetting(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - srv, conn, _ := serverutils.StartServer(t, params) - defer srv.Stopper().Stop(context.Background()) + srv, conn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) s := srv.ApplicationLayer() sqlConn := sqlutils.MakeSQLRunner(conn) @@ -459,9 +455,10 @@ func TestSQLStatsPersistedLimitReached(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs + params.Knobs.SQLStatsKnobs = sqlstats.CreateTestingKnobs() srv, conn, _ := serverutils.StartServer(t, params) - defer srv.Stopper().Stop(context.Background()) + defer srv.Stopper().Stop(ctx) s := srv.ApplicationLayer() sqlConn := sqlutils.MakeSQLRunner(conn) @@ -581,8 +578,10 @@ func TestSQLStatsPlanSampling(t *testing.T) { stubTime.setTime(parsedTime) } - params, _ := tests.CreateTestServerParams() - params.Knobs.SQLStatsKnobs.(*sqlstats.TestingKnobs).StubTimeNow = stubTime.Now + sqlStatsKnobs := sqlstats.CreateTestingKnobs() + sqlStatsKnobs.StubTimeNow = stubTime.Now + var params base.TestServerArgs + params.Knobs.SQLStatsKnobs = sqlStatsKnobs ctx := context.Background() srv, conn, _ := serverutils.StartServer(t, params) diff --git a/pkg/sql/sqlstats/persistedsqlstats/reader_test.go b/pkg/sql/sqlstats/persistedsqlstats/reader_test.go index 34e47e88b78a..1ca13d46e69e 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/reader_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/reader_test.go @@ -43,13 +43,12 @@ func TestPersistedSQLStatsRead(t *testing.T) { } fakeTime.setTime(timeutil.Now()) + knobs := sqlstats.CreateTestingKnobs() + knobs.StubTimeNow = fakeTime.Now testCluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ Knobs: base.TestingKnobs{ - SQLStatsKnobs: &sqlstats.TestingKnobs{ - StubTimeNow: fakeTime.Now, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - }, + SQLStatsKnobs: knobs, }, }, }) @@ -160,13 +159,12 @@ func TestSQLStatsWithMultipleIdxRec(t *testing.T) { } fakeTime.setTime(timeutil.Now()) + knobs := sqlstats.CreateTestingKnobs() + knobs.StubTimeNow = fakeTime.Now testCluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ Knobs: base.TestingKnobs{ - SQLStatsKnobs: &sqlstats.TestingKnobs{ - StubTimeNow: fakeTime.Now, - AOSTClause: "AS OF SYSTEM TIME '-1us'", - }, + SQLStatsKnobs: knobs, }, }, }) diff --git a/pkg/sql/sqlstats/persistedsqlstats/scheduled_sql_stats_compaction_test.go b/pkg/sql/sqlstats/persistedsqlstats/scheduled_sql_stats_compaction_test.go index 4e43359037b4..754052e1ee93 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/scheduled_sql_stats_compaction_test.go +++ b/pkg/sql/sqlstats/persistedsqlstats/scheduled_sql_stats_compaction_test.go @@ -18,6 +18,7 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobstest" "github.com/cockroachdb/cockroach/pkg/scheduledjobs" @@ -26,7 +27,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" - "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" @@ -39,7 +39,7 @@ import ( ) type testHelper struct { - server serverutils.TestServerInterface + server serverutils.ApplicationLayerInterface sqlDB *sqlutils.SQLRunner env *jobstest.JobSchedulerTestEnv cfg *scheduledjobs.JobExecutionConfig @@ -86,17 +86,17 @@ func newTestHelper( helper.cfg = config } - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.JobsTestingKnobs = knobs params.Knobs.SQLStatsKnobs = sqlStatsKnobs - server, db, _ := serverutils.StartServer(t, params) + srv, db, _ := serverutils.StartServer(t, params) require.NotNil(t, helper.cfg) helper.sqlDB = sqlutils.MakeSQLRunner(db) - helper.server = server + helper.server = srv.ApplicationLayer() return helper, func() { - server.Stopper().Stop(context.Background()) + srv.Stopper().Stop(context.Background()) } } diff --git a/pkg/sql/sqlstats/sslocal/BUILD.bazel b/pkg/sql/sqlstats/sslocal/BUILD.bazel index 38ce118a8787..e2a50fe27050 100644 --- a/pkg/sql/sqlstats/sslocal/BUILD.bazel +++ b/pkg/sql/sqlstats/sslocal/BUILD.bazel @@ -44,6 +44,7 @@ go_test( deps = [ ":sslocal", "//pkg/base", + "//pkg/ccl", "//pkg/kv/kvpb", "//pkg/roachpb", "//pkg/security/securityassets", @@ -64,7 +65,6 @@ go_test( "//pkg/sql/sqlstats/insights", "//pkg/sql/sqlstats/persistedsqlstats", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil", - "//pkg/sql/tests", "//pkg/storage/enginepb", "//pkg/testutils", "//pkg/testutils/serverutils", @@ -80,7 +80,6 @@ go_test( "//pkg/util/uint128", "//pkg/util/uuid", "@com_github_jackc_pgx_v4//:pgx", - "@com_github_lib_pq//:pq", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/sql/sqlstats/sslocal/iterator_test.go b/pkg/sql/sqlstats/sslocal/iterator_test.go index ff434f65e6bd..0a760c7f71bb 100644 --- a/pkg/sql/sqlstats/sslocal/iterator_test.go +++ b/pkg/sql/sqlstats/sslocal/iterator_test.go @@ -14,10 +14,10 @@ import ( "context" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/appstatspb" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "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" @@ -30,8 +30,11 @@ func TestSQLStatsIteratorWithTelemetryFlush(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - serverParams, _ := tests.CreateTestServerParams() - s, goDB, _ := serverutils.StartServer(t, serverParams) + s, goDB, _ := serverutils.StartServer(t, base.TestServerArgs{ + Knobs: base.TestingKnobs{ + SQLStatsKnobs: sqlstats.CreateTestingKnobs(), + }, + }) defer s.Stopper().Stop(ctx) testCases := map[string]string{ diff --git a/pkg/sql/sqlstats/sslocal/main_test.go b/pkg/sql/sqlstats/sslocal/main_test.go index e1d4660ef5a7..28f58bca30d0 100644 --- a/pkg/sql/sqlstats/sslocal/main_test.go +++ b/pkg/sql/sqlstats/sslocal/main_test.go @@ -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" @@ -25,5 +26,6 @@ func TestMain(m *testing.M) { securityassets.SetLoader(securitytest.EmbeddedAssets) serverutils.InitTestServerFactory(server.TestServerFactory) serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + defer ccl.TestingEnableEnterprise()() os.Exit(m.Run()) } diff --git a/pkg/sql/sqlstats/sslocal/sql_stats_test.go b/pkg/sql/sqlstats/sslocal/sql_stats_test.go index d79f722ca89e..cafc94cda195 100644 --- a/pkg/sql/sqlstats/sslocal/sql_stats_test.go +++ b/pkg/sql/sqlstats/sslocal/sql_stats_test.go @@ -41,7 +41,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/sslocal" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -56,7 +55,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/uint128" "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/jackc/pgx/v4" - "github.com/lib/pq" "github.com/stretchr/testify/require" ) @@ -322,19 +320,14 @@ func TestNodeLocalInMemoryViewDoesNotReturnPersistedStats(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() - cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{ - ServerArgs: params, - }) - - server := cluster.Server(0 /* idx */) + cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{}) + defer cluster.Stopper().Stop(ctx) + server := cluster.Server(0 /* idx */).ApplicationLayer() // Open two connections so that we can run statements without messing up // the SQL stats. - testConn := cluster.ServerConn(0 /* idx */) + testConn := server.SQLConn(t, "") sqlDB := sqlutils.MakeSQLRunner(testConn) - defer cluster.Stopper().Stop(ctx) - sqlDB.Exec(t, "SET application_name = 'app1'") sqlDB.Exec(t, "SELECT 1 WHERE true") @@ -786,9 +779,7 @@ func TestTxnStatsDiscardedAfterPrematureStatementExecutionAbortion(t *testing.T) defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - server, sqlConn, _ := serverutils.StartServer(t, params) - + server, sqlConn, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer server.Stopper().Stop(ctx) sqlDB := sqlutils.MakeSQLRunner(sqlConn) @@ -865,7 +856,7 @@ func TestTransactionServiceLatencyOnExtendedProtocol(t *testing.T) { currentTestCaseIdx := 0 const latencyThreshold = time.Second * 5 - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ OnRecordTxnFinish: func(isInternal bool, phaseTimes *sessionphase.Times, stmt string) { if !isInternal && testData[currentTestCaseIdx].query == stmt { @@ -907,12 +898,8 @@ func TestFingerprintCreation(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - testServer, sqlConn, _ := serverutils.StartServer(t, params) - defer func() { - require.NoError(t, sqlConn.Close()) - testServer.Stopper().Stop(ctx) - }() + testServer, sqlConn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer testServer.Stopper().Stop(ctx) testConn := sqlutils.MakeSQLRunner(sqlConn) testConn.Exec(t, "CREATE TABLE t (v INT)") @@ -1262,11 +1249,12 @@ func TestSQLStatsIdleLatencies(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) - defer s.Stopper().Stop(ctx) + srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer srv.Stopper().Stop(ctx) + s := srv.ApplicationLayer() - // Max limit safety check on the expected idle latency in seconds. Mostly a paranoia check. + // Max limit safety check on the expected idle latency in seconds. Mostly a + // paranoia check. const idleLatCap float64 = 30 testCases := []struct { @@ -1293,7 +1281,8 @@ func TestSQLStatsIdleLatencies(t *testing.T) { stmtLats: map[string]float64{"SELECT _": 0}, txnLat: 0, ops: func(t *testing.T, db *gosql.DB) { - // These 100ms don't count because we're not in an explicit transaction. + // These 100ms don't count because we're not in an explicit + // transaction. time.Sleep(100 * time.Millisecond) _, err := db.Exec("SELECT 1") require.NoError(t, err) @@ -1416,18 +1405,12 @@ func TestSQLStatsIdleLatencies(t *testing.T) { // Note that we're not using pgx here because it *always* prepares // statements, and we want to test our client latency measurements // both with and without prepared statements. - dbUrl, cleanup := sqlutils.PGUrl(t, s.AdvSQLAddr(), t.Name(), url.User(username.RootUser)) - defer cleanup() - connector, err := pq.NewConnector(dbUrl.String()) - require.NoError(t, err) - opsDB := gosql.OpenDB(connector) - defer func() { - _ = opsDB.Close() - }() + opsDB := s.SQLConn(t, "") - // Set a unique application name for our session, so we can find our stats easily. + // Set a unique application name for our session, so we can find our + // stats easily. appName := t.Name() - _, err = opsDB.Exec("SET application_name = $1", appName) + _, err := opsDB.Exec("SET application_name = $1", appName) require.NoError(t, err) // Run the test operations. @@ -1449,8 +1432,9 @@ func TestSQLStatsIdleLatencies(t *testing.T) { actual[query] = latency } require.NoError(t, rows.Err()) - // Ensure that all test case statements have at least the minimum expected idle latency and do not exceed the - // safety check cap. + // Ensure that all test case statements have at least the + // minimum expected idle latency and do not exceed the safety + // check cap. for tc_stmt, tc_latency := range tc.stmtLats { require.GreaterOrEqual(t, actual[tc_stmt], tc_latency) require.Less(t, actual[tc_stmt], idleLatCap) @@ -1465,8 +1449,8 @@ func TestSQLStatsIdleLatencies(t *testing.T) { WHERE app_name = $1`, appName) err := row.Scan(&actual) require.NoError(t, err) - // Ensure the test case transaction has at least the minimum expected idle latency and do not exceed the safety - // check cap. + // Ensure the test case transaction has at least the minimum + // expected idle latency and do not exceed the safety check cap. require.GreaterOrEqual(t, actual, tc.txnLat) require.Less(t, actual, idleLatCap) }) @@ -1484,12 +1468,8 @@ func TestSQLStatsIndexesUsed(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - testServer, sqlConn, _ := serverutils.StartServer(t, params) - defer func() { - require.NoError(t, sqlConn.Close()) - testServer.Stopper().Stop(ctx) - }() + testServer, sqlConn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer testServer.Stopper().Stop(ctx) testConn := sqlutils.MakeSQLRunner(sqlConn) appName := "indexes-usage" testConn.Exec(t, "SET application_name = $1", appName) @@ -1592,12 +1572,8 @@ func TestSQLStatsLatencyInfo(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - testServer, sqlConn, _ := serverutils.StartServer(t, params) - defer func() { - require.NoError(t, sqlConn.Close()) - testServer.Stopper().Stop(ctx) - }() + testServer, sqlConn, _ := serverutils.StartServer(t, base.TestServerArgs{}) + defer testServer.Stopper().Stop(ctx) testConn := sqlutils.MakeSQLRunner(sqlConn) appName := "latency-info" testConn.Exec(t, "SET application_name = $1", appName) @@ -1685,9 +1661,7 @@ func TestSQLStatsRegions(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() - params.Locality = tc.locality - s, conn, _ := serverutils.StartServer(t, params) + s, conn, _ := serverutils.StartServer(t, base.TestServerArgs{Locality: tc.locality}) defer s.Stopper().Stop(ctx) db := sqlutils.MakeSQLRunner(conn) diff --git a/pkg/sql/sqlstats/test_utils.go b/pkg/sql/sqlstats/test_utils.go index 611aa31c1bb7..78b7c8615052 100644 --- a/pkg/sql/sqlstats/test_utils.go +++ b/pkg/sql/sqlstats/test_utils.go @@ -10,11 +10,7 @@ package sqlstats -import ( - "time" - - "github.com/cockroachdb/cockroach/pkg/base" -) +import "time" // TestingKnobs provides hooks and knobs for unit tests. type TestingKnobs struct { @@ -34,9 +30,9 @@ type TestingKnobs struct { // by the flush operation to calculate aggregated_ts timestamp. StubTimeNow func() time.Time - // AOSTClause overrides the AS OF SYSTEM TIME clause in queries used in + // aostClause overrides the AS OF SYSTEM TIME clause in queries used in // persistedsqlstats. - AOSTClause string + aostClause string // JobMonitorUpdateCheckInterval if non-zero indicates the frequency at // which the job monitor needs to check whether the schedule needs to be @@ -55,7 +51,7 @@ func (*TestingKnobs) ModuleTestingKnobs() {} // used when reading from statements and transactions system tables. func (knobs *TestingKnobs) GetAOSTClause() string { if knobs != nil { - return knobs.AOSTClause + return knobs.aostClause } return "AS OF SYSTEM TIME follower_read_timestamp()" @@ -78,8 +74,8 @@ func (knobs *TestingKnobs) GetAOSTClause() string { // Additionally, we don't want to completely remove the AOST clause in the unit // test. Therefore, `AS OF SYSTEM TIME '-1us'` is a compromise used to get // around the 'descriptor not found' error. -func CreateTestingKnobs() base.ModuleTestingKnobs { +func CreateTestingKnobs() *TestingKnobs { return &TestingKnobs{ - AOSTClause: "AS OF SYSTEM TIME '-1us'", + aostClause: "AS OF SYSTEM TIME '-1us'", } } diff --git a/pkg/sql/table_ref_test.go b/pkg/sql/table_ref_test.go index f2b43effe3ac..0c7e7edf3232 100644 --- a/pkg/sql/table_ref_test.go +++ b/pkg/sql/table_ref_test.go @@ -19,7 +19,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils" - "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" @@ -29,7 +28,7 @@ func TestTableRefs(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/sql/table_test.go b/pkg/sql/table_test.go index 82a3266b14d7..21c1b9e80932 100644 --- a/pkg/sql/table_test.go +++ b/pkg/sql/table_test.go @@ -17,6 +17,7 @@ import ( "reflect" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/security/username" @@ -31,7 +32,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/isql" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -428,8 +428,7 @@ func TestCanCloneTableWithUDT(t *testing.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(` CREATE DATABASE test; @@ -527,8 +526,7 @@ func TestSerializedUDTsInTableDescriptor(t *testing.T) { }, } - 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(` CREATE DATABASE test; @@ -594,8 +592,7 @@ func TestSerializedUDTsInView(t *testing.T) { }, } - 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(` CREATE DATABASE test; @@ -649,7 +646,7 @@ func TestJobsCache(t *testing.T) { } } - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLExecutor = &ExecutorTestingKnobs{ RunAfterSCJobsCacheLookup: runAfterSCJobsCacheLookup, } diff --git a/pkg/sql/temporary_schema_test.go b/pkg/sql/temporary_schema_test.go index f05d918603e4..8cfe240fd158 100644 --- a/pkg/sql/temporary_schema_test.go +++ b/pkg/sql/temporary_schema_test.go @@ -24,7 +24,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descs" "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease" "github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants" - "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" @@ -45,8 +44,7 @@ func TestCleanupSchemaObjects(t *testing.T) { defer lease.TestingDisableTableLeases()() ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) conn, err := db.Conn(ctx) diff --git a/pkg/sql/tests/BUILD.bazel b/pkg/sql/tests/BUILD.bazel index 2b5ac6b8109c..7521b1b17e5b 100644 --- a/pkg/sql/tests/BUILD.bazel +++ b/pkg/sql/tests/BUILD.bazel @@ -6,20 +6,16 @@ go_library( "command_filters.go", "data.go", "explain_test_util.go", - "server_params.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/sql/tests", visibility = ["//visibility:public"], deps = [ - "//pkg/base", "//pkg/internal/sqlsmith", "//pkg/kv", "//pkg/kv/kvpb", - "//pkg/kv/kvserver", "//pkg/kv/kvserver/kvserverbase", "//pkg/roachpb", "//pkg/sql/sem/tree", - "//pkg/sql/sqlstats", "//pkg/storage", "//pkg/testutils/serverutils", "//pkg/testutils/storageutils", @@ -87,6 +83,7 @@ go_test( "//pkg/security/username", "//pkg/server", "//pkg/settings/cluster", + "//pkg/spanconfig", "//pkg/sql", "//pkg/sql/catalog", "//pkg/sql/catalog/bootstrap", diff --git a/pkg/sql/tests/autocommit_extended_protocol_test.go b/pkg/sql/tests/autocommit_extended_protocol_test.go index 9c60543fa426..282ba1cd8bb3 100644 --- a/pkg/sql/tests/autocommit_extended_protocol_test.go +++ b/pkg/sql/tests/autocommit_extended_protocol_test.go @@ -18,6 +18,7 @@ import ( "sync/atomic" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descs" @@ -38,9 +39,7 @@ func TestInsertFastPathExtendedProtocol(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := CreateTestServerParams() - params.Settings = cluster.MakeTestingClusterSettings() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) _, err := db.Exec(`CREATE TABLE fast_path_test(val int);`) require.NoError(t, err) @@ -86,9 +85,7 @@ func TestInsertFastPathDisableDDLExtendedProtocol(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := CreateTestServerParams() - params.Settings = cluster.MakeTestingClusterSettings() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) defer s.Stopper().Stop(ctx) _, err := db.Exec(`CREATE TABLE fast_path_test(val int, j int);`) require.NoError(t, err) @@ -152,7 +149,7 @@ func TestErrorDuringExtendedProtocolCommit(t *testing.T) { var shouldErrorOnAutoCommit syncutil.AtomicBool var traceID atomic.Uint64 - params, _ := CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ DisableAutoCommitDuringExec: true, BeforeExecute: func(ctx context.Context, stmt string, descriptors *descs.Collection) { diff --git a/pkg/sql/tests/random_schema_test.go b/pkg/sql/tests/random_schema_test.go index 26e8aa06b33c..e6fcb645864a 100644 --- a/pkg/sql/tests/random_schema_test.go +++ b/pkg/sql/tests/random_schema_test.go @@ -14,13 +14,15 @@ import ( "context" gosql "database/sql" "fmt" + "math" "math/rand" "testing" + "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/spanconfig" "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/randgen" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "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" @@ -38,8 +40,15 @@ func TestCreateRandomSchema(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - params, _ := tests.CreateTestServerParams() - s, db, _ := serverutils.StartServer(t, params) + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{ + Knobs: base.TestingKnobs{ + SpanConfig: &spanconfig.TestingKnobs{ + LimiterLimitOverride: func() int64 { + return math.MaxInt64 + }, + }, + }, + }) defer s.Stopper().Stop(ctx) if _, err := db.Exec("CREATE DATABASE test; CREATE DATABASE test2"); err != nil { diff --git a/pkg/sql/tests/rsg_test.go b/pkg/sql/tests/rsg_test.go index 4fbee7e7fb32..c28470c877ca 100644 --- a/pkg/sql/tests/rsg_test.go +++ b/pkg/sql/tests/rsg_test.go @@ -22,6 +22,7 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/internal/rsg" "github.com/cockroachdb/cockroach/pkg/internal/sqlsmith" "github.com/cockroachdb/cockroach/pkg/sql" @@ -31,7 +32,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry" "github.com/cockroachdb/cockroach/pkg/sql/sem/eval" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -773,7 +773,7 @@ func testRandomSyntax( } ctx := context.Background() - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.UseDatabase = databaseName // Catch panics and return them as errors. params.Knobs.PGWireTestingKnobs = &sql.PGWireTestingKnobs{ diff --git a/pkg/sql/txn_fingerprint_id_cache_test.go b/pkg/sql/txn_fingerprint_id_cache_test.go index 7ec21e74c87c..791b8d0e0656 100644 --- a/pkg/sql/txn_fingerprint_id_cache_test.go +++ b/pkg/sql/txn_fingerprint_id_cache_test.go @@ -18,11 +18,11 @@ import ( "strconv" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/server/serverpb" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/appstatspb" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -108,7 +108,7 @@ func TestTxnFingerprintIDCache(t *testing.T) { txnFingerprintIDsRecorded := make([]appstatspb.TransactionFingerprintID, 0) appName := "testTxnFingerprintIDCache" - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.SQLExecutor = &ExecutorTestingKnobs{ BeforeTxnStatsRecorded: func( sessionData *sessiondata.SessionData, diff --git a/pkg/sql/txn_restart_test.go b/pkg/sql/txn_restart_test.go index 7c327562eebf..b327e5455d0f 100644 --- a/pkg/sql/txn_restart_test.go +++ b/pkg/sql/txn_restart_test.go @@ -212,7 +212,7 @@ func checkRestarts(t *testing.T, magicVals *filterVals) { // defer log.Scope(t).Close(t) // aborter := NewTxnAborter() // defer aborter.Close(t) -// params, cmdFilters := tests.CreateTestServerParams() +// var params base.TestServerArgs // params.Knobs.SQLExecutor = aborter.executorKnobs() // s, sqlDB, _ := serverutils.StartServer(t, params) // defer s.Stopper().Stop(context.Background()) @@ -453,7 +453,7 @@ func TestTxnAutoRetry(t *testing.T) { aborter := NewTxnAborter() defer aborter.Close(t) - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -632,7 +632,7 @@ func TestAbortedTxnOnlyRetriedOnce(t *testing.T) { aborter := NewTxnAborter() defer aborter.Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -788,7 +788,7 @@ func TestTxnUserRestart(t *testing.T) { t.Run(fmt.Sprintf("err=%s,stgy=%d", tc.expectedErr, rs), func(t *testing.T) { aborter := NewTxnAborter() defer aborter.Close(t) - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -868,7 +868,7 @@ func TestCommitWaitState(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) if _, err := sqlDB.Exec(` @@ -904,7 +904,7 @@ func TestErrorOnCommitFinalizesTxn(t *testing.T) { aborter := NewTxnAborter() defer aborter.Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -991,7 +991,7 @@ func TestRollbackInRestartWait(t *testing.T) { aborter := NewTxnAborter() defer aborter.Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLExecutor = aborter.executorKnobs() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1052,7 +1052,7 @@ func TestUnexpectedStatementInRestartWait(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1103,7 +1103,7 @@ func TestNonRetryableError(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1195,7 +1195,7 @@ func TestReacquireLeaseOnRestart(t *testing.T) { DisableMaxOffsetCheck: true, } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.Store = storeTestingKnobs params.Knobs.KVClient = clientTestingKnobs var sqlDB *gosql.DB @@ -1245,7 +1245,7 @@ func TestFlushUncommitedDescriptorCacheOnRestart(t *testing.T) { }, } - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.Store = testingKnobs s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1464,7 +1464,7 @@ func TestRollbackToSavepointFromUnusualStates(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1527,7 +1527,7 @@ func TestTxnAutoRetriesDisabledAfterResultsHaveBeenSentToClient(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -1620,7 +1620,7 @@ func TestTxnAutoRetryReasonAvailable(t *testing.T) { const numRetries = 3 retryCount := 0 - params, cmdFilters := tests.CreateTestServerParams() + params, cmdFilters := createTestServerParams() params.Knobs.SQLExecutor = &sql.ExecutorTestingKnobs{ BeforeRestart: func(ctx context.Context, reason error) { retryCount++ diff --git a/pkg/sql/type_change_test.go b/pkg/sql/type_change_test.go index b036900ecf93..47fdad6bd852 100644 --- a/pkg/sql/type_change_test.go +++ b/pkg/sql/type_change_test.go @@ -18,7 +18,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/sql" "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/serverutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" @@ -38,7 +37,7 @@ func TestTypeSchemaChangeRetriesTransparently(t *testing.T) { // Protects errorReturned. var mu syncutil.Mutex errorReturned := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.SQLTypeSchemaChanger = &sql.TypeSchemaChangerTestingKnobs{ RunBeforeExec: func() error { mu.Lock() @@ -83,7 +82,7 @@ func TestFailedTypeSchemaChangeRetriesTransparently(t *testing.T) { var mu syncutil.Mutex // Ensures just the first try to cleanup returns a retryable error. errReturned := false - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() cleanupSuccessfullyFinished := make(chan struct{}) params.Knobs.SQLTypeSchemaChanger = &sql.TypeSchemaChangerTestingKnobs{ RunBeforeExec: func() error { @@ -141,7 +140,7 @@ func TestAddDropValuesInTransaction(t *testing.T) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Decrease the adopt loop interval so that retries happen quickly. params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() @@ -281,7 +280,7 @@ func TestEnumMemberTransitionIsolation(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Protects blocker. var mu syncutil.Mutex blocker := make(chan struct{}) @@ -421,7 +420,7 @@ func TestTypeChangeJobCancelSemantics(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // Wait groups for synchronizing various parts of the test. typeSchemaChangeStarted := make(chan struct{}) diff --git a/pkg/sql/unsplit_range_test.go b/pkg/sql/unsplit_range_test.go index 17eb76e271f4..65c0770b2b04 100644 --- a/pkg/sql/unsplit_range_test.go +++ b/pkg/sql/unsplit_range_test.go @@ -268,7 +268,7 @@ func TestUnsplitRanges(t *testing.T) { ctx := context.Background() run := func(t *testing.T, tc testCase) { - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() params.Knobs.GCJob = &sql.GCJobTestingKnobs{ SkipWaitingForMVCCGC: true, diff --git a/pkg/sql/unsplit_test.go b/pkg/sql/unsplit_test.go index 331ad9846cca..7f77efbbd89b 100644 --- a/pkg/sql/unsplit_test.go +++ b/pkg/sql/unsplit_test.go @@ -19,7 +19,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" "github.com/cockroachdb/cockroach/pkg/roachpb" - "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" @@ -30,7 +29,7 @@ func TestUnsplitAt(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() // TODO(jeffreyxiao): Disable the merge queue due to a race condition. The // merge queue might issue an AdminMerge and before the actual merge happens, // the LHS of the merge is manually split and is later merged even though a diff --git a/pkg/sql/zone_config_test.go b/pkg/sql/zone_config_test.go index 51837a5eb86d..4d981db0672f 100644 --- a/pkg/sql/zone_config_test.go +++ b/pkg/sql/zone_config_test.go @@ -28,7 +28,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descs" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/isql" - "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" @@ -91,7 +90,7 @@ func waitForConfigChange(t testing.TB, s serverutils.TestServerInterface) *confi func TestGetZoneConfig(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() defaultZoneConfig := zonepb.DefaultSystemZoneConfig() defaultZoneConfig.NumReplicas = proto.Int32(1) defaultZoneConfig.RangeMinBytes = proto.Int64(1 << 20) @@ -325,7 +324,7 @@ func TestGetZoneConfig(t *testing.T) { func TestCascadingZoneConfig(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() defaultZoneConfig := zonepb.DefaultZoneConfig() defaultZoneConfig.NumReplicas = proto.Int32(1) @@ -648,7 +647,7 @@ func BenchmarkGetZoneConfig(b *testing.B) { defer leaktest.AfterTest(b)() defer log.Scope(b).Close(b) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, sqlDB, _ := serverutils.StartServer(b, params) defer s.Stopper().Stop(context.Background()) // Set the closed_timestamp interval to be short to shorten the test duration. diff --git a/pkg/sql/zone_test.go b/pkg/sql/zone_test.go index 8805417f3884..cdcb6d6ea065 100644 --- a/pkg/sql/zone_test.go +++ b/pkg/sql/zone_test.go @@ -19,7 +19,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/lexbase" - "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" @@ -32,7 +31,7 @@ func TestValidSetShowZones(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -235,7 +234,7 @@ func TestZoneInheritField(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) @@ -282,7 +281,7 @@ func TestInvalidSetShowZones(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - params, _ := tests.CreateTestServerParams() + params, _ := createTestServerParams() s, db, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 58efa90dc417..19800bdc43a1 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -2342,8 +2342,8 @@ func TestLint(t *testing.T) { ":!sql/importer/import_stmt_test.go", ":!sql/importer/read_import_mysql_test.go", ":!sql/schemachanger/sctest/test_server_factory.go", + ":!sql/server_params_test.go", ":!sql/sqlinstance/instancestorage/instancecache_test.go", - ":!sql/tests/server_params.go", ":!sql/ttl/ttljob/ttljob_test.go", ":!testutils/lint/lint_test.go", ":!ts/server_test.go", diff --git a/pkg/upgrade/upgrades/BUILD.bazel b/pkg/upgrade/upgrades/BUILD.bazel index 576db99dfbf1..7a9763355944 100644 --- a/pkg/upgrade/upgrades/BUILD.bazel +++ b/pkg/upgrade/upgrades/BUILD.bazel @@ -178,7 +178,6 @@ go_test( "//pkg/sql/sem/builtins/builtinconstants", "//pkg/sql/sem/catid", "//pkg/sql/sem/tree", - "//pkg/sql/tests", "//pkg/sql/types", "//pkg/storage", "//pkg/testutils", diff --git a/pkg/upgrade/upgrades/schemachanger_elements_test.go b/pkg/upgrade/upgrades/schemachanger_elements_test.go index 844cf4ff4df1..14159e7e8841 100644 --- a/pkg/upgrade/upgrades/schemachanger_elements_test.go +++ b/pkg/upgrade/upgrades/schemachanger_elements_test.go @@ -17,6 +17,7 @@ import ( "testing" "time" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" @@ -24,7 +25,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scop" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan" - "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/util" @@ -108,7 +108,7 @@ func TestUpgradeSchemaChangerElements(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - params, _ := tests.CreateTestServerParams() + var params base.TestServerArgs params.Knobs.Server = &server.TestingKnobs{ DisableAutomaticVersionUpgrade: make(chan struct{}), BinaryVersionOverride: clusterversion.ByKey(clusterversion.V23_1_SchemaChangerDeprecatedIndexPredicates - 1), diff --git a/pkg/util/rangedesc/BUILD.bazel b/pkg/util/rangedesc/BUILD.bazel index 6130fbabf50f..3f39b4d48633 100644 --- a/pkg/util/rangedesc/BUILD.bazel +++ b/pkg/util/rangedesc/BUILD.bazel @@ -24,17 +24,18 @@ go_test( data = glob(["testdata/**"]), deps = [ ":rangedesc", + "//pkg/base", "//pkg/keys", "//pkg/kv/kvserver", "//pkg/roachpb", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/server", - "//pkg/sql/tests", "//pkg/testutils/datapathutils", "//pkg/testutils/serverutils", "//pkg/testutils/testcluster", "//pkg/util/leaktest", + "//pkg/util/log", "@com_github_cockroachdb_datadriven//:datadriven", "@com_github_stretchr_testify//require", ], diff --git a/pkg/util/rangedesc/rangedesc_test.go b/pkg/util/rangedesc/rangedesc_test.go index ecd89073ece1..69ff15b8866b 100644 --- a/pkg/util/rangedesc/rangedesc_test.go +++ b/pkg/util/rangedesc/rangedesc_test.go @@ -16,13 +16,14 @@ import ( "strings" "testing" + "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv/kvserver" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/rangedesc" "github.com/cockroachdb/datadriven" "github.com/stretchr/testify/require" @@ -66,8 +67,7 @@ func TestEverythingScanner(t *testing.T) { ctx := context.Background() for _, s := range splits { t.Run(fmt.Sprintf("with-splits-at=%s", s), func(t *testing.T) { - params, _ := tests.CreateTestServerParams() - server, _, kvDB := serverutils.StartServer(t, params) + server, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) defer server.Stopper().Stop(context.Background()) for _, split := range s { @@ -111,11 +111,13 @@ func TestEverythingScanner(t *testing.T) { // - "split" [set=] func TestDataDriven(t *testing.T) { defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) datadriven.Walk(t, datapathutils.TestDataPath(t), func(t *testing.T, path string) { ctx := context.Background() - params, _ := tests.CreateTestServerParams() - server, _, kvDB := serverutils.StartServer(t, params) + server, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{ + DefaultTestTenant: base.TestIsSpecificToStorageLayerAndNeedsASystemTenant, + }) defer server.Stopper().Stop(context.Background()) scanner := rangedesc.NewScanner(kvDB) @@ -185,8 +187,7 @@ func TestIterator(t *testing.T) { ctx := context.Background() for _, s := range splits { t.Run(fmt.Sprintf("with-splits-at=%s", s), func(t *testing.T) { - params, _ := tests.CreateTestServerParams() - server, _, kvDB := serverutils.StartServer(t, params) + server, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{}) defer server.Stopper().Stop(context.Background()) for _, split := range s {