Add TAP tests for pg_dump
This TAP test suite will create a new cluster, populate it based on
the 'create_sql' values in the '%tests' hash, run all of the runs
defined in the '%pgdump_runs' hash, and then for each test in the
'%tests' hash, compare each run's output the the regular expression
defined for the test under the 'like' and 'unlike' functions, as
appropriate.
While this test suite covers a fair bit of ground (67% of pg_dump.c
and quite a bit of the other files in src/bin/pg_dump), there is
still quite a bit which remains to be added to provide better code
coverage. Still, this is quite a bit better than we had, and has
found a few bugs already (note that the CREATE TRANSFORM test is
commented out, as it is currently failing).
Idea for using the TAP system from Tom, though all of the code is mine.
2016-05-06 20:06:50 +02:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Config;
|
|
|
|
use PostgresNode;
|
|
|
|
use TestLib;
|
2017-01-06 22:29:31 +01:00
|
|
|
use Test::More tests => 42;
|
Add TAP tests for pg_dump
This TAP test suite will create a new cluster, populate it based on
the 'create_sql' values in the '%tests' hash, run all of the runs
defined in the '%pgdump_runs' hash, and then for each test in the
'%tests' hash, compare each run's output the the regular expression
defined for the test under the 'like' and 'unlike' functions, as
appropriate.
While this test suite covers a fair bit of ground (67% of pg_dump.c
and quite a bit of the other files in src/bin/pg_dump), there is
still quite a bit which remains to be added to provide better code
coverage. Still, this is quite a bit better than we had, and has
found a few bugs already (note that the CREATE TRANSFORM test is
commented out, as it is currently failing).
Idea for using the TAP system from Tom, though all of the code is mine.
2016-05-06 20:06:50 +02:00
|
|
|
|
|
|
|
my $tempdir = TestLib::tempdir;
|
|
|
|
my $tempdir_short = TestLib::tempdir_short;
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Basic checks
|
|
|
|
|
|
|
|
program_help_ok('pg_dump');
|
|
|
|
program_version_ok('pg_dump');
|
|
|
|
program_options_handling_ok('pg_dump');
|
|
|
|
|
2017-01-06 22:29:31 +01:00
|
|
|
program_help_ok('pg_restore');
|
|
|
|
program_version_ok('pg_restore');
|
|
|
|
program_options_handling_ok('pg_restore');
|
|
|
|
|
|
|
|
program_help_ok('pg_dumpall');
|
|
|
|
program_version_ok('pg_dumpall');
|
|
|
|
program_options_handling_ok('pg_dumpall');
|
|
|
|
|
Add TAP tests for pg_dump
This TAP test suite will create a new cluster, populate it based on
the 'create_sql' values in the '%tests' hash, run all of the runs
defined in the '%pgdump_runs' hash, and then for each test in the
'%tests' hash, compare each run's output the the regular expression
defined for the test under the 'like' and 'unlike' functions, as
appropriate.
While this test suite covers a fair bit of ground (67% of pg_dump.c
and quite a bit of the other files in src/bin/pg_dump), there is
still quite a bit which remains to be added to provide better code
coverage. Still, this is quite a bit better than we had, and has
found a few bugs already (note that the CREATE TRANSFORM test is
commented out, as it is currently failing).
Idea for using the TAP system from Tom, though all of the code is mine.
2016-05-06 20:06:50 +02:00
|
|
|
#########################################
|
|
|
|
# Test various invalid options and disallowed combinations
|
|
|
|
# Doesn't require a PG instance to be set up, so do this first.
|
|
|
|
|
|
|
|
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
|
|
|
|
1, 'pg_dump: too many command-line arguments (first is "asd")');
|
|
|
|
|
2017-01-06 22:29:31 +01:00
|
|
|
command_exit_is([ 'pg_restore', 'qqq', 'abc' ],
|
|
|
|
1, 'pg_restore too many command-line arguments (first is "asd")');
|
|
|
|
|
|
|
|
command_exit_is([ 'pg_dumpall', 'qqq', 'abc' ],
|
|
|
|
1, 'pg_dumpall: too many command-line arguments (first is "qqq")');
|
|
|
|
|
2016-06-12 10:19:56 +02:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dump', '-s', '-a' ],
|
|
|
|
1,
|
|
|
|
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
|
|
|
|
);
|
|
|
|
|
2017-01-06 22:29:31 +01:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_restore', '-s', '-a' ],
|
|
|
|
1,
|
|
|
|
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
|
|
|
|
);
|
|
|
|
|
2017-01-31 18:42:16 +01:00
|
|
|
command_exit_is([ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
|
2017-01-06 22:29:31 +01:00
|
|
|
1,
|
2017-01-31 18:42:16 +01:00
|
|
|
'pg_restore: options -d/--dbname and -f/--file cannot be used together');
|
2017-01-06 22:29:31 +01:00
|
|
|
|
2016-06-12 10:19:56 +02:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dump', '-c', '-a' ],
|
|
|
|
1,
|
|
|
|
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
|
|
|
|
|
2017-01-06 22:29:31 +01:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_restore', '-c', '-a' ],
|
|
|
|
1,
|
2017-01-31 18:42:16 +01:00
|
|
|
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
|
2017-01-06 22:29:31 +01:00
|
|
|
|
2016-06-12 10:19:56 +02:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dump', '--inserts', '-o' ],
|
|
|
|
1,
|
|
|
|
'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
|
|
|
|
);
|
Add TAP tests for pg_dump
This TAP test suite will create a new cluster, populate it based on
the 'create_sql' values in the '%tests' hash, run all of the runs
defined in the '%pgdump_runs' hash, and then for each test in the
'%tests' hash, compare each run's output the the regular expression
defined for the test under the 'like' and 'unlike' functions, as
appropriate.
While this test suite covers a fair bit of ground (67% of pg_dump.c
and quite a bit of the other files in src/bin/pg_dump), there is
still quite a bit which remains to be added to provide better code
coverage. Still, this is quite a bit better than we had, and has
found a few bugs already (note that the CREATE TRANSFORM test is
commented out, as it is currently failing).
Idea for using the TAP system from Tom, though all of the code is mine.
2016-05-06 20:06:50 +02:00
|
|
|
|
|
|
|
command_exit_is([ 'pg_dump', '--if-exists' ],
|
|
|
|
1, 'pg_dump: option --if-exists requires option -c/--clean');
|
|
|
|
|
|
|
|
command_exit_is([ 'pg_dump', '-j' ],
|
|
|
|
1, 'pg_dump: option requires an argument -- \'j\'');
|
|
|
|
|
|
|
|
command_exit_is([ 'pg_dump', '-j3' ],
|
|
|
|
1, 'pg_dump: parallel backup only supported by the directory format');
|
2017-01-06 22:29:31 +01:00
|
|
|
|
2017-01-31 18:42:16 +01:00
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_restore', '--single-transaction', '-j3' ],
|
|
|
|
1,
|
|
|
|
'pg_restore: cannot specify both --single-transaction and multiple jobs');
|
2017-01-06 22:29:31 +01:00
|
|
|
|
|
|
|
command_exit_is([ 'pg_restore', '--if-exists' ],
|
|
|
|
1, 'pg_restore: option --if-exists requires option -c/--clean');
|
|
|
|
|
|
|
|
# pg_dumpall command-line argument checks
|
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dumpall', '-g', '-r' ],
|
|
|
|
1,
|
|
|
|
'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together'
|
|
|
|
);
|
|
|
|
|
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dumpall', '-g', '-t' ],
|
|
|
|
1,
|
|
|
|
'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
|
|
|
|
);
|
|
|
|
|
|
|
|
command_exit_is(
|
|
|
|
[ 'pg_dumpall', '-r', '-t' ],
|
|
|
|
1,
|
|
|
|
'pg_restore: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
|
|
|
|
);
|
|
|
|
|
|
|
|
command_exit_is([ 'pg_dumpall', '--if-exists' ],
|
|
|
|
1, 'pg_dumpall: option --if-exists requires option -c/--clean');
|