From 878c632883b9b4b56797086bf23c9ad483ad3822 Mon Sep 17 00:00:00 2001 From: Rebecca Taft Date: Tue, 18 Jan 2022 20:00:43 -0600 Subject: [PATCH] sql: deflake TestPerfLogging 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 #74811 Release note: None --- pkg/sql/event_log_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/sql/event_log_test.go b/pkg/sql/event_log_test.go index d64a036d18d7..42087939d08f 100644 --- a/pkg/sql/event_log_test.go +++ b/pkg/sql/event_log_test.go @@ -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, }, @@ -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, }, @@ -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, }, @@ -559,7 +559,7 @@ 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, }, @@ -567,7 +567,7 @@ 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_read_limit"`, + logRe: `"EventType":"txn_rows_read_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`, logExpected: false, channel: channel.SQL_PERF, }, @@ -575,7 +575,7 @@ 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_INTERNAL_PERF, }, @@ -583,7 +583,7 @@ 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_read_limit"`, + logRe: `"EventType":"txn_rows_read_limit","Statement":"CREATE.*","TxnID":".*","SessionID":".*"`, logExpected: false, channel: channel.SQL_INTERNAL_PERF, }, @@ -591,7 +591,7 @@ func TestPerfLogging(t *testing.T) { 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, }, @@ -599,7 +599,7 @@ func TestPerfLogging(t *testing.T) { 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, }, @@ -607,7 +607,7 @@ func TestPerfLogging(t *testing.T) { 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, }, @@ -615,21 +615,21 @@ func TestPerfLogging(t *testing.T) { 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, },