couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couchdb commit: updated refs/heads/windsor-merge to 3c7aa3f
Date Tue, 12 Aug 2014 20:16:31 GMT
Repository: couchdb
Updated Branches:
  refs/heads/windsor-merge caba89312 -> 3c7aa3ff5


Don't sleep mindlessly for 3s at a time

Attempting to compare the source and target update_seq values isn't
valid as any document modification on the source will permanently alter
the comparison. This changes things to just wait for the task's status
to update and reflect the source database's update sequence.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3c7aa3ff
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3c7aa3ff
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3c7aa3ff

Branch: refs/heads/windsor-merge
Commit: 3c7aa3ff51d14b26c28783947e0d88958a1a33ec
Parents: caba893
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Aug 12 15:15:11 2014 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Aug 12 15:15:11 2014 -0500

----------------------------------------------------------------------
 share/www/script/test/replication.js | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/3c7aa3ff/share/www/script/test/replication.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index de62b3f..0ad9e8c 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -151,16 +151,23 @@ couchTests.replication = function(debug) {
 
 
   function waitForSeq(sourceDb, targetDb) {
-    var targetSeq,
-        sourceSeq = sourceDb.info().update_seq,
+    var sourceSeq = sourceDb.info().update_seq,
         t0 = new Date(),
         t1,
         ms = 3000;
 
     do {
-      targetSeq = targetDb.info().update_seq;
+      var xhr = CouchDB.request("GET", "/_active_tasks");
+      var tasks = JSON.parse(xhr.responseText);
+      for(var i = 0; i < tasks.length; i++) {
+        if(tasks[i].replication_id == repResult._local_id) {
+          if(tasks[i]["source_seq"] == sourceSeq) {
+            return;
+          }
+        }
+      }
       t1 = new Date();
-    } while (((t1 - t0) <= ms) && targetSeq < sourceSeq);
+    } while (((t1 - t0) <= ms));
   }
 
 
@@ -1166,7 +1173,7 @@ couchTests.replication = function(debug) {
 
     var rep_id = repResult._local_id;
 
-    waitForSeq(sourceDb, targetDb);
+    waitForSeq(sourceDb, targetDb, rep_id);
 
     for (j = 0; j < docs.length; j++) {
       doc = docs[j];
@@ -1204,7 +1211,7 @@ couchTests.replication = function(debug) {
     var ddoc = docs[docs.length - 1]; // design doc
     addAtt(sourceDb, ddoc, "readme.txt", att1_data, "text/plain");
 
-    waitForSeq(sourceDb, targetDb);
+    waitForSeq(sourceDb, targetDb, rep_id);
 
     var modifDocs = docs.slice(10, 15).concat([ddoc]);
     for (j = 0; j < modifDocs.length; j++) {
@@ -1249,7 +1256,7 @@ couchTests.replication = function(debug) {
     // add another attachment to the ddoc on source
     addAtt(sourceDb, ddoc, "data.dat", att2_data, "application/binary");
 
-    waitForSeq(sourceDb, targetDb);
+    waitForSeq(sourceDb, targetDb, rep_id);
 
     copy = targetDb.open(ddoc._id);
     var atts = copy._attachments;
@@ -1286,7 +1293,7 @@ couchTests.replication = function(debug) {
     var newDocs = makeDocs(25, 35);
     populateDb(sourceDb, newDocs, true);
 
-    waitForSeq(sourceDb, targetDb);
+    waitForSeq(sourceDb, targetDb, rep_id);
 
     for (j = 0; j < newDocs.length; j++) {
       doc = newDocs[j];
@@ -1306,7 +1313,7 @@ couchTests.replication = function(debug) {
     wait(1000);
     TEquals(true, sourceDb.deleteDoc(newDocs[6]).ok);
 
-    waitForSeq(sourceDb, targetDb);
+    waitForSeq(sourceDb, targetDb, rep_id);
 
     copy = targetDb.open(newDocs[0]._id);
     TEquals(null, copy);
@@ -1390,7 +1397,7 @@ couchTests.replication = function(debug) {
   }
   TEquals(true, found_task);
 
-  waitForSeq(sourceDb, targetDb);
+  waitForSeq(sourceDb, targetDb, repResult._local_id);
   T(sourceDb.open("30") !== null);
 
   // cancel replication


Mime
View raw message