Adjust tests for new slony_status output.
authorGreg Sabino Mullane <[email protected]>
Mon, 1 Mar 2010 20:57:27 +0000 (15:57 -0500)
committerGreg Sabino Mullane <[email protected]>
Mon, 1 Mar 2010 20:57:27 +0000 (15:57 -0500)
t/02_slony_status.t

index cd12ee4cecc3ea2f09b4e6ac182a732de27203ab..592d459f506646c40ea34fcb06f750c4e0e1fa01 100644 (file)
@@ -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();