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
98470fdf
Commit
98470fdf
authored
Aug 11, 2017
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pg_archivecleanup: Add test suite
Reviewed-by:
David Steele
<
david@pgmasters.net
>
parent
af7211e9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
0 deletions
+90
-0
src/bin/pg_archivecleanup/.gitignore
src/bin/pg_archivecleanup/.gitignore
+2
-0
src/bin/pg_archivecleanup/Makefile
src/bin/pg_archivecleanup/Makefile
+7
-0
src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
+81
-0
No files found.
src/bin/pg_archivecleanup/.gitignore
View file @
98470fdf
/pg_archivecleanup
/tmp_check/
src/bin/pg_archivecleanup/Makefile
View file @
98470fdf
...
...
@@ -25,3 +25,10 @@ uninstall:
clean distclean maintainer-clean
:
rm
-f
pg_archivecleanup
$(X)
$(OBJS)
rm
-rf
tmp_check
check
:
$(prove_check)
installcheck
:
$(prove_installcheck)
src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
0 → 100644
View file @
98470fdf
use
strict
;
use
warnings
;
use
TestLib
;
use
Test::
More
tests
=>
42
;
program_help_ok
('
pg_archivecleanup
');
program_version_ok
('
pg_archivecleanup
');
program_options_handling_ok
('
pg_archivecleanup
');
my
$tempdir
=
TestLib::
tempdir
;
my
@walfiles
=
(
'
00000001000000370000000C.gz
',
'
00000001000000370000000D
',
'
00000001000000370000000E
',
'
00000001000000370000000F.partial
',
);
sub
create_files
{
foreach
my
$fn
(
@walfiles
,
'
unrelated_file
')
{
open
my
$file
,
'
>
',
"
$tempdir
/
$fn
";
print
$file
'
CONTENT
';
close
$file
;
}
}
create_files
();
command_fails_like
(['
pg_archivecleanup
'],
qr/must specify archive location/
,
'
fails if archive location is not specified
');
command_fails_like
(['
pg_archivecleanup
',
$tempdir
],
qr/must specify oldest kept WAL file/
,
'
fails if oldest kept WAL file name is not specified
');
command_fails_like
(['
pg_archivecleanup
',
'
notexist
',
'
foo
'],
qr/archive location .* does not exist/
,
'
fails if archive location does not exist
');
command_fails_like
(['
pg_archivecleanup
',
$tempdir
,
'
foo
',
'
bar
'],
qr/too many command-line arguments/
,
'
fails with too many command-line arguments
');
command_fails_like
(['
pg_archivecleanup
',
$tempdir
,
'
foo
'],
qr/invalid file name argument/
,
'
fails with invalid restart file name
');
{
# like command_like but checking stderr
my
$stderr
;
my
$result
=
IPC::Run::
run
['
pg_archivecleanup
',
'
-d
',
'
-n
',
$tempdir
,
$walfiles
[
2
]],
'
2>
',
\
$stderr
;
ok
(
$result
,
"
pg_archivecleanup dry run: exit code 0
");
like
(
$stderr
,
qr/$walfiles[1].*would be removed/
,
"
pg_archivecleanup dry run: matches
");
foreach
my
$fn
(
@walfiles
)
{
ok
(
-
f
"
$tempdir
/
$fn
",
"
$fn
not removed
");
}
}
sub
run_check
{
my
(
$suffix
,
$test_name
)
=
@_
;
create_files
();
command_ok
(['
pg_archivecleanup
',
'
-x
',
'
.gz
',
$tempdir
,
$walfiles
[
2
]
.
$suffix
],
"
$test_name
: runs
");
ok
(
!
-
f
"
$tempdir
/
$walfiles
[0]
",
"
$test_name
: first older WAL file was cleaned up
");
ok
(
!
-
f
"
$tempdir
/
$walfiles
[1]
",
"
$test_name
: second older WAL file was cleaned up
");
ok
(
-
f
"
$tempdir
/
$walfiles
[2]
",
"
$test_name
: restartfile was not cleaned up
");
ok
(
-
f
"
$tempdir
/
$walfiles
[3]
",
"
$test_name
: newer WAL file was not cleaned up
");
ok
(
-
f
"
$tempdir
/unrelated_file
",
"
$test_name
: unrelated file was not cleaned up
");
}
run_check
('',
'
pg_archivecleanup
');
run_check
('
.partial
',
'
pg_archivecleanup with .partial file
');
run_check
('
.00000020.backup
',
'
pg_archivecleanup with .backup file
');
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