darold / pgbadger

A fast PostgreSQL Log Analyzer
http://pgbadger.darold.net/
PostgreSQL License
3.55k stars 352 forks source link

Syslog test breaks every year #715

Closed df7cb closed 2 years ago

df7cb commented 2 years ago

Since syslog timestamps do not contain the year, the t/04_advanced.t now breaks since it's now February 2022:

grep: /tmp/pgbadger_data_tmp/pgbench/2021/week-07/index.html: Datei oder Verzeichnis nicht gefunden
not ok 4 - Test incremental mode with --explode and --dbname
#   Failed test 'Test incremental mode with --explode and --dbname'
#   at t/04_advanced.t line 32.
$ret = `perl pgbadger -q --dbname=pgbench --explode -I -O $incr_outdir $SYSLOG1 $SYSLOG2 && ls $incr_outdir | grep ">12,474 queries" $incr_outdir/pgbench/2021/week-07/index.html`;
Feb 11 13:15:39 test-pc postgres[10808]: [1-1] db=,user=,app=,client= LOG:  listening on IPv4 address "127.0.0.1", port 5432
$ tree /tmp/pgbadger_data_tmp/pgbench/
/tmp/pgbadger_data_tmp/pgbench//
├── 2022/
│   ├── 02/
│   │   └── 11/
│   │       └── index.html
│   └── week-07/
│       └── index.html
└── index.html

Simply replacing 2021 by the current year won't work since the week number of Feb 11 will change. Maybe grep ... $incr_outdir/pgbench/*/week-0*/index.html is the way to go.