Commit ef73a816 authored by Tom Lane's avatar Tom Lane

Enforce our convention about max number of parallel regression tests.

We have a very old rule that parallel_schedule should have no more
than twenty tests in any one parallel group, so as to provide a
bound on the number of concurrently running processes needed to
pass the tests.  But people keep forgetting the rule, so let's add
a few lines of code to check it.

Discussion: https://postgr.es/m/a37e9c57-22d4-1b82-1270-4501cd2e984e@2ndquadrant.com
parent 1fdab4d5
...@@ -124,7 +124,7 @@ tablespace-setup: ...@@ -124,7 +124,7 @@ tablespace-setup:
## Run tests ## Run tests
## ##
REGRESS_OPTS = --dlpath=. $(EXTRA_REGRESS_OPTS) REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 $(EXTRA_REGRESS_OPTS)
check: all tablespace-setup check: all tablespace-setup
$(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS) $(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
......
...@@ -78,6 +78,7 @@ char *launcher = NULL; ...@@ -78,6 +78,7 @@ char *launcher = NULL;
static _stringlist *loadlanguage = NULL; static _stringlist *loadlanguage = NULL;
static _stringlist *loadextension = NULL; static _stringlist *loadextension = NULL;
static int max_connections = 0; static int max_connections = 0;
static int max_concurrent_tests = 0;
static char *encoding = NULL; static char *encoding = NULL;
static _stringlist *schedulelist = NULL; static _stringlist *schedulelist = NULL;
static _stringlist *extra_tests = NULL; static _stringlist *extra_tests = NULL;
...@@ -1592,9 +1593,9 @@ run_schedule(const char *schedule, test_function tfunc) ...@@ -1592,9 +1593,9 @@ run_schedule(const char *schedule, test_function tfunc)
FILE *scf; FILE *scf;
int line_num = 0; int line_num = 0;
memset(resultfiles, 0, sizeof(_stringlist *) * MAX_PARALLEL_TESTS); memset(resultfiles, 0, sizeof(resultfiles));
memset(expectfiles, 0, sizeof(_stringlist *) * MAX_PARALLEL_TESTS); memset(expectfiles, 0, sizeof(expectfiles));
memset(tags, 0, sizeof(_stringlist *) * MAX_PARALLEL_TESTS); memset(tags, 0, sizeof(tags));
scf = fopen(schedule, "r"); scf = fopen(schedule, "r");
if (!scf) if (!scf)
...@@ -1614,6 +1615,7 @@ run_schedule(const char *schedule, test_function tfunc) ...@@ -1614,6 +1615,7 @@ run_schedule(const char *schedule, test_function tfunc)
line_num++; line_num++;
/* clear out string lists left over from previous line */
for (i = 0; i < MAX_PARALLEL_TESTS; i++) for (i = 0; i < MAX_PARALLEL_TESTS; i++)
{ {
if (resultfiles[i] == NULL) if (resultfiles[i] == NULL)
...@@ -1667,8 +1669,8 @@ run_schedule(const char *schedule, test_function tfunc) ...@@ -1667,8 +1669,8 @@ run_schedule(const char *schedule, test_function tfunc)
if (num_tests >= MAX_PARALLEL_TESTS) if (num_tests >= MAX_PARALLEL_TESTS)
{ {
/* can't print scbuf here, it's already been trashed */ /* can't print scbuf here, it's already been trashed */
fprintf(stderr, _("too many parallel tests in schedule file \"%s\", line %d\n"), fprintf(stderr, _("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n"),
schedule, line_num); MAX_PARALLEL_TESTS, schedule, line_num);
exit(2); exit(2);
} }
tests[num_tests] = c; tests[num_tests] = c;
...@@ -1691,6 +1693,13 @@ run_schedule(const char *schedule, test_function tfunc) ...@@ -1691,6 +1693,13 @@ run_schedule(const char *schedule, test_function tfunc)
wait_for_tests(pids, statuses, NULL, 1); wait_for_tests(pids, statuses, NULL, 1);
/* status line is finished below */ /* status line is finished below */
} }
else if (max_concurrent_tests > 0 && max_concurrent_tests < num_tests)
{
/* can't print scbuf here, it's already been trashed */
fprintf(stderr, _("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n"),
max_concurrent_tests, schedule, line_num);
exit(2);
}
else if (max_connections > 0 && max_connections < num_tests) else if (max_connections > 0 && max_connections < num_tests)
{ {
int oldest = 0; int oldest = 0;
...@@ -1999,6 +2008,8 @@ help(void) ...@@ -1999,6 +2008,8 @@ help(void)
printf(_(" tests; can appear multiple times\n")); printf(_(" tests; can appear multiple times\n"));
printf(_(" --max-connections=N maximum number of concurrent connections\n")); printf(_(" --max-connections=N maximum number of concurrent connections\n"));
printf(_(" (default is 0, meaning unlimited)\n")); printf(_(" (default is 0, meaning unlimited)\n"));
printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
printf(_(" (default is 0, meaning unlimited)\n"));
printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n")); printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n"));
printf(_(" --schedule=FILE use test ordering schedule from FILE\n")); printf(_(" --schedule=FILE use test ordering schedule from FILE\n"));
printf(_(" (can be used multiple times to concatenate)\n")); printf(_(" (can be used multiple times to concatenate)\n"));
...@@ -2048,6 +2059,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -2048,6 +2059,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
{"launcher", required_argument, NULL, 21}, {"launcher", required_argument, NULL, 21},
{"load-extension", required_argument, NULL, 22}, {"load-extension", required_argument, NULL, 22},
{"config-auth", required_argument, NULL, 24}, {"config-auth", required_argument, NULL, 24},
{"max-concurrent-tests", required_argument, NULL, 25},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
...@@ -2161,6 +2173,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -2161,6 +2173,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
case 24: case 24:
config_auth_datadir = pg_strdup(optarg); config_auth_datadir = pg_strdup(optarg);
break; break;
case 25:
max_concurrent_tests = atoi(optarg);
break;
default: default:
/* getopt_long already emitted a complaint */ /* getopt_long already emitted a complaint */
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"), fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
......
...@@ -104,6 +104,7 @@ sub installcheck ...@@ -104,6 +104,7 @@ sub installcheck
"--dlpath=.", "--dlpath=.",
"--bindir=../../../$Config/psql", "--bindir=../../../$Config/psql",
"--schedule=${schedule}_schedule", "--schedule=${schedule}_schedule",
"--max-concurrent-tests=20",
"--encoding=SQL_ASCII", "--encoding=SQL_ASCII",
"--no-locale"); "--no-locale");
push(@args, $maxconn) if $maxconn; push(@args, $maxconn) if $maxconn;
...@@ -122,6 +123,7 @@ sub check ...@@ -122,6 +123,7 @@ sub check
"--dlpath=.", "--dlpath=.",
"--bindir=", "--bindir=",
"--schedule=${schedule}_schedule", "--schedule=${schedule}_schedule",
"--max-concurrent-tests=20",
"--encoding=SQL_ASCII", "--encoding=SQL_ASCII",
"--no-locale", "--no-locale",
"--temp-instance=./tmp_check"); "--temp-instance=./tmp_check");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment