summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2010-03-01 20:57:27 +0000
committerGreg Sabino Mullane2010-03-01 20:57:27 +0000
commit6b5a2e7ca74f920d8cb459d660b293129b23daa4 (patch)
treed31dab287e82c45dee07db17befab1ef3b90a511
parent292851f3d48604e660393084202bdcec08096e98 (diff)
Adjust tests for new slony_status output.
-rw-r--r--t/02_slony_status.t32
1 files changed, 21 insertions, 11 deletions
diff --git a/t/02_slony_status.t b/t/02_slony_status.t
index cd12ee4ce..592d459f5 100644
--- a/t/02_slony_status.t
+++ b/t/02_slony_status.t
@@ -34,17 +34,23 @@ like ($cp->run('-w 55 -c 33'), qr{ERROR:.+'warning' option .+ cannot be larger},
$t=qq{$S fails when called with an invalid schema argument};
like ($cp->run('-w 60 --schema foobar'), qr{ERROR: .*schema}, $t);
-$t=qq{$S fails when cannot find schema of sl_status automatically};
-like ($cp->run('-w 60'), qr{$label UNKNOWN: .*schema}, $t);
-
cleanup_schema();
+$t=qq{$S fails when cannot find schema of sl_status automatically};
+like ($cp->run('-w 60'), qr{$label UNKNOWN: .*schema}, $t);
## Create a fake view to emulate a real Slony one
## Does not have to be complete: only needs one column
$SQL = q{CREATE SCHEMA slony_testing};
$dbh->do($SQL);
-$SQL = q{CREATE VIEW slony_testing.sl_status AS SELECT '123 seconds'::interval AS st_lag_time};
+$SQL = q{CREATE VIEW slony_testing.sl_status AS
+SELECT '123 seconds'::interval AS st_lag_time, 1 AS st_origin, 2 AS st_received};
+$dbh->do($SQL);
+$SQL = q{CREATE TABLE slony_testing.sl_node AS
+SELECT 1 AS no_id, 'First node' AS no_comment
+UNION ALL
+SELECT 2 AS no_id, 'Second node' AS no_comment
+};
$dbh->do($SQL);
$dbh->commit();
@@ -56,46 +62,46 @@ my $res = $cp->run('-w 230 --schema slony_testing');
like ($res, qr{$label OK:.*\b123\b}, $t);
$t=qq{$S reports correct stats for raw seconds warning input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;230;\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;230;\s*$}, $t);
$t=qq{$S reports warning correctly for raw seconds};
$res = $cp->run('-w 30');
like ($res, qr{$label WARNING:.*\b123\b}, $t);
$t=qq{$S reports correct stats for raw seconds warning input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;30;\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;30;\s*$}, $t);
$t=qq{$S reports warning correctly for minutes input};
$res = $cp->run('-w "1 minute"');
like ($res, qr{$label WARNING:.*\b123\b}, $t);
$t=qq{$S reports correct stats for minutes warning input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;60;\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;60;\s*$}, $t);
$t=qq{$S reports okay when lag threshhold not reached, with critical};
$res = $cp->run('-c 235');
like ($res, qr{$label OK:.*\b123\b}, $t);
$t=qq{$S reports correct stats for raw seconds critical input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;;235\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;;235\s*$}, $t);
$t=qq{$S reports critical correctly for raw seconds};
$res = $cp->run('-c 35');
like ($res, qr{$label CRITICAL:.*\b123\b}, $t);
$t=qq{$S reports correct stats for raw seconds critical input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;;35\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;;35\s*$}, $t);
$t=qq{$S reports critical correctly for minutes input};
$res = $cp->run('-c "1 minute"');
like ($res, qr{$label CRITICAL:.*\b123\b}, $t);
$t=qq{$S reports correct stats for minutes critical input};
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;;60\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;;60\s*$}, $t);
$t=qq{$S reports correct stats for both warning and critical};
$res = $cp->run('-c "3 days" -w "23 hours"');
-like ($res, qr{\| time=\d+\.\d+ 'postgres'=123;82800;259200\s*$}, $t);
+like ($res, qr{\| time=\d+\.\d+ 'postgres Node 1\(First node\) -> Node 2\(Second node\)'=123;82800;259200\s*$}, $t);
cleanup_schema();
@@ -107,6 +113,10 @@ sub cleanup_schema {
eval { $dbh->do($SQL); };
$dbh->commit();
+ $SQL = q{DROP TABLE slony_testing.sl_node};
+ eval { $dbh->do($SQL); };
+ $dbh->commit();
+
$SQL = q{DROP SCHEMA slony_testing};
eval { $dbh->do($SQL); };
$dbh->commit();