Make spaces in dirs by default.
authorGreg Sabino Mullane <greg@endpoint.com>
Tue, 28 Apr 2009 15:30:51 +0000 (11:30 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Tue, 28 Apr 2009 15:30:51 +0000 (11:30 -0400)
check_postgres.pl
t/02_checkpoint.t
t/CP_Testing.pm

index abb4d4692548ab0588592cbc3b2579d32155c80d..8581d35d96c5e1c1427308e426ac54b15ea20499 100755 (executable)
@@ -4334,7 +4334,7 @@ sub check_checkpoint {
        ## Checks how long in seconds since the last checkpoint on a WAL slave
        ## Supports: Nagios, MRTG
        ## Warning and critical are seconds
-       ## Requires $ENV{PGATA} or --datadir
+       ## Requires $ENV{PGDATA} or --datadir
 
        my ($warning, $critical) = validate_range
                ({
@@ -4361,7 +4361,7 @@ sub check_checkpoint {
                = $ENV{PGCONTROLDATA} ? $ENV{PGCONTROLDATA}
                : $ENV{PGBINDIR}      ? "$ENV{PGBINDIR}/pg_controldata"
                :                       'pg_controldata';
-       $COM = "$pgc $dir";
+       $COM = qq{$pgc "$dir"};
        eval {
                $res = qx{$COM 2>&1};
        };
index b345178fa0daff3de2086e9803124c6e05274230..bff1210856ed720a2fd90cacf5da15c9e4cfbe84 100644 (file)
@@ -39,29 +39,29 @@ like ($cp->run('-c 10 --datadir=foobar'), qr{ERROR: Invalid data_directory}, $t)
 
 my $host = $cp->get_host();
 $t=qq{$S fails when called against a non datadir datadir};
-like ($cp->run("-c 10 --datadir=$host"), qr{ERROR:.+could not read the given data directory}, $t);
+like ($cp->run(qq{-c 10 --datadir="$host"}), qr{ERROR:.+could not read the given data directory}, $t);
 
 $t=qq{$S works when called for a recent checkpoint};
 my $dbh = $cp->get_dbh();
 $dbh->do('CHECKPOINT');
 $dbh->commit();
 $host =~ s/socket$//;
-like ($cp->run("-w 20 --datadir=$host"), qr{POSTGRES_CHECKPOINT OK}, $t);
+like ($cp->run(qq{-w 20 --datadir="$host"}), qr{POSTGRES_CHECKPOINT OK}, $t);
 
 $t=qq{$S returns a warning when checkpoint older than warning option};
 sleep 2;
-like ($cp->run("-w 1 --datadir=$host"), qr{WARNING:}, $t);
+like ($cp->run(qq{-w 1 --datadir="$host"}), qr{WARNING:}, $t);
 
 $t=qq{$S returns a critical when checkpoint older than critical option};
-like ($cp->run("-c 1 --datadir=$host"), qr{CRITICAL:}, $t);
+like ($cp->run(qq{-c 1 --datadir="$host"}), qr{CRITICAL:}, $t);
 
 $t=qq{$S returns the correct number of seconds};
-like ($cp->run("-c 1 --datadir=$host"), qr{was \d seconds ago}, $t);
+like ($cp->run(qq{-c 1 --datadir="$host"}), qr{was \d seconds ago}, $t);
 
 $t=qq{$S returns the expected output for MRTG};
-like ($cp->run("-c 1 --output=MRTG --datadir=$host"), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
+like ($cp->run(qq{-c 1 --output=MRTG --datadir="$host"}), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
 
 $t=qq{$S returns the expected output for MRTG};
-like ($cp->run("-c 199 --output=MRTG --datadir=$host"), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
+like ($cp->run(qq{-c 199 --output=MRTG --datadir="$host"}), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
 
 exit;
index f0280871ea7278ae9e9b451e2b4be5826b0b803c..e7d4f7be89ec2581418189fbd37bb4e7814a9f86 100644 (file)
@@ -33,7 +33,7 @@ sub cleanup {
 
        my $self = shift;
        my $dbdir = $self->{dbdir} or die;
-       my $pidfile = "$dbdir/data/postmaster.pid";
+       my $pidfile = "$dbdir/data space/postmaster.pid";
        return if ! -e $pidfile;
        open my $fh, '<', $pidfile or die qq{Could not open "$pidfile": $!\n};
        <$fh> =~ /^(\d+)/ or die qq{File "$pidfile" did not start with a number!\n};
@@ -72,7 +72,7 @@ sub test_database_handle {
                        : $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/initdb"
                        :                  'initdb';
 
-               $com = qq{LC_ALL=en LANG=C $initdb --locale=C -E UTF8 -D $dbdir/data 2>&1};
+               $com = qq{LC_ALL=en LANG=C $initdb --locale=C -E UTF8 -D "$dbdir/data space" 2>&1};
                eval {
                        $info = qx{$com};
                };
@@ -81,7 +81,7 @@ sub test_database_handle {
                }
 
                ## Modify the postgresql.conf
-               my $cfile = "$dbdir/data/postgresql.conf";
+               my $cfile = "$dbdir/data space/postgresql.conf";
                open my $cfh, '>>', $cfile or die qq{Could not open "$cfile": $!\n};
                print $cfh qq{\n\n## check_postgres.pl testing parameters\n};
                print $cfh qq{listen_addresses = ''\n};
@@ -91,14 +91,14 @@ sub test_database_handle {
                print $cfh "\n";
                close $cfh or die qq{Could not close "$cfile": $!\n};
 
-               mkdir "$dbdir/data/socket";
+               mkdir "$dbdir/data space/socket";
 
        }
 
        ## See if the database is already running.
        my $needs_startup = 0;
 
-       my $pidfile = "$dbdir/data/postmaster.pid";
+       my $pidfile = "$dbdir/data space/postmaster.pid";
        if (! -e $pidfile) {
                $needs_startup = 1;
        }
@@ -127,7 +127,7 @@ sub test_database_handle {
                        : $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/pg_ctl"
                        :                  'pg_ctl';
 
-               $com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data" start};
+               $com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data space" start};
                eval {
                        $info = qx{$com};
                };
@@ -156,7 +156,7 @@ sub test_database_handle {
        } ## end of needs startup
 
        my $here = cwd();
-       my $dbhost = $self->{dbhost} = "$here/$dbdir/data/socket";
+       my $dbhost = $self->{dbhost} = "$here/$dbdir/data space/socket";
        $dbhost =~ s/^ /\\ /;
        $dbhost =~ s/([^\\]) /$1\\ /g;
        $self->{dbname} ||= 'postgres';