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 authored and Gerardo Torres committed Jan 24, 2022
1 parent 5a557cf commit 878c632
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/sql/event_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func TestPerfLogging(t *testing.T) {
{
query: `INSERT INTO t(i) VALUES (6)`,
errRe: ``,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"INSERT INTO.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
Expand Down Expand Up @@ -483,14 +483,14 @@ func TestPerfLogging(t *testing.T) {
cleanup: `RESET transaction_rows_written_err`,
query: `INSERT INTO t(i) VALUES (15), (16)`,
errRe: `pq: txn has written 2 rows, which is above the limit: TxnID .* SessionID .*`,
logRe: `"EventType":"txn_rows_written_limit"`,
logRe: `"EventType":"txn_rows_written_limit","Statement":"INSERT INTO.*","TxnID":".*","SessionID":".*"`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
query: `SELECT * FROM t WHERE i = 6`,
errRe: ``,
logRe: `"EventType":"txn_rows_read_limit"`,
logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› = ‹6›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
logExpected: false,
channel: channel.SQL_PERF,
},
Expand Down 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 878c632

Please sign in to comment.