diff options
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r-- | src/test/isolation/isolationtester.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index f98bb1cf64b..a8353b93af7 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -34,6 +34,10 @@ static int nconns = 0; /* In dry run only output permutations to be run by the tester. */ static int dry_run = false; +/* Maximum time to wait before giving up on a step (in usec) */ +static int64 max_step_wait = 300 * USECS_PER_SEC; + + static void run_testspec(TestSpec *testspec); static void run_all_permutations(TestSpec *testspec); static void run_all_permutations_recurse(TestSpec *testspec, int nsteps, @@ -66,6 +70,7 @@ int main(int argc, char **argv) { const char *conninfo; + const char *env_wait; TestSpec *testspec; int i, j; @@ -110,6 +115,14 @@ main(int argc, char **argv) else conninfo = "dbname = postgres"; + /* + * If PGISOLATIONTIMEOUT is set in the environment, adopt its value (given + * in seconds) as the max time to wait for any one step to complete. + */ + env_wait = getenv("PGISOLATIONTIMEOUT"); + if (env_wait != NULL) + max_step_wait = ((int64) atoi(env_wait)) * USECS_PER_SEC; + /* Read the test spec from stdin */ spec_yyparse(); testspec = &parseresult; @@ -779,7 +792,7 @@ try_complete_step(TestSpec *testspec, Step *step, int flags) td += (int64) current_time.tv_usec - (int64) start_time.tv_usec; /* - * After 180 seconds, try to cancel the query. + * After max_step_wait microseconds, try to cancel the query. * * If the user tries to test an invalid permutation, we don't want * to hang forever, especially when this is running in the @@ -787,7 +800,7 @@ try_complete_step(TestSpec *testspec, Step *step, int flags) * failing, but remaining permutations and tests should still be * OK. */ - if (td > 180 * USECS_PER_SEC && !canceled) + if (td > max_step_wait && !canceled) { PGcancel *cancel = PQgetCancel(conn); @@ -796,7 +809,15 @@ try_complete_step(TestSpec *testspec, Step *step, int flags) char buf[256]; if (PQcancel(cancel, buf, sizeof(buf))) + { + /* + * print to stdout not stderr, as this should appear + * in the test case's results + */ + printf("isolationtester: canceling step %s after %d seconds\n", + step->name, (int) (td / USECS_PER_SEC)); canceled = true; + } else fprintf(stderr, "PQcancel failed: %s\n", buf); PQfreeCancel(cancel); @@ -804,16 +825,16 @@ try_complete_step(TestSpec *testspec, Step *step, int flags) } /* - * After 200 seconds, just give up and die. + * After twice max_step_wait, just give up and die. * * Since cleanup steps won't be run in this case, this may cause * later tests to fail. That stinks, but it's better than waiting * forever for the server to respond to the cancel. */ - if (td > 200 * USECS_PER_SEC) + if (td > 2 * max_step_wait) { - fprintf(stderr, "step %s timed out after 200 seconds\n", - step->name); + fprintf(stderr, "step %s timed out after %d seconds\n", + step->name, (int) (td / USECS_PER_SEC)); exit(1); } } |