Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
eb5089a0
Commit
eb5089a0
authored
Jul 26, 2016
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pg_ctl: Add tests for promote action
Reviewed-by:
Michael Paquier
<
michael.paquier@gmail.com
>
parent
e767db22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
src/bin/pg_ctl/t/003_promote.pl
src/bin/pg_ctl/t/003_promote.pl
+39
-0
src/test/perl/TestLib.pm
src/test/perl/TestLib.pm
+11
-0
No files found.
src/bin/pg_ctl/t/003_promote.pl
0 → 100644
View file @
eb5089a0
use
strict
;
use
warnings
;
use
PostgresNode
;
use
TestLib
;
use
Test::
More
tests
=>
9
;
my
$tempdir
=
TestLib::
tempdir
;
command_fails_like
([
'
pg_ctl
',
'
-D
',
"
$tempdir
/nonexistent
",
'
promote
'
],
qr/directory .* does not exist/
,
'
pg_ctl promote with nonexistent directory
');
my
$node_primary
=
get_new_node
('
primary
');
$node_primary
->
init
(
allows_streaming
=>
1
);
command_fails_like
([
'
pg_ctl
',
'
-D
',
$node_primary
->
data_dir
,
'
promote
'
],
qr/PID file .* does not exist/
,
'
pg_ctl promote of not running instance fails
');
$node_primary
->
start
;
command_fails_like
([
'
pg_ctl
',
'
-D
',
$node_primary
->
data_dir
,
'
promote
'
],
qr/not in standby mode/
,
'
pg_ctl promote of primary instance fails
');
my
$node_standby
=
get_new_node
('
standby
');
$node_primary
->
backup
('
my_backup
');
$node_standby
->
init_from_backup
(
$node_primary
,
'
my_backup
',
has_streaming
=>
1
);
$node_standby
->
start
;
is
(
$node_standby
->
safe_psql
('
postgres
',
'
SELECT pg_is_in_recovery()
'),
'
t
',
'
standby is in recovery
');
command_ok
([
'
pg_ctl
',
'
-D
',
$node_standby
->
data_dir
,
'
promote
'
],
'
pg_ctl promote of standby runs
');
ok
(
$node_standby
->
poll_query_until
('
postgres
',
'
SELECT NOT pg_is_in_recovery()
'),
'
promoted standby is not in recovery
');
src/test/perl/TestLib.pm
View file @
eb5089a0
...
...
@@ -34,6 +34,7 @@ our @EXPORT = qw(
program_version_ok
program_options_handling_ok
command_like
command_fails_like
$windows_os
)
;
...
...
@@ -281,4 +282,14 @@ sub command_like
like
(
$stdout
,
$expected_stdout
,
"
$test_name
: matches
");
}
sub
command_fails_like
{
my
(
$cmd
,
$expected_stderr
,
$test_name
)
=
@_
;
my
(
$stdout
,
$stderr
);
print
("
# Running:
"
.
join
("
",
@
{
$cmd
})
.
"
\n
");
my
$result
=
IPC::Run::
run
$cmd
,
'
>
',
\
$stdout
,
'
2>
',
\
$stderr
;
ok
(
!
$result
,
"
$test_name
: exit code not 0
");
like
(
$stderr
,
$expected_stderr
,
"
$test_name
: matches
");
}
1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment