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/05/31 21:35:55 UTC

[couchdb] branch 553-js-restart updated (4ac6f13 -> 0133b59)

This is an automated email from the ASF dual-hosted git repository.

wohali pushed a change to branch 553-js-restart
in repository https://gitbox.apache.org/repos/asf/couchdb.git.

     omits  4ac6f13   Improve JS test harness restartServer() support fn
       new  0133b59   Improve JS test harness restartServer() support fn

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (4ac6f13)
            \
             N -- N -- N   refs/heads/553-js-restart (0133b59)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omits" are not gone; other references still
refer to them.  Any revisions marked "discards" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 test/javascript/test_setup.js | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/01: Improve JS test harness restartServer() support fn

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch 553-js-restart
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 0133b59a301b91a0ec55ed3b18afa95db6a142a2
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed May 31 16:44:12 2017 -0400

    Improve JS test harness restartServer() support fn
    
    restartServer() is still erroring out sometimes in Travis/Jenkins. This
    PR both bumps the timeout to 15s as well as changes the detection
    mechanism for restart to look for the uptime in _system to reset to a
    low number.
    
    This PR also removes the eclipsed redundant restartServer() definition
    in couch_test_runner.js.
    
    Closes #553
---
 test/javascript/couch_test_runner.js | 31 -------------------------------
 test/javascript/test_setup.js        | 29 +++++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/test/javascript/couch_test_runner.js b/test/javascript/couch_test_runner.js
index 6567859..d51748b 100644
--- a/test/javascript/couch_test_runner.js
+++ b/test/javascript/couch_test_runner.js
@@ -436,37 +436,6 @@ function waitForSuccess(fun, tag) {
   }
 }
 
-function getCurrentToken() {
-  var xhr = CouchDB.request("GET", "/_restart/token");
-  return JSON.parse(xhr.responseText).token;
-};
-
-
-function restartServer() {
-  var token = getCurrentToken();
-  var token_changed = false;
-  var tDelta = 5000;
-  var t0 = new Date();
-  var t1;
-
-  CouchDB.request("POST", "/_restart");
-
-  do {
-    try {
-      if(token != getCurrentToken()) {
-        token_changed = true;
-      }
-    } catch (e) {
-      // Ignore errors while the server restarts
-    }
-    t1 = new Date();
-  } while(((t1 - t0) <= tDelta) && !token_changed);
-
-  if(!token_changed) {
-    throw("Server restart failed");
-  }
-}
-
 // legacy functions for CouchDB < 1.2.0
 // we keep them to make sure we keep BC
 CouchDB.user_prefix = "org.couchdb.user:";
diff --git a/test/javascript/test_setup.js b/test/javascript/test_setup.js
index ccc0485..73667ed 100644
--- a/test/javascript/test_setup.js
+++ b/test/javascript/test_setup.js
@@ -71,11 +71,36 @@ function waitForSuccess(fun, tag) {
   }
 }
 
+function getUptime() {
+  var url = "/_node/node1@127.0.0.1/_system"
+  var stats = JSON.parse(CouchDB.request("GET", url).responseText);
+  return stats['uptime'];
+}
+
 function restartServer() {
+  var olduptime = getUptime();
+  if (olduptime < 5) {
+    // handle quick-restarts, though this slows things down
+    sleep(5000);
+    olduptime = getUptime();
+  }
   print('restart');
+
+  /* Need to pass olduptime to check fn so can't reuse waitForSuccess here */
   var start = new Date().getTime();
-  while (new Date().getTime() < start + 1000);
-  waitForSuccess(CouchDB.isRunning, 'restart');
+  var complete = false;
+  while (!complete) {
+    var now = new Date().getTime();
+    if (now > start + 10000) {
+      complete = true;
+      print('\nFAIL restart');
+      quit(1);
+    }
+    try {
+      sleep(500);
+      complete = getUptime() < olduptime;
+    } catch (e) {}
+  }
 }
 
 /*

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.