Skip to content

Commit

Permalink
sql: deflake TestPerfLogging
Browse files Browse the repository at this point in the history
This commit deflakes TestPerfLogging by ensuring that test cases
that should not produce log entries do not match with unrelated log
entries and thus cause the test to fail. This is ensured by making
the regex more precise for the specific test case.

Fixes cockroachdb#74811

Release note: None
  • Loading branch information
rytaft committed Jan 19, 2022
1 parent b917f1e commit a33f059
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/sql/event_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func TestPerfLogging(t *testing.T) {
cleanup: `RESET transaction_rows_read_err`,
query: `SELECT * FROM t WHERE i = 6 OR i = 7`,
errRe: `pq: txn has read 2 rows, which is above the limit: TxnID .* SessionID .*`,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› = ‹6› OR ‹i› = ‹7›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
logExpected: false,
channel: channel.SQL_PERF,
},
Expand All @@ -559,77 +559,77 @@ func TestPerfLogging(t *testing.T) {
cleanup: `DROP TABLE t_copy`,
query: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
errRe: ``,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
cleanup: `DROP TABLE t_copy`,
query: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
cleanup: `DROP TABLE t_copy`,
query: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
errRe: ``,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_INTERNAL_PERF,
},
{
cleanup: `DROP TABLE t_copy`,
query: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_INTERNAL_PERF,
},
{
setup: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
query: `DROP TABLE t_copy`,
errRe: ``,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"DROP.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
setup: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
query: `DROP TABLE t_copy`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"DROP.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
setup: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
query: `DROP TABLE t_copy`,
errRe: ``,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"DROP.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_INTERNAL_PERF,
},
{
setup: `CREATE TABLE t_copy (i PRIMARY KEY) AS SELECT i FROM t`,
query: `DROP TABLE t_copy`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"DROP.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_INTERNAL_PERF,
},
{
query: `ANALYZE t`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"ANALYZE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
query: `ANALYZE t`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"ANALYZE.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_INTERNAL_PERF,
},
Expand Down

0 comments on commit a33f059

Please sign in to comment.