Run most pg_dump and pg_dumpall tests with --no-sync

Commit 96a7128b made pg_dump and pg_dumpall sync their output by
default. However, there's no great need for that in testing, and it
could impose a performance penalty, so we add the --no-sync flag to most
of the test cases.

Michael Paquier
This commit is contained in:
Andrew Dunstan 2017-04-10 19:53:47 -04:00
parent 521fd4795e
commit 3820c63da8
4 changed files with 136 additions and 57 deletions

View File

@ -39,6 +39,7 @@ my %pgdump_runs = (
binary_upgrade => { binary_upgrade => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
'--format=custom', '--format=custom',
"--file=$tempdir/binary_upgrade.dump", "--file=$tempdir/binary_upgrade.dump",
'-w', '-w',
@ -55,6 +56,7 @@ my %pgdump_runs = (
clean => { clean => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/clean.sql", "--file=$tempdir/clean.sql",
'--include-subscriptions', '--include-subscriptions',
'-c', '-c',
@ -63,6 +65,7 @@ my %pgdump_runs = (
clean_if_exists => { clean_if_exists => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/clean_if_exists.sql", "--file=$tempdir/clean_if_exists.sql",
'--include-subscriptions', '--include-subscriptions',
'-c', '-c',
@ -71,12 +74,16 @@ my %pgdump_runs = (
'postgres', ], }, 'postgres', ], },
column_inserts => { column_inserts => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/column_inserts.sql", 'pg_dump',
'-a', '--column-inserts', '--no-sync',
"--file=$tempdir/column_inserts.sql",
'-a',
'--column-inserts',
'postgres', ], }, 'postgres', ], },
createdb => { createdb => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/createdb.sql", "--file=$tempdir/createdb.sql",
'--include-subscriptions', '--include-subscriptions',
'-C', '-C',
@ -86,6 +93,7 @@ my %pgdump_runs = (
data_only => { data_only => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/data_only.sql", "--file=$tempdir/data_only.sql",
'--include-subscriptions', '--include-subscriptions',
'-a', '-a',
@ -94,8 +102,13 @@ my %pgdump_runs = (
'-v', # no-op, just make sure it works '-v', # no-op, just make sure it works
'postgres', ], }, 'postgres', ], },
defaults => { defaults => {
dump_cmd => [ 'pg_dump', '-f', "$tempdir/defaults.sql", 'postgres', ], dump_cmd => [
}, 'pg_dump',
'--no-sync',
'-f',
"$tempdir/defaults.sql",
'postgres', ], },
# Do not use --no-sync to give test coverage for data sync.
defaults_custom_format => { defaults_custom_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
@ -105,6 +118,7 @@ my %pgdump_runs = (
'pg_restore', '-Fc', 'pg_restore', '-Fc',
"--file=$tempdir/defaults_custom_format.sql", "--file=$tempdir/defaults_custom_format.sql",
"$tempdir/defaults_custom_format.dump", ], }, "$tempdir/defaults_custom_format.dump", ], },
# Do not use --no-sync to give test coverage for data sync.
defaults_dir_format => { defaults_dir_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
@ -114,6 +128,7 @@ my %pgdump_runs = (
'pg_restore', '-Fd', 'pg_restore', '-Fd',
"--file=$tempdir/defaults_dir_format.sql", "--file=$tempdir/defaults_dir_format.sql",
"$tempdir/defaults_dir_format", ], }, "$tempdir/defaults_dir_format", ], },
# Do not use --no-sync to give test coverage for data sync.
defaults_parallel => { defaults_parallel => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
@ -123,6 +138,7 @@ my %pgdump_runs = (
'pg_restore', 'pg_restore',
"--file=$tempdir/defaults_parallel.sql", "--file=$tempdir/defaults_parallel.sql",
"$tempdir/defaults_parallel", ], }, "$tempdir/defaults_parallel", ], },
# Do not use --no-sync to give test coverage for data sync.
defaults_tar_format => { defaults_tar_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
@ -135,17 +151,22 @@ my %pgdump_runs = (
"$tempdir/defaults_tar_format.tar", ], }, "$tempdir/defaults_tar_format.tar", ], },
exclude_dump_test_schema => { exclude_dump_test_schema => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/exclude_dump_test_schema.sql", 'pg_dump',
'--exclude-schema=dump_test', 'postgres', ], }, '--no-sync',
"--file=$tempdir/exclude_dump_test_schema.sql",
'--exclude-schema=dump_test',
'postgres', ], },
exclude_test_table => { exclude_test_table => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/exclude_test_table.sql", "--file=$tempdir/exclude_test_table.sql",
'--exclude-table=dump_test.test_table', '--exclude-table=dump_test.test_table',
'postgres', ], }, 'postgres', ], },
exclude_test_table_data => { exclude_test_table_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/exclude_test_table_data.sql", "--file=$tempdir/exclude_test_table_data.sql",
'--exclude-table-data=dump_test.test_table', '--exclude-table-data=dump_test.test_table',
'--no-unlogged-table-data', '--no-unlogged-table-data',
@ -153,30 +174,52 @@ my %pgdump_runs = (
pg_dumpall_globals => { pg_dumpall_globals => {
dump_cmd => [ dump_cmd => [
'pg_dumpall', '-v', 'pg_dumpall', '-v',
"--file=$tempdir/pg_dumpall_globals.sql", '-g', ], }, "--file=$tempdir/pg_dumpall_globals.sql", '-g',
'--no-sync', ], },
pg_dumpall_globals_clean => { pg_dumpall_globals_clean => {
dump_cmd => [ dump_cmd => [
'pg_dumpall', "--file=$tempdir/pg_dumpall_globals_clean.sql", 'pg_dumpall',
'-g', '-c', ], }, "--file=$tempdir/pg_dumpall_globals_clean.sql",
'-g',
'-c',
'--no-sync', ], },
pg_dumpall_dbprivs => { pg_dumpall_dbprivs => {
dump_cmd => dump_cmd => [
[ 'pg_dumpall', "--file=$tempdir/pg_dumpall_dbprivs.sql", ], }, 'pg_dumpall',
'--no-sync',
"--file=$tempdir/pg_dumpall_dbprivs.sql", ], },
no_blobs => { no_blobs => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/no_blobs.sql", '-B', 'postgres', ], }, 'pg_dump',
'--no-sync',
"--file=$tempdir/no_blobs.sql",
'-B',
'postgres', ], },
no_privs => { no_privs => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/no_privs.sql", '-x', 'postgres', ], }, 'pg_dump',
'--no-sync',
"--file=$tempdir/no_privs.sql",
'-x',
'postgres', ], },
no_owner => { no_owner => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/no_owner.sql", '-O', 'postgres', ], }, 'pg_dump',
'--no-sync',
"--file=$tempdir/no_owner.sql",
'-O',
'postgres', ], },
only_dump_test_schema => { only_dump_test_schema => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/only_dump_test_schema.sql", 'pg_dump',
'--schema=dump_test', 'postgres', ], }, '--no-sync',
"--file=$tempdir/only_dump_test_schema.sql",
'--schema=dump_test',
'postgres', ], },
only_dump_test_table => { only_dump_test_table => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/only_dump_test_table.sql", "--file=$tempdir/only_dump_test_table.sql",
'--table=dump_test.test_table', '--table=dump_test.test_table',
'--lock-wait-timeout=1000000', '--lock-wait-timeout=1000000',
@ -184,6 +227,7 @@ my %pgdump_runs = (
role => { role => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/role.sql", "--file=$tempdir/role.sql",
'--role=regress_dump_test_role', '--role=regress_dump_test_role',
'--schema=dump_test_second_schema', '--schema=dump_test_second_schema',
@ -192,6 +236,7 @@ my %pgdump_runs = (
test_key => 'role', test_key => 'role',
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
'--format=directory', '--format=directory',
'--jobs=2', '--jobs=2',
"--file=$tempdir/role_parallel", "--file=$tempdir/role_parallel",
@ -204,28 +249,29 @@ my %pgdump_runs = (
schema_only => { schema_only => {
dump_cmd => [ dump_cmd => [
'pg_dump', '--format=plain', "--file=$tempdir/schema_only.sql", 'pg_dump', '--format=plain', "--file=$tempdir/schema_only.sql",
'-s', 'postgres', ], }, '--no-sync', '-s', 'postgres', ], },
section_pre_data => { section_pre_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_pre_data.sql", 'pg_dump', "--file=$tempdir/section_pre_data.sql",
'--include-subscriptions', '--include-subscriptions',
'--section=pre-data', 'postgres', ], }, '--section=pre-data', '--no-sync', 'postgres', ], },
section_data => { section_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_data.sql", 'pg_dump', "--file=$tempdir/section_data.sql",
'--section=data', 'postgres', ], }, '--section=data', '--no-sync', 'postgres', ], },
section_post_data => { section_post_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_post_data.sql", 'pg_dump', "--file=$tempdir/section_post_data.sql",
'--section=post-data', 'postgres', ], }, '--section=post-data', '--no-sync', 'postgres', ], },
test_schema_plus_blobs => { test_schema_plus_blobs => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/test_schema_plus_blobs.sql", 'pg_dump', "--file=$tempdir/test_schema_plus_blobs.sql",
'--schema=dump_test', '-b', '-B', 'postgres', ], },
'--schema=dump_test', '-b', '-B', '--no-sync', 'postgres', ], },
with_oids => { with_oids => {
dump_cmd => [ dump_cmd => [
'pg_dump', '--oids', 'pg_dump', '--oids',
'--include-subscriptions', '--include-subscriptions', '--no-sync',
"--file=$tempdir/with_oids.sql", 'postgres', ], },); "--file=$tempdir/with_oids.sql", 'postgres', ], },);
############################################################### ###############################################################

View File

@ -59,29 +59,29 @@ $node->command_ok(
'-U', $dbname4 ], '-U', $dbname4 ],
'pg_dumpall with long ASCII name 1'); 'pg_dumpall with long ASCII name 1');
$node->command_ok( $node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname', [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname2), $node->connstr($dbname2),
'-U', $dbname3 ], '-U', $dbname3 ],
'pg_dumpall with long ASCII name 2'); 'pg_dumpall with long ASCII name 2');
$node->command_ok( $node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname', [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname3), $node->connstr($dbname3),
'-U', $dbname2 ], '-U', $dbname2 ],
'pg_dumpall with long ASCII name 3'); 'pg_dumpall with long ASCII name 3');
$node->command_ok( $node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname', [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname4), $node->connstr($dbname4),
'-U', $dbname1 ], '-U', $dbname1 ],
'pg_dumpall with long ASCII name 4'); 'pg_dumpall with long ASCII name 4');
$node->command_ok( $node->command_ok(
[ 'pg_dumpall', '-r', '-l', 'dbname=template1' ], [ 'pg_dumpall', '--no-sync', '-r', '-l', 'dbname=template1' ],
'pg_dumpall -l accepts connection string'); 'pg_dumpall -l accepts connection string');
$node->run_log([ 'createdb', "foo\n\rbar" ]); $node->run_log([ 'createdb', "foo\n\rbar" ]);
# not sufficient to use -r here # not sufficient to use -r here
$node->command_fails( $node->command_fails(
[ 'pg_dumpall', '-f', $discard ], [ 'pg_dumpall', '--no-sync', '-f', $discard ],
'pg_dumpall with \n\r in database name'); 'pg_dumpall with \n\r in database name');
$node->run_log([ 'dropdb', "foo\n\rbar" ]); $node->run_log([ 'dropdb', "foo\n\rbar" ]);
@ -91,7 +91,7 @@ $node->safe_psql($dbname1, 'CREATE TABLE t0()');
# XXX no printed message when this fails, just SIGPIPE termination # XXX no printed message when this fails, just SIGPIPE termination
$node->command_ok( $node->command_ok(
[ 'pg_dump', '-Fd', '-j2', '-f', $dirfmt, [ 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt,
'-U', $dbname1, $node->connstr($dbname1) ], '-U', $dbname1, $node->connstr($dbname1) ],
'parallel dump'); 'parallel dump');
@ -112,7 +112,7 @@ $node->command_ok(
'parallel restore with create'); 'parallel restore with create');
$node->command_ok([ 'pg_dumpall', '-f', $plain, '-U', $dbname1 ], $node->command_ok([ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $dbname1 ],
'take full dump'); 'take full dump');
system_log('cat', $plain); system_log('cat', $plain);
my ($stderr, $result); my ($stderr, $result);

View File

@ -170,7 +170,7 @@ createdb "$dbname2" || createdb_status=$?
createdb "$dbname3" || createdb_status=$? createdb "$dbname3" || createdb_status=$?
if "$MAKE" -C "$oldsrc" installcheck; then if "$MAKE" -C "$oldsrc" installcheck; then
pg_dumpall -f "$temp_root"/dump1.sql || pg_dumpall1_status=$? pg_dumpall --no-sync -f "$temp_root"/dump1.sql || pg_dumpall1_status=$?
if [ "$newsrc" != "$oldsrc" ]; then if [ "$newsrc" != "$oldsrc" ]; then
oldpgversion=`psql -X -A -t -d regression -c "SHOW server_version_num"` oldpgversion=`psql -X -A -t -d regression -c "SHOW server_version_num"`
fix_sql="" fix_sql=""
@ -221,7 +221,7 @@ case $testhost in
*) sh ./analyze_new_cluster.sh ;; *) sh ./analyze_new_cluster.sh ;;
esac esac
pg_dumpall -f "$temp_root"/dump2.sql || pg_dumpall2_status=$? pg_dumpall --no-sync -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
pg_ctl -m fast stop pg_ctl -m fast stop
# no need to echo commands anymore # no need to echo commands anymore

View File

@ -41,16 +41,21 @@ my $tempdir_short = TestLib::tempdir_short;
my %pgdump_runs = ( my %pgdump_runs = (
binary_upgrade => { binary_upgrade => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/binary_upgrade.sql", 'pg_dump',
'--schema-only', '--binary-upgrade', '--no-sync',
"--file=$tempdir/binary_upgrade.sql",
'--schema-only',
'--binary-upgrade',
'--dbname=postgres', ], }, '--dbname=postgres', ], },
clean => { clean => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/clean.sql", 'pg_dump', "--file=$tempdir/clean.sql",
'-c', '--dbname=postgres', ], }, '-c', '--no-sync',
'--dbname=postgres', ], },
clean_if_exists => { clean_if_exists => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/clean_if_exists.sql", "--file=$tempdir/clean_if_exists.sql",
'-c', '-c',
'--if-exists', '--if-exists',
@ -58,12 +63,16 @@ my %pgdump_runs = (
'postgres', ], }, 'postgres', ], },
column_inserts => { column_inserts => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/column_inserts.sql", 'pg_dump',
'-a', '--column-inserts', '--no-sync',
"--file=$tempdir/column_inserts.sql",
'-a',
'--column-inserts',
'postgres', ], }, 'postgres', ], },
createdb => { createdb => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/createdb.sql", "--file=$tempdir/createdb.sql",
'-C', '-C',
'-R', # no-op, just for testing '-R', # no-op, just for testing
@ -71,6 +80,7 @@ my %pgdump_runs = (
data_only => { data_only => {
dump_cmd => [ dump_cmd => [
'pg_dump', 'pg_dump',
'--no-sync',
"--file=$tempdir/data_only.sql", "--file=$tempdir/data_only.sql",
'-a', '-a',
'-v', # no-op, just make sure it works '-v', # no-op, just make sure it works
@ -81,7 +91,7 @@ my %pgdump_runs = (
defaults_custom_format => { defaults_custom_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
'pg_dump', '-Fc', '-Z6', 'pg_dump', '--no-sync', '-Fc', '-Z6',
"--file=$tempdir/defaults_custom_format.dump", 'postgres', ], "--file=$tempdir/defaults_custom_format.dump", 'postgres', ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
@ -90,7 +100,7 @@ my %pgdump_runs = (
defaults_dir_format => { defaults_dir_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
'pg_dump', '-Fd', 'pg_dump', '--no-sync', '-Fd',
"--file=$tempdir/defaults_dir_format", 'postgres', ], "--file=$tempdir/defaults_dir_format", 'postgres', ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
@ -99,8 +109,8 @@ my %pgdump_runs = (
defaults_parallel => { defaults_parallel => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
'pg_dump', '-Fd', '-j2', "--file=$tempdir/defaults_parallel", 'pg_dump', '--no-sync', '-Fd', '-j2',
'postgres', ], "--file=$tempdir/defaults_parallel", 'postgres', ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
"--file=$tempdir/defaults_parallel.sql", "--file=$tempdir/defaults_parallel.sql",
@ -108,37 +118,60 @@ my %pgdump_runs = (
defaults_tar_format => { defaults_tar_format => {
test_key => 'defaults', test_key => 'defaults',
dump_cmd => [ dump_cmd => [
'pg_dump', '-Ft', 'pg_dump', '--no-sync', '-Ft',
"--file=$tempdir/defaults_tar_format.tar", 'postgres', ], "--file=$tempdir/defaults_tar_format.tar", 'postgres', ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
"--file=$tempdir/defaults_tar_format.sql", "--file=$tempdir/defaults_tar_format.sql",
"$tempdir/defaults_tar_format.tar", ], }, "$tempdir/defaults_tar_format.tar", ], },
pg_dumpall_globals => { pg_dumpall_globals => {
dump_cmd => dump_cmd => [
[ 'pg_dumpall', "--file=$tempdir/pg_dumpall_globals.sql", '-g', ], 'pg_dumpall',
'--no-sync',
"--file=$tempdir/pg_dumpall_globals.sql",
'-g', ],
}, },
no_privs => { no_privs => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/no_privs.sql", '-x', 'postgres', ], }, 'pg_dump',
'--no-sync',
"--file=$tempdir/no_privs.sql",
'-x',
'postgres', ], },
no_owner => { no_owner => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/no_owner.sql", '-O', 'postgres', ], }, 'pg_dump',
'--no-sync',
"--file=$tempdir/no_owner.sql",
'-O',
'postgres', ], },
schema_only => { schema_only => {
dump_cmd => dump_cmd => [
[ 'pg_dump', "--file=$tempdir/schema_only.sql", '-s', 'postgres', ], 'pg_dump',
'--no-sync',
"--file=$tempdir/schema_only.sql",
'-s',
'postgres', ],
}, },
section_pre_data => { section_pre_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_pre_data.sql", 'pg_dump',
'--section=pre-data', 'postgres', ], }, '--no-sync',
"--file=$tempdir/section_pre_data.sql",
'--section=pre-data',
'postgres', ], },
section_data => { section_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_data.sql", 'pg_dump',
'--section=data', 'postgres', ], }, '--no-sync',
"--file=$tempdir/section_data.sql",
'--section=data',
'postgres', ], },
section_post_data => { section_post_data => {
dump_cmd => [ dump_cmd => [
'pg_dump', "--file=$tempdir/section_post_data.sql", 'pg_dump',
'--no-sync',
"--file=$tempdir/section_post_data.sql",
'--section=post-data', 'postgres', ], },); '--section=post-data', 'postgres', ], },);
############################################################### ###############################################################