From 2b6d390e02ea7cf4b7bb431046ca7c7f95aa75cd Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Tue, 17 Mar 2026 10:01:13 +0100 Subject: [PATCH v4 5/5] Simplify and improve output of 002_pg_upgrade.pl and 027_stream_regress.pl tests Due to recent commits test output of both pg_regress and command_ok have been improved. This allows us to simplify the way pg_regress was run in both the 002_pg_upgrade.pl and 027_stream_regress.pl, while at the same time getting better output too. The original output when running the test using meson looked like this for 002_pg_upgrade.pl and for : stderr: # Failed test 'regression tests pass' # at /home/jelte/work/postgres-4/src/bin/pg_upgrade/t/002_pg_upgrade.pl line 308. # got: '256' # expected: '0' # Looks like you failed 1 test of 20. (test program exited with status code 1) Now it looks like: Listing only the last 100 lines from a long log. # ok 25 + point 14 ms # ok 26 + lseg 9 ms # ok 27 + line 12 ms # ... 199 lines omitted ... # ok 213 + returning 63 ms # ok 214 + largeobject 80 ms # ok 215 + with 110 ms # ok 216 + xml 433 ms # # parallel group (18 tests): numa hash_part reloptions explain predicate partition_info compression_lz4 compression memoize eager_aggregate partition_merge partition_split partition_join partition_aggregate partition_prune tuplesort indexing stats # ok 217 + partition_merge 207 ms # ok 218 + partition_split 226 ms # ok 219 + partition_join 268 ms # ok 220 + partition_prune 326 ms # ok 221 + reloptions 23 ms # ok 222 + hash_part 16 ms # ok 223 + indexing 367 ms # ok 224 + partition_aggregate 317 ms # ok 225 + partition_info 41 ms # ok 226 + tuplesort 328 ms # ok 227 + explain 36 ms # ok 228 + compression 70 ms # ok 229 + compression_lz4 63 ms # ok 230 + memoize 85 ms # ok 231 + stats 443 ms # ok 232 + predicate 40 ms # ok 233 + numa 7 ms # ok 234 + eager_aggregate 142 ms # # parallel group (2 tests): oidjoins event_trigger # ok 235 + oidjoins 74 ms # ok 236 + event_trigger 82 ms # ok 237 - event_trigger_login 18 ms # ok 238 - fast_default 67 ms # ok 239 - tablespace 173 ms # 1..239 # -------------- stderr -------------- # # diff -U3 /home/jelte/work/postgres-4/src/test/regress/expected/oid8.out /home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/results/oid8.out # # --- /home/jelte/work/postgres-4/src/test/regress/expected/oid8.out 2026-03-16 10:26:38.498798476 +0100 # # +++ /home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/results/oid8.out 2026-03-17 09:59:48.621621265 +0100 # # @@ -6,7 +6,7 @@ # # INSERT INTO OID8_TBL(f1) VALUES ('1235'); # # INSERT INTO OID8_TBL(f1) VALUES ('987'); # # INSERT INTO OID8_TBL(f1) VALUES ('-1040'); # # -INSERT INTO OID8_TBL(f1) VALUES ('88888888'); # # +INSERT INTO OID8_TBL(f1) VALUES ('99999999'); # # INSERT INTO OID8_TBL(f1) VALUES ('5 '); # # INSERT INTO OID8_TBL(f1) VALUES (' 10 '); # # INSERT INTO OID8_TBL(f1) VALUES ('123456789012345678'); # # diff -U3 /home/jelte/work/postgres-4/src/test/regress/expected/drop_if_exists.out /home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/results/drop_if_exists.out # # --- /home/jelte/work/postgres-4/src/test/regress/expected/drop_if_exists.out 2026-02-12 22:47:28.927291354 +0100 # # +++ /home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/results/drop_if_exists.out 2026-03-17 09:59:49.364125282 +0100 # # @@ -317,12 +317,6 @@ # # -- Likewise for procedures. # # CREATE PROCEDURE test_ambiguous_procname(int) as $$ begin end; $$ language plpgsql; # # CREATE PROCEDURE test_ambiguous_procname(text) as $$ begin end; $$ language plpgsql; # # -DROP PROCEDURE test_ambiguous_procname; # # -ERROR: procedure name "test_ambiguous_procname" is not unique # # -HINT: Specify the argument list to select the procedure unambiguously. # # -DROP PROCEDURE IF EXISTS test_ambiguous_procname; # # -ERROR: procedure name "test_ambiguous_procname" is not unique # # -HINT: Specify the argument list to select the procedure unambiguously. # # -- Check we get a similar error if we use ROUTINE instead of PROCEDURE. # # DROP ROUTINE IF EXISTS test_ambiguous_procname; # # ERROR: routine name "test_ambiguous_procname" is not unique # # diff -U3 /home/jelte/work/postgres-4/src/test/regress/expected/select_parallel.out /home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/results/select_parallel.out # # --- /home/jelte/work/postgres-4/src/test/regress/expected/select_parallel.out 2026-02-12 22:47:29.021292660 +0100 # ... 25 lines omitted ... # # - Aggregate # # - -> Gather # # - Workers Planned: 3 # # - -> Parallel Append # # - -> Parallel Seq Scan on part_pa_test_p1 pa2_1 # # - -> Parallel Seq Scan on part_pa_test_p2 pa2_2 # # - SubPlan expr_1 # # - -> Result # # - SubPlan expr_2 # # - -> Append # # - -> Seq Scan on part_pa_test_p1 pa1_1 # # - Filter: (a = pa2.a) # # - -> Seq Scan on part_pa_test_p2 pa1_2 # # - Filter: (a = pa2.a) # # -(14 rows) # # - # # -drop table part_pa_test; # # --- test with leader participation disabled # # -set parallel_leader_participation = off; # # -explain (costs off) # # - select count(*) from tenk1 where stringu1 = 'GRAAAA'; # # - QUERY PLAN # # ---------------------------------------------------------- # # - Finalize Aggregate # # - -> Gather # # (diff output truncated and silencing output for further failing tests...) # # (diff output truncated and silencing output for further failing tests...) # # 4 of 239 tests failed. # # The differences that caused some tests to fail can be viewed in the file "/home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/regression.diffs". # # A copy of the test summary that you see above is saved in the file "/home/jelte/work/postgres-4/build/testrun/pg_upgrade/002_pg_upgrade/data/regression.out". # ------------------------------------ # Looks like you failed 1 test of 20. For 027_stream_regress.pl it would already dump the head and tail, but now the head of the diff would be outside of the 100 line limit. Now we can actually see the first failure, which is most often what we want to see. Also, now we show it in a consistent way. --- src/bin/pg_upgrade/t/002_pg_upgrade.pl | 40 ++++++----------- src/test/recovery/t/027_stream_regress.pl | 55 +++++++---------------- 2 files changed, 29 insertions(+), 66 deletions(-) diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index cd2d2f30078..0a4121fdc4d 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -280,32 +280,20 @@ else # --inputdir points to the path of the input files. my $inputdir = "$srcdir/src/test/regress"; - note 'running regression tests in old instance'; - my $rc = - system($ENV{PG_REGRESS} - . " $extra_opts " - . "--dlpath=\"$dlpath\" " - . "--bindir= " - . "--host=" - . $oldnode->host . " " - . "--port=" - . $oldnode->port . " " - . "--schedule=$srcdir/src/test/regress/parallel_schedule " - . "--max-concurrent-tests=20 " - . "--inputdir=\"$inputdir\" " - . "--outputdir=\"$outputdir\""); - if ($rc != 0) - { - # Dump out the regression diffs file, if there is one - my $diffs = "$outputdir/regression.diffs"; - if (-e $diffs) - { - print "=== dumping $diffs ===\n"; - print slurp_file($diffs); - print "=== EOF ===\n"; - } - } - is($rc, 0, 'regression tests pass'); + command_ok( + [ + $ENV{PG_REGRESS}, + split(' ', $extra_opts), + "--dlpath=$dlpath", + '--bindir=', + '--host=' . $oldnode->host, + '--port=' . $oldnode->port, + "--schedule=$srcdir/src/test/regress/parallel_schedule", + '--max-concurrent-tests=20', + "--inputdir=$inputdir", + "--outputdir=$outputdir" + ], + 'regression tests in old instance'); } # Initialize a new node for the upgrade. diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl index 259fd680ff3..ae977297849 100644 --- a/src/test/recovery/t/027_stream_regress.pl +++ b/src/test/recovery/t/027_stream_regress.pl @@ -68,48 +68,23 @@ my $outputdir = $PostgreSQL::Test::Utils::tmp_check; # Run the regression tests against the primary. my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || ""; -my $rc = - system($ENV{PG_REGRESS} - . " $extra_opts " - . "--dlpath=\"$dlpath\" " - . "--bindir= " - . "--host=" - . $node_primary->host . " " - . "--port=" - . $node_primary->port . " " - . "--schedule=../regress/parallel_schedule " - . "--max-concurrent-tests=20 " - . "--inputdir=../regress " - . "--outputdir=\"$outputdir\""); - -# Regression diffs are only meaningful if both the primary and the standby -# are still alive after a regression test failure. +command_ok( + [ + $ENV{PG_REGRESS}, + split(' ', $extra_opts), + "--dlpath=$dlpath", + '--bindir=', + '--host=' . $node_primary->host, + '--port=' . $node_primary->port, + '--schedule=../regress/parallel_schedule', + '--max-concurrent-tests=20', + '--inputdir=../regress', + "--outputdir=$outputdir" + ], + 'regression tests pass'); + my $primary_alive = $node_primary->is_alive; my $standby_alive = $node_standby_1->is_alive; -if ($rc != 0 && $primary_alive && $standby_alive) -{ - # Dump out the regression diffs file, if there is one - my $diffs = "$outputdir/regression.diffs"; - if (-e $diffs) - { - # Dump portions of the diff file. - my ($head, $tail) = read_head_tail($diffs); - - diag("=== dumping $diffs (head) ==="); - foreach my $line (@$head) - { - diag($line); - } - - diag("=== dumping $diffs (tail) ==="); - foreach my $line (@$tail) - { - diag($line); - } - diag("=== EOF ==="); - } -} -is($rc, 0, 'regression tests pass'); is($primary_alive, 1, 'primary alive after regression test run'); is($standby_alive, 1, 'standby alive after regression test run'); -- 2.53.0