Skip to content

Commit d80da8b

Browse files
committed
sql: ignore optional spans in TestTrace for tenants
Release note: None
1 parent a053744 commit d80da8b

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

pkg/sql/trace_test.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import (
3737

3838
func TestTrace(t *testing.T) {
3939
defer leaktest.AfterTest(t)()
40+
defer log.Scope(t).Close(t)
41+
4042
skip.UnderRace(t, "does too much work under race, see: "+
4143
"https://github.com/cockroachdb/cockroach/pull/56343#issuecomment-733577377")
4244

43-
defer log.Scope(t).Close(t)
44-
4545
// These are always appended, even without the test specifying it.
4646
alwaysOptionalSpans := []string{
4747
"drain",
@@ -61,33 +61,30 @@ func TestTrace(t *testing.T) {
6161
"/cockroach.sql.distsqlrun.DistSQL/FlowStream",
6262
"noop",
6363
}
64-
nonVectorizedExpSpans := []string{
64+
// These are optional if we use a test tenant.
65+
tenantOptionalSpans := []string{
66+
"/cockroach.roachpb.Internal/RangeLookup",
67+
"executeWriteBatch",
68+
}
69+
commonExpSpans := []string{
6570
"session recording",
6671
"sql txn",
6772
"sql query",
6873
"optimizer",
6974
"flow",
70-
"table reader",
7175
"consuming rows",
7276
"txn coordinator send",
7377
"dist sender send",
7478
"/cockroach.roachpb.Internal/Batch",
7579
"commit sql txn",
7680
}
77-
vectorizedExpSpans := []string{
78-
"session recording",
79-
"sql txn",
80-
"sql query",
81-
"optimizer",
82-
"flow",
81+
nonVectorizedExpSpans := append(append([]string(nil), commonExpSpans...), []string{
82+
"table reader",
83+
}...)
84+
vectorizedExpSpans := append(append([]string(nil), commonExpSpans...), []string{
8385
"batch flow coordinator",
8486
"colbatchscan",
85-
"consuming rows",
86-
"txn coordinator send",
87-
"dist sender send",
88-
"/cockroach.roachpb.Internal/Batch",
89-
"commit sql txn",
90-
}
87+
}...)
9188

9289
getRows := func(t *testing.T, sqlDB *gosql.DB, distsql, vectorize string, useShowTraceFor bool) (*gosql.Rows, string, error) {
9390
if _, err := sqlDB.Exec(fmt.Sprintf("SET distsql = %s", distsql)); err != nil {
@@ -211,6 +208,9 @@ func TestTrace(t *testing.T) {
211208
if test.distSQL == "on" {
212209
optionalSpans = append(optionalSpans, distsqlOptionalSpans...)
213210
}
211+
if cluster.StartedDefaultTestTenant() {
212+
optionalSpans = append(optionalSpans, tenantOptionalSpans...)
213+
}
214214
expSpans := nonVectorizedExpSpans
215215
if test.vectorize == "on" {
216216
expSpans = vectorizedExpSpans
@@ -377,7 +377,6 @@ func TestTraceFieldDecomposition(t *testing.T) {
377377
if err := rows.Scan(&msg, &ct, &loc); err != nil {
378378
t.Fatal(err)
379379
}
380-
t.Logf("received trace: %q // %q // %q", msg, ct, loc)
381380
// Check that brackets are properly balanced.
382381
if len(ct) > 0 && ct[0] == '[' {
383382
if ct[len(ct)-1] != ']' {
@@ -420,7 +419,6 @@ func TestTraceFieldDecomposition(t *testing.T) {
420419
if err := rows.Scan(&msg, &ct); err != nil {
421420
t.Fatal(err)
422421
}
423-
t.Logf("received trace: %q // %q", msg, ct)
424422
// Check that brackets are properly balanced.
425423
if len(ct) > 0 && ct[0] == '[' {
426424
if ct[len(ct)-1] != ']' {

0 commit comments

Comments
 (0)