diff options
author | Joan Touzet <joant@atypical.net> | 2017-07-21 15:32:15 -0400 |
---|---|---|
committer | Joan Touzet <joant@atypical.net> | 2017-07-21 15:32:15 -0400 |
commit | 07c3509b3e8e9ad5a3331e05c32e7c3dc2d68f71 (patch) | |
tree | 4dd8e2a5e01f0386d685bfd9eb8553eddf1c72fa | |
parent | 42f26d5e7884c9a751340f7488a13a8639bb736b (diff) | |
download | couchdb-07c3509b3e8e9ad5a3331e05c32e7c3dc2d68f71.tar.gz |
Improve JS restartServer() support function
Previously, we potentially could attempt to restart couch,
immediately attempt to see if couch had restarted, and fail
if the server wasn't there (pre- or post-restart).
This change wraps all attempts to contact couch in restartServer()
with try blocks and simplifies the check-if-restarted logic.
Closes #669. May or may not help with #673.
-rw-r--r-- | test/javascript/test_setup.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/test/javascript/test_setup.js b/test/javascript/test_setup.js index 0d274616e..a6109b4d7 100644 --- a/test/javascript/test_setup.js +++ b/test/javascript/test_setup.js @@ -85,20 +85,26 @@ function restartServer() { } print('restart'); - /* Need to pass olduptime to check fn so can't reuse waitForSuccess here */ + /* Wait up to 15s for server to restart */ var start = new Date().getTime(); var complete = false; - while (!complete) { - var now = new Date().getTime(); - if (now > start + 10000) { - complete = true; - uptime = getUptime(); - throw(Error('FAILED to restart: ' + uptime + ' not < ' + olduptime)); - } + while (1) { + sleep(500); try { - sleep(500); - complete = getUptime() < olduptime; + if (getUptime() < olduptime) { + return; + } } catch (e) {} + + var now = new Date().getTime(); + if (now > start + 15000) { + try { + uptime = getUptime(); + throw(Error('FAILED to restart: ' + uptime + ' not < ' + olduptime)); + } catch (e) { + throw(Error('FAILED to restart: server is unresponsive, waited 15s')); + } + } } } |