From 8eca1bf892a327428ce2756b618aa5ca0323e256 Mon Sep 17 00:00:00 2001 From: Nitin Motiani Date: Thu, 22 May 2025 10:20:15 +0000 Subject: [PATCH v6 5/5] [WIP] This is WIP patch for adding tests to pg_dump.pl * The first test in the patch was the test we were originally trying to add but it kept failing. * The 3 tests at the bottom were part of the debugging process and the logs showed that those tests would fail whenever a pipe was used inside the pipe command i.e. 'cat | gzip' or 'cat > '. But simple 'cat' or 'gzip' without pipe worked. * The tests need to be cleaned up and rerun to get the exact error messages. --- src/bin/pg_dump/t/002_pg_dump.pl | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 28812d28aa9..658e847193e 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -223,6 +223,15 @@ my %pgdump_runs = ( ], }, + # This test kept failing. + defaults_dir_format_pipe => { + test_key => 'defaults', + dump_cmd => [ + 'pg_dump', '-Fd', 'postgres', + "--pipe-command=\"cat > $tempdir/defaults_dir_format/%f\"", + ], + }, + # Do not use --no-sync to give test coverage for data sync. defaults_parallel => { test_key => 'defaults', @@ -4934,6 +4943,35 @@ foreach my $db (sort keys %create_sql) $node->safe_psql($db, $create_sql{$db}); } +# These four tests were added temporarily to more easily look through the output. +# They failed as soon as we used a pipe of any kind whether to file or just to another +# command. Those commands worked fine manually. So the second & fourth test where +# we only have cat and gzip without any pipe, they work fine. But the rest don't. +$node->command_fails_like( + [ + 'pg_dump', '-Fd', '-B', 'postgres', + "--pipe-command=\"cat > $tempdir/%f\"",], + qr/pg_dump: error: Failure in cat to file/, + 'pg_dump: Failure in cat to file using pipe-command'); + + +$node->command_ok( + [ + 'pg_dump', '-Fd', '-B', 'postgres', + "--pipe-command=\"cat\"",], "Testing just with cat"); + +$node->command_ok( + [ + 'pg_dump', '-Fd', '-B', 'postgres', + "--pipe-command=\"cat | gzip\"",], "Testing with cat piped to gzip"); + + +$node->command_ok( + [ + 'pg_dump', '-Fd', '-B', '-x', 'postgres', + "--pipe-command=\"gzip\"",], "Testing just with gzip"); + + ######################################### # Test connecting to a non-existent database -- 2.52.0.457.g6b5491de43-goog