mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Now connecting to db.
This commit is contained in:
parent
8db52c115a
commit
8b37786e5b
48
test/test.pl
48
test/test.pl
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
#use strict;
|
#use strict;
|
||||||
|
use DBI;
|
||||||
|
|
||||||
my $strPgBinPath = '/Library/PostgreSQL/9.3/bin/';
|
my $strPgBinPath = '/Library/PostgreSQL/9.3/bin/';
|
||||||
|
|
||||||
@ -11,9 +12,10 @@ sub execute
|
|||||||
|
|
||||||
print("$strCommand\n");
|
print("$strCommand\n");
|
||||||
$strOutput = qx($strCommand) or return 0;
|
$strOutput = qx($strCommand) or return 0;
|
||||||
|
$strOutput =~ s/^\s+|\s+$//g;
|
||||||
print("$strOutput\n");
|
print("$strOutput\n");
|
||||||
|
|
||||||
return 1;
|
return $strOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub pg_create
|
sub pg_create
|
||||||
@ -32,6 +34,14 @@ sub pg_start
|
|||||||
execute($strCommand);
|
execute($strCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub pg_password_set
|
||||||
|
{
|
||||||
|
local($strPath, $strUser) = @_;
|
||||||
|
my $strCommand = $strPgBinPath . "psql --port=6000 -c \"alter user $strUser with password 'password'\" postgres";
|
||||||
|
|
||||||
|
execute($strCommand);
|
||||||
|
}
|
||||||
|
|
||||||
sub pg_stop
|
sub pg_stop
|
||||||
{
|
{
|
||||||
local($strPath) = @_;
|
local($strPath) = @_;
|
||||||
@ -48,9 +58,35 @@ sub pg_drop
|
|||||||
execute($strCommand);
|
execute($strCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_stop("/Users/dsteele/test/test2");
|
sub pg_execute
|
||||||
pg_drop("/Users/dsteele/test/test2");
|
{
|
||||||
pg_create("/Users/dsteele/test/test2");
|
local($dbh, $strSql) = @_;
|
||||||
pg_start("/Users/dsteele/test/test2");
|
|
||||||
pg_stop("/Users/dsteele/test/test2");
|
|
||||||
|
|
||||||
|
$sth = $dbh->prepare($strSql);
|
||||||
|
$sth->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $strUser = execute('whoami');
|
||||||
|
my $strTestPath = "/Users/dsteele/test/";
|
||||||
|
my $strTestDir = "test2";
|
||||||
|
my $strArchiveDir = "archive";
|
||||||
|
|
||||||
|
pg_stop("$strTestPath$strTestDir");
|
||||||
|
pg_drop("$strTestPath$strTestDir");
|
||||||
|
pg_create("$strTestPath$strTestDir");
|
||||||
|
pg_start("$strTestPath$strTestDir");
|
||||||
|
pg_password_set("$strTestPath$strTestDir", $strUser);
|
||||||
|
|
||||||
|
$dbh = DBI->connect("dbi:Pg:dbname=postgres;port=6000;host=127.0.0.1", 'dsteele', 'password', {AutoCommit => 1});
|
||||||
|
pg_execute($dbh, "create table test (id int)");
|
||||||
|
|
||||||
|
pg_execute($dbh, "insert into test values (1)");
|
||||||
|
pg_execute($dbh, "select pg_switch_xlog()");
|
||||||
|
|
||||||
|
pg_execute($dbh, "insert into test values (2)");
|
||||||
|
pg_execute($dbh, "select pg_switch_xlog()");
|
||||||
|
|
||||||
|
pg_execute($dbh, "insert into test values (3)");
|
||||||
|
pg_execute($dbh, "select pg_switch_xlog()");
|
||||||
|
|
||||||
|
#pg_stop($strTestPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user