@@ -26,6 +26,7 @@ import (
26
26
"github.com/cockroachdb/cockroach/pkg/sql/clusterunique"
27
27
"github.com/cockroachdb/cockroach/pkg/sql/contention"
28
28
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
29
+ "github.com/cockroachdb/cockroach/pkg/sql/sqlstats"
29
30
"github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights"
30
31
"github.com/cockroachdb/cockroach/pkg/testutils"
31
32
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
@@ -89,7 +90,7 @@ func TestInsightsIntegration(t *testing.T) {
89
90
require .NoError (t , err )
90
91
91
92
// Eventually see one recorded insight.
92
- testutils .SucceedsWithin (t , func () error {
93
+ testutils .SucceedsSoon (t , func () error {
93
94
row = conn .QueryRowContext (ctx , "SELECT count(*), coalesce(string_agg(query, ';'),'') " +
94
95
"FROM crdb_internal.cluster_execution_insights where app_name = $1 " , appName )
95
96
if err = row .Scan (& count , & queryText ); err != nil {
@@ -99,10 +100,10 @@ func TestInsightsIntegration(t *testing.T) {
99
100
return fmt .Errorf ("expected 1, but was %d, queryText:%s" , count , queryText )
100
101
}
101
102
return nil
102
- }, 1 * time . Second )
103
+ })
103
104
104
105
// Verify the table content is valid.
105
- testutils .SucceedsWithin (t , func () error {
106
+ testutils .SucceedsSoon (t , func () error {
106
107
row = conn .QueryRowContext (ctx , "SELECT " +
107
108
"query, " +
108
109
"status, " +
@@ -147,12 +148,12 @@ func TestInsightsIntegration(t *testing.T) {
147
148
}
148
149
149
150
return nil
150
- }, 1 * time . Second )
151
+ })
151
152
152
153
// TODO (xzhang) Turn this into a datadriven test
153
154
// https://github.com/cockroachdb/cockroach/issues/95010
154
155
// Verify the txn table content is valid.
155
- testutils .SucceedsWithin (t , func () error {
156
+ testutils .SucceedsSoon (t , func () error {
156
157
row = conn .QueryRowContext (ctx , "SELECT " +
157
158
"query, " +
158
159
"start_time, " +
@@ -194,7 +195,7 @@ func TestInsightsIntegration(t *testing.T) {
194
195
}
195
196
196
197
return nil
197
- }, 1 * time . Second )
198
+ })
198
199
}
199
200
200
201
func TestFailedInsights (t * testing.T ) {
@@ -275,8 +276,7 @@ func TestFailedInsights(t *testing.T) {
275
276
_ , _ = conn .ExecContext (ctx , tc .stmt )
276
277
277
278
var query , status , problem , errorCode , errorMsg string
278
- testutils .SucceedsWithin (t , func () error {
279
-
279
+ testutils .SucceedsSoon (t , func () error {
280
280
// Query the node execution insights table.
281
281
row := conn .QueryRowContext (ctx , `
282
282
SELECT query,
@@ -289,7 +289,7 @@ WHERE query = $1 AND app_name = $2 `,
289
289
tc .fingerprint , appName )
290
290
291
291
return row .Scan (& query , & status , & problem , & errorCode , & errorMsg )
292
- }, 1 * time . Second )
292
+ })
293
293
294
294
require .Equal (t , tc .status , status )
295
295
require .Equal (t , tc .problem , problem )
@@ -362,7 +362,7 @@ WHERE query = $1 AND app_name = $2 `,
362
362
}
363
363
364
364
var query , problems , status , errorCode , errorMsg string
365
- testutils .SucceedsWithin (t , func () error {
365
+ testutils .SucceedsSoon (t , func () error {
366
366
367
367
// Query the node txn execution insights table.
368
368
row := conn .QueryRowContext (ctx , `
@@ -375,7 +375,7 @@ FROM crdb_internal.node_txn_execution_insights
375
375
WHERE query = $1 AND app_name = $2` , tc .fingerprint , appName )
376
376
377
377
return row .Scan (& query , & problems , & status , & errorCode , & errorMsg )
378
- }, 1 * time . Second )
378
+ })
379
379
380
380
require .Equal (t , tc .txnStatus , status )
381
381
require .Equal (t , tc .errorCode , errorCode )
@@ -587,7 +587,7 @@ func TestInsightsPriorityIntegration(t *testing.T) {
587
587
_ , err = conn .ExecContext (ctx , "SELECT pg_sleep(.11)" )
588
588
require .NoError (t , err )
589
589
590
- testutils .SucceedsWithin (t , func () error {
590
+ testutils .SucceedsSoon (t , func () error {
591
591
row := conn .QueryRowContext (ctx , "SELECT " +
592
592
"implicit_txn " +
593
593
"FROM crdb_internal.node_execution_insights where " +
@@ -604,7 +604,7 @@ func TestInsightsPriorityIntegration(t *testing.T) {
604
604
}
605
605
606
606
return nil
607
- }, 2 * time . Second )
607
+ })
608
608
609
609
var priorities = []struct {
610
610
setPriorityQuery string
@@ -639,7 +639,7 @@ func TestInsightsPriorityIntegration(t *testing.T) {
639
639
}
640
640
641
641
for _ , p := range priorities {
642
- testutils .SucceedsWithin (t , func () error {
642
+ testutils .SucceedsSoon (t , func () error {
643
643
tx , errTxn := conn .BeginTx (ctx , & gosql.TxOptions {})
644
644
require .NoError (t , errTxn )
645
645
@@ -654,9 +654,9 @@ func TestInsightsPriorityIntegration(t *testing.T) {
654
654
errTxn = tx .Commit ()
655
655
require .NoError (t , errTxn )
656
656
return nil
657
- }, 2 * time . Second )
657
+ })
658
658
659
- testutils .SucceedsWithin (t , func () error {
659
+ testutils .SucceedsSoon (t , func () error {
660
660
row := conn .QueryRowContext (ctx , "SELECT " +
661
661
"query, " +
662
662
"priority, " +
@@ -685,7 +685,7 @@ func TestInsightsPriorityIntegration(t *testing.T) {
685
685
}
686
686
687
687
return nil
688
- }, 2 * time . Second )
688
+ })
689
689
}
690
690
}
691
691
@@ -911,7 +911,7 @@ func TestInsightsIndexRecommendationIntegration(t *testing.T) {
911
911
}
912
912
913
913
// Verify the table content is valid.
914
- testutils .SucceedsWithin (t , func () error {
914
+ testutils .SucceedsSoon (t , func () error {
915
915
rows , err := sqlConn .QueryContext (ctx , "SELECT " +
916
916
"query, " +
917
917
"array_to_string(index_recommendations, ';') as cmb_index_recommendations " +
@@ -952,7 +952,7 @@ func TestInsightsIndexRecommendationIntegration(t *testing.T) {
952
952
}
953
953
954
954
return nil
955
- }, 1 * time . Second )
955
+ })
956
956
}
957
957
958
958
// TestInsightsClearsPerSessionMemory ensures that memory allocated
@@ -966,8 +966,8 @@ func TestInsightsClearsPerSessionMemory(t *testing.T) {
966
966
clearedSessionID := clusterunique.ID {}
967
967
ts := serverutils .StartServerOnly (t , base.TestServerArgs {
968
968
Knobs : base.TestingKnobs {
969
- Insights : & insights .TestingKnobs {
970
- OnSessionClear : func (sessionID clusterunique.ID ) {
969
+ SQLStatsKnobs : & sqlstats .TestingKnobs {
970
+ OnIngesterSessionClear : func (sessionID clusterunique.ID ) {
971
971
defer close (sessionClosedCh )
972
972
clearedSessionID = sessionID
973
973
},
0 commit comments