Skip to content

Commit

Permalink
scl/pgsql: add test case with extra fields
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <[email protected]>
  • Loading branch information
OverOrion committed Nov 10, 2023
1 parent 88ae483 commit f1322d6
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,42 @@
},
},
),
(
# Log with query_id(v14+), backend_type(v13+)
r'2023-11-03 16:32:35.084 CET,"postgres","bench_test",3451998,"[local]",65451258.34ac5e,632376,"UPDATE",2023-11-03 16:31:36 CET,6/45171,228887,LOG,00000,"duration: 0.081 ms",,,,,,,,,"pgbench","client backend",,1521477082073268809',
{
"DATE": "Nov 3 16:32:35",
"HOST_FROM": "localhost",
"MSG": r'automatic vacuum of table "tablename": index scans: 0 pages: 0 removed, 4 remain, 0 skipped due to pins, 0 skipped frozen tuples: 114 removed, 268 remain, 0 are dead but not yet removable, oldest xmin: 149738000 buffer usage: 97 hits, 0 misses, 6 dirtied avg read rate: 0.000 MB/s, avg write rate: 114.609 MB/s system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s',
"PID": 3451998,
"SEVERITY": "info",
"_pgsql": {
"application_name": "",
"command_tag": "",
"connection_from": "localhost",
"context": "",
"database": "",
"detail": "",
"hint": "",
"internal_query": "",
"location": "",
"message": r'automatic vacuum of table "tablename": index scans: 0 pages: 0 removed, 4 remain, 0 skipped due to pins, 0 skipped frozen tuples: 114 removed, 268 remain, 0 are dead but not yet removable, oldest xmin: 149738000 buffer usage: 97 hits, 0 misses, 6 dirtied avg read rate: 0.000 MB/s, avg write rate: 114.609 MB/s system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s',
"pid": 22113,
"query": "",
"session_id": "65451258.34ac5e",
"session_line_num": 632376,
"session_start_time": "2023-11-03 16:31:36 CET",
"severity": "LOG",
"sql_state_code": "00000",
"timestamp": "2023-11-03 16:32:35.084 CET",
"transaction_id": "0",
"username": "",
"virtual_transaction_id": "",
"query_id": 1521477082073268809,
"backend_type": "client backend",
},
},
),
]


Expand Down Expand Up @@ -159,3 +195,9 @@ def test_postgresql_csvlog_parser(config, port_allocator, syslog_ng, input_messa
# If field is filled
if "timestamp" in expected_kv_pairs["_pgsql"]:
assert output_json["_pgsql"]["timestamp"] == expected_kv_pairs["_pgsql"]["timestamp"]

# Optional, extra fields
extra_fields = ["query_id", "backend_type"]
for extra_field in extra_fields:
if extra_field in expected_kv_pairs["_pgsql"]:
assert output_json["_pgsql"][extra_field] == expected_kv_pairs["_pgsql"][extra_field]

0 comments on commit f1322d6

Please sign in to comment.