Skip to content

Commit

Permalink
persistedsqlstats: simplify TestSQLStatsCompactionJobMarkedAsAutomatic
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Apr 28, 2023
1 parent 8365895 commit 4183fc2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/sql/sqlstats/persistedsqlstats/compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,18 @@ func TestSQLStatsCompactionJobMarkedAsAutomatic(t *testing.T) {
params, _ := tests.CreateTestServerParams()
params.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals()

t.Logf("starting test server")
ctx := context.Background()
tc := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{
ServerArgs: params,
})
defer tc.Stopper().Stop(ctx)
server, conn, _ := serverutils.StartServer(t, params)
defer server.Stopper().Stop(ctx)

server := tc.Server(0 /* idx */)
conn := tc.ServerConn(0 /* idx */)
sqlDB := sqlutils.MakeSQLRunner(conn)

t.Logf("launching the stats compaction job")
jobID, err := launchSQLStatsCompactionJob(server)
require.NoError(t, err)

t.Logf("checking the job status")
// Ensure the sqlstats job is hidden from the SHOW JOBS command.
sqlDB.CheckQueryResults(
t,
Expand All @@ -294,6 +293,8 @@ func TestSQLStatsCompactionJobMarkedAsAutomatic(t *testing.T) {
fmt.Sprintf("SELECT count(*) FROM [SHOW AUTOMATIC JOBS] WHERE job_id = %d", jobID),
[][]string{{"1"}},
)

t.Logf("test complete")
}

func launchSQLStatsCompactionJob(server serverutils.TestServerInterface) (jobspb.JobID, error) {
Expand Down

0 comments on commit 4183fc2

Please sign in to comment.