From adc5df307a4ef5d9732ef93c6c0a4d25c77f14d6 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Wed, 29 Jun 2011 23:02:53 -0400 Subject: [PATCH] Test file tweaks for new output. --- check_postgres.pl | 1 + t/02_autovac_freeze.t | 2 +- t/02_backends.t | 2 +- t/02_bloat.t | 2 +- t/02_checkpoint.t | 2 +- t/02_connection.t | 2 +- t/02_custom_query.t | 2 +- t/02_database_commitratio.t | 2 +- t/02_database_hitratio.t | 2 +- t/02_database_size.t | 2 +- t/02_fsm_pages.t | 2 +- t/02_fsm_relations.t | 2 +- t/02_locks.t | 2 +- t/02_new_version_bc.t | 2 +- t/02_new_version_box.t | 2 +- t/02_new_version_cp.t | 2 +- t/02_new_version_pg.t | 2 +- t/02_new_version_tnm.t | 2 +- t/02_prepared_txns.t | 2 +- t/02_replicate_row.t | 2 +- t/02_sequence.t | 2 +- t/02_slony_status.t | 2 +- t/02_version.t | 2 +- t/02_wal_files.t | 2 +- 24 files changed, 24 insertions(+), 23 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index 4c204b19f..044f42080 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -1394,6 +1394,7 @@ sub add_response { $dbhost, $dbport; $header =~ s/\s+$//; + $header =~ s/^ //; my $perf = ($opt{showtime} and $db->{totaltime} and $action ne 'bloat') ? "time=$db->{totaltime}s" : ''; if ($db->{perf}) { $db->{perf} =~ s/^ +//; diff --git a/t/02_autovac_freeze.t b/t/02_autovac_freeze.t index 9f692071f..4fd585d3f 100644 --- a/t/02_autovac_freeze.t +++ b/t/02_autovac_freeze.t @@ -35,7 +35,7 @@ $t = qq{$S identifies host}; like ($result, qr{host:$host}, $t); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid --warning option}; like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t); diff --git a/t/02_backends.t b/t/02_backends.t index dbc94ef98..ed34ecb30 100644 --- a/t/02_backends.t +++ b/t/02_backends.t @@ -55,7 +55,7 @@ SKIP: { } $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid warning option}; like ($cp->run('-w felz'), qr{^ERROR: Warning}, $t); diff --git a/t/02_bloat.t b/t/02_bloat.t index 82014509a..cbb9c0101 100644 --- a/t/02_bloat.t +++ b/t/02_bloat.t @@ -22,7 +22,7 @@ my $label = 'POSTGRES_BLOAT'; my $tname = 'cp_bloat_test'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid option}; like ($cp->run('-w=abc'), qr{must be a size or a percentage}, $t); diff --git a/t/02_checkpoint.t b/t/02_checkpoint.t index 83349000c..724e695b8 100644 --- a/t/02_checkpoint.t +++ b/t/02_checkpoint.t @@ -20,7 +20,7 @@ my $S = q{Action 'checkpoint'}; my $label = 'POSTGRES_CHECKPOINT'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called without warning or critical}; like ($cp->run(''), qr{Must provide a warning and/or critical}, $t); diff --git a/t/02_connection.t b/t/02_connection.t index 6e1c51158..d6fd219e1 100644 --- a/t/02_connection.t +++ b/t/02_connection.t @@ -35,7 +35,7 @@ $t=qq{$S returned correct version}; like ($result, qr{ \| time=\d\.\d\ds\s$}, $t); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid warning option}; like ($cp->run('-w felz'), qr{^ERROR: No warning}, $t); diff --git a/t/02_custom_query.t b/t/02_custom_query.t index 791a0dee3..276f62dad 100644 --- a/t/02_custom_query.t +++ b/t/02_custom_query.t @@ -33,7 +33,7 @@ $t = qq{$S identifies host}; like ($result, qr{host:$host}, $t); $t = qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t = qq{$S handles 'string' type for non-match}; like ($cp->run(qq{--query="$good_query" --valtype=string --warning=abc}), diff --git a/t/02_database_commitratio.t b/t/02_database_commitratio.t index cb7f35475..6daad1e5e 100644 --- a/t/02_database_commitratio.t +++ b/t/02_database_commitratio.t @@ -34,7 +34,7 @@ $t=qq{$S returned expected text when warning level and critical level are specif like ($cp->run('-w 0% -c 0%'), qr{^$label OK:}, $t); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid warning option}; like ($cp->run('-w felz'), qr{^ERROR: Invalid 'warning' option: must be a percentage}, $t); diff --git a/t/02_database_hitratio.t b/t/02_database_hitratio.t index 5fcd98699..8564de1e0 100644 --- a/t/02_database_hitratio.t +++ b/t/02_database_hitratio.t @@ -34,7 +34,7 @@ $t=qq{$S returned expected text when warning level and critical level are specif like ($cp->run('-w 0% -c 0%'), qr{^$label OK:}, $t); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid warning option}; like ($cp->run('-w felz'), qr{^ERROR: Invalid 'warning' option: must be a percentage}, $t); diff --git a/t/02_database_size.t b/t/02_database_size.t index 0aa6d9d49..87ed11ce9 100644 --- a/t/02_database_size.t +++ b/t/02_database_size.t @@ -53,7 +53,7 @@ $t=qq{$S returned expected text when warning level and critical level are specif like ($cp->run('-w 10GB -c 20GB'), qr{^$label OK:}, $t); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid warning option}; like ($cp->run('-w felz'), qr{^ERROR: Invalid size}, $t); diff --git a/t/02_fsm_pages.t b/t/02_fsm_pages.t index b67331171..bbe5a97e5 100644 --- a/t/02_fsm_pages.t +++ b/t/02_fsm_pages.t @@ -20,7 +20,7 @@ my $S = q{Action 'fsm_pages'}; my $label = 'POSTGRES_FSM_PAGES'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid option}; like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t); diff --git a/t/02_fsm_relations.t b/t/02_fsm_relations.t index a4218c190..ebb21c253 100644 --- a/t/02_fsm_relations.t +++ b/t/02_fsm_relations.t @@ -20,7 +20,7 @@ my $S = q{Action 'fsm_relations'}; my $label = 'POSTGRES_FSM_RELATIONS'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid option}; like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t); diff --git a/t/02_locks.t b/t/02_locks.t index ddf077d0b..0f497c1b9 100644 --- a/t/02_locks.t +++ b/t/02_locks.t @@ -20,7 +20,7 @@ my $S = q{Action 'locks'}; my $label = 'POSTGRES_LOCKS'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when invalid database used}; like ($cp->run('--dbname=foo'), qr{database "foo" does not exist}, $t); diff --git a/t/02_new_version_bc.t b/t/02_new_version_bc.t index f6aff082a..7e802db7c 100644 --- a/t/02_new_version_bc.t +++ b/t/02_new_version_bc.t @@ -20,7 +20,7 @@ my $S = q{Action 'new_version_bc'}; my $label = 'POSTGRES_NEW_VERSION_BC'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); ## No other tests for now diff --git a/t/02_new_version_box.t b/t/02_new_version_box.t index c6920d52d..b41539b8e 100644 --- a/t/02_new_version_box.t +++ b/t/02_new_version_box.t @@ -20,7 +20,7 @@ my $S = q{Action 'new_version_box'}; my $label = 'POSTGRES_NEW_VERSION_BOX'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); ## No other tests for now diff --git a/t/02_new_version_cp.t b/t/02_new_version_cp.t index 3a2c100b2..dc47b0196 100644 --- a/t/02_new_version_cp.t +++ b/t/02_new_version_cp.t @@ -20,7 +20,7 @@ my $S = q{Action 'new_version_cp'}; my $label = 'POSTGRES_NEW_VERSION_CP'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S returns warning for mismatched major version}; $cp->fake_self_version('1.2.3'); diff --git a/t/02_new_version_pg.t b/t/02_new_version_pg.t index 496833094..2829f86f6 100644 --- a/t/02_new_version_pg.t +++ b/t/02_new_version_pg.t @@ -20,7 +20,7 @@ my $S = q{Action 'new_version_pg'}; my $label = 'POSTGRES_NEW_VERSION_PG'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S returns unknown for bizarre Postgres version}; $cp->fake_version('7.8.12'); diff --git a/t/02_new_version_tnm.t b/t/02_new_version_tnm.t index a03c0b269..5d1b253d8 100644 --- a/t/02_new_version_tnm.t +++ b/t/02_new_version_tnm.t @@ -20,7 +20,7 @@ my $S = q{Action 'new_version_tnm'}; my $label = 'POSTGRES_NEW_VERSION_TNM'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); ## No other tests for now diff --git a/t/02_prepared_txns.t b/t/02_prepared_txns.t index 8cf835783..d588a28ca 100644 --- a/t/02_prepared_txns.t +++ b/t/02_prepared_txns.t @@ -20,7 +20,7 @@ my $S = q{Action 'prepare_txns'}; my $label = 'POSTGRES_PREPARED_TXNS'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); my $ver = $dbh->{pg_server_version}; if ($ver < 80100) { diff --git a/t/02_replicate_row.t b/t/02_replicate_row.t index 0fec72f7c..8aee019be 100644 --- a/t/02_replicate_row.t +++ b/t/02_replicate_row.t @@ -41,7 +41,7 @@ $dbh->commit(); $dbh2->commit(); $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called without warning or critical}; like ($cp->run(''), qr{Must provide a warning and/or critical}, $t); diff --git a/t/02_sequence.t b/t/02_sequence.t index fcbea4e1f..84333005d 100644 --- a/t/02_sequence.t +++ b/t/02_sequence.t @@ -20,7 +20,7 @@ my $S = q{Action 'sequence'}; my $label = 'POSTGRES_SEQUENCE'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid option}; like ($cp->run('--warning=80'), qr{ERROR:.+must be a percentage}, $t); diff --git a/t/02_slony_status.t b/t/02_slony_status.t index 325bec716..eb9c2d137 100644 --- a/t/02_slony_status.t +++ b/t/02_slony_status.t @@ -20,7 +20,7 @@ my $S = q{Action 'slony_status'}; my $label = 'POSTGRES_SLONY_STATUS'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with invalid warning}; like ($cp->run('-w foo'), qr{ERROR:.+'warning' must be a valid time}, $t); diff --git a/t/02_version.t b/t/02_version.t index fe5c54a0c..77703ac95 100644 --- a/t/02_version.t +++ b/t/02_version.t @@ -20,7 +20,7 @@ my $S = q{Action 'version'}; my $label = 'POSTGRES_VERSION'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with MRTG but no option}; like ($cp->run('--output=mrtg'), qr{ERROR: Invalid mrtg}, $t); diff --git a/t/02_wal_files.t b/t/02_wal_files.t index f1d14c58b..7241825e0 100644 --- a/t/02_wal_files.t +++ b/t/02_wal_files.t @@ -20,7 +20,7 @@ my $S = q{Action 'wal_files'}; my $label = 'POSTGRES_WAL_FILES'; $t=qq{$S fails when called with an invalid option}; -like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); +like ($cp->run('foobar=12'), qr{Usage:}, $t); $t=qq{$S fails when called with an invalid option}; like ($cp->run('--warning=30%'), qr{ERROR:.+must be a positive integer}, $t); -- 2.30.2