couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [24/35] couchdb commit: updated refs/heads/2876-js-tests-merged to 6d9b2eb
Date Sat, 12 Dec 2015 16:01:45 GMT
draft compression config


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

Branch: refs/heads/2876-js-tests-merged
Commit: 3346282fa1273ad29de286b757106ad30c76180c
Parents: 29cb25f
Author: sebastianro <sebastianro@apache.org>
Authored: Wed Nov 11 22:36:23 2015 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Sat Dec 12 15:25:10 2015 +0100

----------------------------------------------------------------------
 test/javascript/tests/replication.js | 84 +++++++++++++++++++++----------
 1 file changed, 57 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/3346282f/test/javascript/tests/replication.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/replication.js b/test/javascript/tests/replication.js
index 5b65e38..b2eafeb 100644
--- a/test/javascript/tests/replication.js
+++ b/test/javascript/tests/replication.js
@@ -58,39 +58,69 @@ couchTests.replication = function(debug) {
     return data;
   }
 
-
-  function enableAttCompression(level, types) {
-    var xhr = CouchDB.request(
-      "PUT",
-      "/_config/attachments/compression_level",
-      {
-        body: JSON.stringify(level),
-        headers: {"X-Couch-Persist": "false"}
-      }
-    );
+  
+  function runAllNodes(callback) {
+    // new and fancy: clustered version: pull cluster_members and walk over all of them
+    var xhr = CouchDB.request("GET", "/_membership"); 
     T(xhr.status === 200);
-    xhr = CouchDB.request(
-      "PUT",
-      "/_config/attachments/compressible_types",
-      {
-        body: JSON.stringify(types),
-        headers: {"X-Couch-Persist": "false"}
-      }
-    );
+    JSON.parse(xhr.responseText).cluster_nodes.forEach(callback);
+  }
+
+  function runFirstNode(callback) {
+    // new and fancy: clustered version: pull cluster_members and walk over all of them
+    var xhr = CouchDB.request("GET", "/_membership"); 
     T(xhr.status === 200);
+    var node = JSON.parse(xhr.responseText).cluster_nodes[0];
+    return callback(node);
   }
 
+  function getCompressionInfo() {
+    return runFirstNode(function(node) {
+      var xhr = CouchDB.request(
+        "GET",
+        "_node/" + node + "/_config/attachments"
+      );
+      T(xhr.status === 200);
+      var res = JSON.parse(xhr.responseText);
+      return {"level": res.compression_level, "types": res.compressible_types};
+    });
+  }
+
+  function enableAttCompression(level, types) {
+    runAllNodes(function(node) {
+      var xhr = CouchDB.request(
+        "PUT",
+        "_node/" + node + "/_config/attachments/compression_level",
+        {
+          body: JSON.stringify(level),
+          headers: {"X-Couch-Persist": "false"}
+        }
+      );
+      T(xhr.status === 200);
+      xhr = CouchDB.request(
+        "PUT",
+        "_node/" + node + "/_config/attachments/compressible_types",
+        {
+          body: JSON.stringify(types),
+          headers: {"X-Couch-Persist": "false"}
+        }
+      );
+      T(xhr.status === 200);
+    });
+  }
 
   function disableAttCompression() {
-    var xhr = CouchDB.request(
-      "PUT",
-      "/_config/attachments/compression_level",
-      {
-        body: JSON.stringify("0"),
-        headers: {"X-Couch-Persist": "false"}
-      }
-    );
-    T(xhr.status === 200);
+    runAllNodes(function(node) {
+      var xhr = CouchDB.request(
+        "PUT",
+        "_node/" + node + "/_config/attachments/compression_level",
+        {
+          body: JSON.stringify("0"),
+          headers: {"X-Couch-Persist": "false"}
+        }
+      );
+      T(xhr.status === 200);
+    });
   }
 
 


Mime
View raw message