Skip to content

Commit

Permalink
sql: deflake TestTrace
Browse files Browse the repository at this point in the history
This has been seen to flake in CI:

```
=== RUN   TestTrace/ShowTraceForVectorized/TracingOff/node-1
    trace_test.go:386: expected span: "session recording", got: "pendingLeaseRequest: requesting lease"
    trace_test.go:397: remaining span: "session recording"
    trace_test.go:397: remaining span: "sql query"
    trace_test.go:397: remaining span: "sql txn"
    trace_test.go:397: remaining span: "txn coordinator send"
            --- FAIL: TestTrace/ShowTraceForVectorized/TracingOff/node-1 (0.02s)
```

There was already an exception for this span, but with a `storage.`
prefix. This patch removes the prefix, and makes it match on substrings.

This flake has possibly been made worse with the introduction of a
metamorphic setting to only use expiration-based leases in ecc931b.

Epic: none
Release note: None
  • Loading branch information
erikgrinaker committed Mar 20, 2023
1 parent 6839729 commit c7641af
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/sql/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestTrace(t *testing.T) {
// These are always appended, even without the test specifying it.
alwaysOptionalSpans := []string{
"drain",
"storage.pendingLeaseRequest: requesting lease",
"storage.Store: gossip on capacity change",
"pendingLeaseRequest: requesting lease",
"gossip on capacity change",
"outbox",
"request range lease",
"range lookup",
Expand Down Expand Up @@ -364,17 +364,22 @@ func TestTrace(t *testing.T) {
}
defer rows.Close()

ignoreSpans := make(map[string]bool)
for _, s := range test.optionalSpans {
ignoreSpans[s] = true
ignoreSpan := func(op string) bool {
for _, s := range test.optionalSpans {
if strings.Contains(op, s) {
return true
}
}
return false
}

r := 0
for rows.Next() {
var op string
if err := rows.Scan(&op); err != nil {
t.Fatal(err)
}
if ignoreSpans[op] {
if ignoreSpan(op) {
continue
}

Expand All @@ -391,7 +396,7 @@ func TestTrace(t *testing.T) {
if err := rows.Scan(&op); err != nil {
t.Fatal(err)
}
if ignoreSpans[op] {
if ignoreSpan(op) {
continue
}
t.Errorf("remaining span: %q", op)
Expand Down

0 comments on commit c7641af

Please sign in to comment.