commit 9630f6367d2b5079976bef0a27bb925d00cb798d Author: anastasia Date: Tue Jun 8 02:01:35 2021 +0300 v4-0001-Test-replay-of-regression-tests.patch diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index cb401a45b3..7a10c83d8a 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -289,6 +289,17 @@ make check-world PG_TEST_EXTRA='kerberos ldap ssl' + + + wal_consistency_checking + + + Uses wal_consistency_checking=all while running + some of the tests under src/test/recovery. Not + enabled by default because it is resource intensive. + + + Tests for features that are not supported by the current build diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 45d1636128..7b0af9fd78 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -484,7 +484,7 @@ sub init print $conf "hot_standby = on\n"; # conservative settings to ensure we can run multiple postmasters: print $conf "shared_buffers = 1MB\n"; - print $conf "max_connections = 10\n"; + print $conf "max_connections = 25\n"; # limit disk space consumption, too: print $conf "max_wal_size = 128MB\n"; } diff --git a/src/test/recovery/.gitignore b/src/test/recovery/.gitignore index 871e943d50..03410b70a3 100644 --- a/src/test/recovery/.gitignore +++ b/src/test/recovery/.gitignore @@ -1,2 +1,10 @@ # Generated by test suite /tmp_check/ +/results/ +/expected/ +/sql/ +/log/ + +# Note: regression.* are only left behind on a failure; that's why they're not ignored +#/regression.diffs +#/regression.out diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile index 96442ceb4e..0b0d6094cc 100644 --- a/src/test/recovery/Makefile +++ b/src/test/recovery/Makefile @@ -15,6 +15,10 @@ subdir = src/test/recovery top_builddir = ../../.. include $(top_builddir)/src/Makefile.global +# These are created by pg_regress. +# So we need rules to clean them. +pg_regress_clean_files += sql/ expected/ + check: $(prove_check) @@ -22,4 +26,4 @@ installcheck: $(prove_installcheck) clean distclean maintainer-clean: - rm -rf tmp_check + rm -rf $(pg_regress_clean_files) diff --git a/src/test/recovery/t/026_stream_rep_regress.pl b/src/test/recovery/t/026_stream_rep_regress.pl new file mode 100644 index 0000000000..0043405739 --- /dev/null +++ b/src/test/recovery/t/026_stream_rep_regress.pl @@ -0,0 +1,59 @@ +# Run the standard regression tests with streaming replication +use strict; +use warnings; +use PostgresNode; +use TestLib; +use Test::More tests => 2; + +# Initialize primary node +my $node_primary = get_new_node('primary'); +$node_primary->init( + allows_streaming => 1); + +# WAL consistency checking is resource intensive so require opt-in with the +# PG_TEST_EXTRA environment variable. +if ($ENV{PG_TEST_EXTRA} && + $ENV{PG_TEST_EXTRA} =~ m/\bwal_consistency_checking\b/) { + $node_primary->append_conf('postgresql.conf', + 'wal_consistency_checking = all'); +} + +$node_primary->start; +is( $node_primary->psql( + 'postgres', + qq[SELECT pg_create_physical_replication_slot('standby_1');]), + 0, + 'physical slot created on primary'); +my $backup_name = 'my_backup'; + +# Take backup +$node_primary->backup($backup_name); + +# Create streaming standby linking to primary +my $node_standby_1 = get_new_node('standby_1'); +$node_standby_1->init_from_backup($node_primary, $backup_name, + has_streaming => 1); +$node_standby_1->append_conf('postgresql.conf', + "primary_slot_name = standby_1"); +$node_standby_1->start; + +# XXX The tablespace tests don't currently work when the standby shares a +# filesystem with the primary, due to colliding absolute paths. We'll skip +# that for now. + +# Run the regression tests against the primary. +system_or_bail("../regress/pg_regress", + "--port=" . $node_primary->port, + "--schedule=../regress/parallel_schedule", + "--dlpath=../regress", + "--inputdir=../regress", + "--skip-tests=tablespace"); + +# Wait for standby to catch up +$node_primary->wait_for_catchup($node_standby_1, 'replay', + $node_primary->lsn('insert')); + +ok(1, "caught up"); + +$node_standby_1->stop; +$node_primary->stop; diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index e04d365258..510afaadbf 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -83,6 +83,7 @@ static int max_connections = 0; static int max_concurrent_tests = 0; static char *encoding = NULL; static _stringlist *schedulelist = NULL; +static _stringlist *skip_tests = NULL; static _stringlist *extra_tests = NULL; static char *temp_instance = NULL; static _stringlist *temp_configs = NULL; @@ -203,6 +204,22 @@ split_to_stringlist(const char *s, const char *delim, _stringlist **listhead) free(sc); } +/* + * Test if a string is in a list. + */ +static bool +string_in_stringlist(const char *s, _stringlist *list) +{ + while (list) + { + if (strcmp(list->str, s) == 0) + return true; + list = list->next; + } + + return false; +} + /* * Print a progress banner on stdout. */ @@ -1672,7 +1689,11 @@ run_schedule(const char *schedule, test_start_function startfunc, if (scbuf[0] == '\0' || scbuf[0] == '#') continue; if (strncmp(scbuf, "test: ", 6) == 0) + { test = scbuf + 6; + if (string_in_stringlist(test, skip_tests)) + continue; + } else if (strncmp(scbuf, "ignore: ", 8) == 0) { c = scbuf + 8; @@ -1870,6 +1891,7 @@ run_schedule(const char *schedule, test_start_function startfunc, } free_stringlist(&ignorelist); + free_stringlist(&skip_tests); fclose(scf); } @@ -2076,6 +2098,7 @@ help(void) printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n")); printf(_(" --schedule=FILE use test ordering schedule from FILE\n")); printf(_(" (can be used multiple times to concatenate)\n")); + printf(_(" --skip-tests=LIST comma-separated list of tests to skip\n")); printf(_(" --temp-instance=DIR create a temporary instance in DIR\n")); printf(_(" --use-existing use an existing installation\n")); printf(_(" -V, --version output version information, then exit\n")); @@ -2128,6 +2151,7 @@ regression_main(int argc, char *argv[], {"config-auth", required_argument, NULL, 24}, {"max-concurrent-tests", required_argument, NULL, 25}, {"make-testtablespace-dir", no_argument, NULL, 26}, + {"skip-tests", required_argument, NULL, 27}, {NULL, 0, NULL, 0} }; @@ -2261,6 +2285,9 @@ regression_main(int argc, char *argv[], case 26: make_testtablespace_dir = true; break; + case 27: + split_to_stringlist(optarg, ",", &skip_tests); + break; default: /* getopt_long already emitted a complaint */ fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),