You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2017/07/21 19:35:23 UTC
[couchdb] branch master updated: Improve JS restartServer() support
function
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 07c3509 Improve JS restartServer() support function
07c3509 is described below
commit 07c3509b3e8e9ad5a3331e05c32e7c3dc2d68f71
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Fri Jul 21 15:32:15 2017 -0400
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.
---
test/javascript/test_setup.js | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/test/javascript/test_setup.js b/test/javascript/test_setup.js
index 0d27461..a6109b4 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'));
+ }
+ }
}
}
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].