couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [couchdb] branch master updated: Added tests for checking http status code depending on cluster quorum
Date Mon, 09 Jul 2018 17:46:42 GMT
This is an automated email from the ASF dual-hosted git repository.

jan 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 7dfed0c  Added tests for checking http status code depending on cluster quorum
7dfed0c is described below

commit 7dfed0cbbd2695835698efca438e6b8d9fa17f88
Author: jjrodrig <jjrodrig@gmail.com>
AuthorDate: Fri Feb 9 10:22:10 2018 +0100

    Added tests for checking http status code depending on cluster quorum
---
 .../with-quorum/{db-creation.js => attachments.js} | 29 +++++++++------
 .../{db-creation.js => attachments_delete.js}      | 25 +++++++------
 .../attachments_delete_overridden_quorum.js        | 36 +++++++++++++++++++
 .../with-quorum/attachments_overridden_quorum.js   | 40 +++++++++++++++++++++
 .../with-quorum/{db-creation.js => db_creation.js} |  0
 ...reation.js => db_creation_overridden_quorum.js} | 11 +++---
 .../with-quorum/{db-creation.js => db_deletion.js} | 11 +++---
 ...reation.js => db_deletion_overridden_quorum.js} | 14 +++-----
 .../with-quorum/{db-creation.js => doc_bulk.js}    | 20 +++++------
 ...b-creation.js => doc_bulk_overridden_quorum.js} | 20 +++++------
 .../with-quorum/{db-creation.js => doc_copy.js}    | 20 +++++------
 ...b-creation.js => doc_copy_overridden_quorum.js} | 23 ++++++------
 .../with-quorum/{db-creation.js => doc_crud.js}    | 24 +++++++------
 ...b-creation.js => doc_crud_overridden_quorum.js} | 24 +++++++------
 .../tests-cluster/without-quorum/attachments.js    | 39 ++++++++++++++++++++
 .../without-quorum/attachments_delete.js           | 37 +++++++++++++++++++
 .../attachments_delete_overridden_quorum.js        | 36 +++++++++++++++++++
 .../attachments_overridden_quorum.js               | 42 ++++++++++++++++++++++
 .../{db-creation.js => db_creation.js}             |  0
 ...reation.js => db_creation_overridden_quorum.js} | 12 ++++---
 .../{db-creation.js => db_deletion.js}             | 14 ++++----
 ...reation.js => db_deletion_overridden_quorum.js} | 15 ++++----
 .../without-quorum/{db-creation.js => doc_bulk.js} | 20 +++++------
 ...b-creation.js => doc_bulk_overridden_quorum.js} | 20 +++++------
 .../without-quorum/{db-creation.js => doc_copy.js} | 20 ++++++-----
 ...b-creation.js => doc_copy_overridden_quorum.js} | 23 +++++++-----
 .../without-quorum/{db-creation.js => doc_crud.js} | 25 ++++++++-----
 ...b-creation.js => doc_crud_overridden_quorum.js} | 24 ++++++++-----
 28 files changed, 446 insertions(+), 178 deletions(-)

diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/attachments.js
similarity index 50%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/attachments.js
index f8efd6e..f578f87 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/attachments.js
@@ -10,18 +10,27 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.attachments= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 201,"Should return 201");
+  var rev = JSON.parse(xhr.responseText).rev;
 
-  // cleanup
+  xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + rev, {
+    body:"This is no base64 encoded text-2",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 201,"Should return 201");
+  
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/attachments_delete.js
similarity index 52%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/attachments_delete.js
index f8efd6e..ed7d2db 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/attachments_delete.js
@@ -10,18 +10,23 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.attachments_delete= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 201,"Should return 201 Accepted");
+  var rev = JSON.parse(xhr.responseText).rev;
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev);
+  T(xhr.status == 200,"Should return 200 Ok but returns "+xhr.status);
 
-  // cleanup
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js
b/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js
new file mode 100644
index 0000000..1994a0a
--- /dev/null
+++ b/test/javascript/tests-cluster/with-quorum/attachments_delete_overridden_quorum.js
@@ -0,0 +1,36 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.attachments_delete_overridden_quorum= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev);
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
202->"+xhr.status);
+  // TODO: Define correct behaviour
+  //T(xhr.status == 202,"Should return 202 but returns "+xhr.status);
+
+ //db.deleteDb();
+ // cleanup
+ // TODO DB deletions fails if the quorum is not met.
+ xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+}
diff --git a/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js
new file mode 100644
index 0000000..22c8a4c
--- /dev/null
+++ b/test/javascript/tests-cluster/with-quorum/attachments_overridden_quorum.js
@@ -0,0 +1,40 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+//Test attachments operations with an overridden quorum parameter
+couchTests.attachments_overriden_quorum= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  //TODO: Define correct behaviour
+  //T(xhr.status == 202,"Should return 202");
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + rev, {
+    body:"This is no base64 encoded text-2",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
202->"+xhr.status);
+  //TODO: Define correct behaviour
+  //T(xhr.status == 202,"Should return 202");
+
+  db.deleteDb();
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/db_creation.js
similarity index 100%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/db_creation.js
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js
similarity index 62%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js
index f8efd6e..14d319c 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js
@@ -10,17 +10,18 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB creation under cluster with quorum conditions but overriding write quorum.
+couchTests.db_creation_overridden_quorum = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
 
-  // DB Creation should return 201 - Created
+  // DB Creation should return 202 - Accepted
   xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
202->"+xhr.status)
+  //T(xhr.status == 202,"Should return 202");
 
   // cleanup
   db.deleteDb();
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/db_deletion.js
similarity index 74%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/db_deletion.js
index f8efd6e..bef4cae 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/db_deletion.js
@@ -10,18 +10,15 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB deletion in a cluster with quorum conditions.
+couchTests.db_deletion = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
-
-  // cleanup
   db.deleteDb();
+  T(db.last_req.status="200","Should return 200");
 };
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js
similarity index 67%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js
index f8efd6e..01417eb 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js
@@ -10,18 +10,14 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB deletion in a cluster with quorum conditions.
+couchTests.db_deletion_overridden_quorum = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
-
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
-
-  // cleanup
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
   db.deleteDb();
+  T(db.last_req.status="202","Should return 202");
 };
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_bulk.js
similarity index 70%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/doc_bulk.js
index f8efd6e..4bdd3c8 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_bulk.js
@@ -10,18 +10,16 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
-  if (debug) debugger;
-
-  var db_name = get_random_db_name()
+couchTests.doc_bulk = function(debug) {
+  var db_name = get_random_db_name();
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
+  if (debug) debugger;
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var docs = makeDocs(5);
+  // Create the docs
+  var results = db.bulkSave(docs);
+  T(db.last_req.status="201","Should return 201")
 
-  // cleanup
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js
similarity index 63%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js
index f8efd6e..0cf9a7e 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js
@@ -10,18 +10,16 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_bulk_overridden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
-
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var docs = makeDocs(5);
+  // Create the docs
+  var results = db.bulkSave(docs);
+  T(db.last_req.status="202","Should return 202")
 
-  // cleanup
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_copy.js
similarity index 70%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/doc_copy.js
index f8efd6e..386ca56 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_copy.js
@@ -10,18 +10,18 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_copy = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"dummy"});
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", {
+    headers: {"Destination":"dummy2"}
+  });
+  T(xhr.status=="201","Should return 201 ");
 
-  // cleanup
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js
similarity index 53%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js
index f8efd6e..23fbc97 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js
@@ -10,18 +10,21 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_copy_overriden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"dummy"});
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", {
+    headers: {"Destination":"dummy2"}
+  });
+  //TODO: Define correct behaviour
+  //T(xhr.status=="202","Should return 202");
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
202->"+xhr.status);
 
-  // cleanup
   db.deleteDb();
-};
+
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_crud.js
similarity index 68%
copy from test/javascript/tests-cluster/with-quorum/db-creation.js
copy to test/javascript/tests-cluster/with-quorum/doc_crud.js
index f8efd6e..f016cef 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_crud.js
@@ -10,18 +10,22 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_crud = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"0",a:1});
+  T(db.last_req.status=="201");
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  var doc = db.open("0");
+  db.save(doc);
+  T(db.last_req.status=="201");
 
-  // cleanup
+  doc = db.open("0");
+  db.deleteDoc(doc);
+  T(db.last_req.status="200");
   db.deleteDb();
-};
+
+}
diff --git a/test/javascript/tests-cluster/with-quorum/db-creation.js b/test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js
similarity index 55%
rename from test/javascript/tests-cluster/with-quorum/db-creation.js
rename to test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js
index f8efd6e..41502ca 100644
--- a/test/javascript/tests-cluster/with-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js
@@ -10,18 +10,22 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster with quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_crud_overridden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":3});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"0",a:1});
+  T(db.last_req.status=="202","Should return 202 status");
+
+  var doc = db.open("0");
+  db.save(doc);
+  T(db.last_req.status=="202","Should return 202 status");
 
-  // DB Creation should return 201 - Created
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 201);
+  doc = db.open("0");
+  db.deleteDoc(doc);
+  T(db.last_req.status="202","Should return 202 status");
 
-  // cleanup
   db.deleteDb();
-};
+}
diff --git a/test/javascript/tests-cluster/without-quorum/attachments.js b/test/javascript/tests-cluster/without-quorum/attachments.js
new file mode 100644
index 0000000..5756343
--- /dev/null
+++ b/test/javascript/tests-cluster/without-quorum/attachments.js
@@ -0,0 +1,39 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.attachments= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 202,"Should return 202 Accepted");
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + rev, {
+    body:"This is no base64 encoded text-2",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 202,"Should return 202 Accepted");
+  rev = JSON.parse(xhr.responseText).rev;
+
+ //db.deleteDb();
+ // cleanup
+ // TODO DB deletions fails if the quorum is not met.
+ xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+}
diff --git a/test/javascript/tests-cluster/without-quorum/attachments_delete.js b/test/javascript/tests-cluster/without-quorum/attachments_delete.js
new file mode 100644
index 0000000..d05fcaf
--- /dev/null
+++ b/test/javascript/tests-cluster/without-quorum/attachments_delete.js
@@ -0,0 +1,37 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.attachments_delete= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  T(xhr.status == 202,"Should return 202 Accepted");
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev);
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status);
+  //TODO: Define correct behaviour
+  //T(xhr.status == 202,"Should return 202 Accepted but returns "+xhr.status);
+
+ //db.deleteDb();
+ // cleanup
+ // TODO DB deletions fails if the quorum is not met.
+ xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+}
diff --git a/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js
b/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js
new file mode 100644
index 0000000..906391a
--- /dev/null
+++ b/test/javascript/tests-cluster/without-quorum/attachments_delete_overridden_quorum.js
@@ -0,0 +1,36 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.attachments_delete_overridden_quorum= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev);
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering quorum. 202->"+xhr.status);
+  //TODO: Define correct behaviour
+  //T(xhr.status == 200,"Should return 200 but returns "+xhr.status);
+
+ //db.deleteDb();
+ // cleanup
+ // TODO DB deletions fails if the quorum is not met.
+ xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+}
diff --git a/test/javascript/tests-cluster/without-quorum/attachments_overridden_quorum.js
b/test/javascript/tests-cluster/without-quorum/attachments_overridden_quorum.js
new file mode 100644
index 0000000..434578f
--- /dev/null
+++ b/test/javascript/tests-cluster/without-quorum/attachments_overridden_quorum.js
@@ -0,0 +1,42 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+//Test attachments operations with an overridden quorum parameter
+couchTests.attachments_overriden_quorum= function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
+  if (debug) debugger;
+
+  var doc = db.save({_id:"dummy"});
+  T(doc.ok);
+
+  var xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + doc.rev, {
+    body:"This is no base64 encoded text",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  //TODO: Define correct behaviour
+  //T(xhr.status == 201,"Should return 201");
+  var rev = JSON.parse(xhr.responseText).rev;
+
+  xhr = CouchDB.request("PUT", "/" + db_name + "/dummy/foo.txt?rev=" + rev, {
+    body:"This is no base64 encoded text-2",
+    headers:{"Content-Type": "text/plain;charset=utf-8"}
+  });
+  //TODO: Define correct behaviour
+  //T(xhr.status == 201,"Should return 201");
+
+  //db.deleteDb();
+  // cleanup
+  // TODO DB deletions fails if the quorum is not met.
+  xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/db_creation.js
similarity index 100%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/db_creation.js
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js
similarity index 64%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js
index 0d8ff83..6d5d798 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js
@@ -10,18 +10,20 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB creation under cluster with quorum conditions but overriding write quorum.
+couchTests.db_creation_overridden_quorum = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
 
-  // DB Creation should return 202- Accepted
+  // DB Creation should return 201 - Created
   xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
201->"+xhr.status)
+  //T(xhr.status == 201,"Should return 201");
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/db_deletion.js
similarity index 75%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/db_deletion.js
index 0d8ff83..04b15c0 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/db_deletion.js
@@ -10,19 +10,19 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB deletion in a cluster with quorum conditions.
+couchTests.db_deletion = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
-
-  // cleanup
+  //db.deleteDb();
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+  //T(db.last_req.status="202","Should return 202");
+  console.log("Skipped-TODO: Fix issue 500 Error on delete. 202->"+xhr.status)
+
 };
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
similarity index 64%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
index 0d8ff83..4a1efce 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
@@ -10,19 +10,20 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
+// Do DB deletion in a cluster with quorum conditions.
+couchTests.db_deletion_overridden_quorum = function(debug) {
 
   if (debug) debugger;
 
   var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
 
-  // cleanup
+  //db.deleteDb();
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
+  //T(db.last_req.status="200","Should return 200");
+  console.log("Skipped-TODO: Fix issue 500 Error on delete - Not considering overriden quorum.
200->"+xhr.status);
+
 };
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_bulk.js
similarity index 74%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/doc_bulk.js
index 0d8ff83..91578d8 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_bulk.js
@@ -10,19 +10,19 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
-  if (debug) debugger;
-
-  var db_name = get_random_db_name()
+couchTests.doc_bulk = function(debug) {
+  var db_name = get_random_db_name();
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
+  if (debug) debugger;
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  var docs = makeDocs(5);
+  // Create the docs
+  var results = db.bulkSave(docs);
+  T(db.last_req.status="202","Should return 202")
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_bulk_overridden_quorum.js
similarity index 67%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/doc_bulk_overridden_quorum.js
index 0d8ff83..56fb11e 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_bulk_overridden_quorum.js
@@ -10,19 +10,19 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_bulk_overridden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
-
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  var docs = makeDocs(5);
+  // Create the docs
+  var results = db.bulkSave(docs);
+  T(db.last_req.status="201","Should return 201")
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_copy.js
similarity index 72%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/doc_copy.js
index 0d8ff83..7d7c35f 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_copy.js
@@ -10,19 +10,21 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_copy = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"dummy"});
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", {
+    headers: {"Destination":"dummy2"}
+  });
+  T(xhr.status=="202","Should return 202 ");
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js
similarity index 56%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js
index 0d8ff83..e72425d 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js
@@ -10,19 +10,24 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_copy_overriden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"dummy"});
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", {
+    headers: {"Destination":"dummy2"}
+  });
+  console.log("Skipped-TODO: Clarify correct behaviour. Is not considering overridden quorum.
201->"+xhr.status);
+  //TODO Defie correct behaviour
+  //T(xhr.status=="201","Should return 201");
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_crud.js
similarity index 65%
copy from test/javascript/tests-cluster/without-quorum/db-creation.js
copy to test/javascript/tests-cluster/without-quorum/doc_crud.js
index 0d8ff83..aa70697 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_crud.js
@@ -10,19 +10,26 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_crud = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"0",a:1});
+  T(db.last_req.status=="202","Should return 202 status");
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  var doc = db.open("0");
+  db.save(doc);
+  T(db.last_req.status=="202","Should return 202 status");
 
+  doc = db.open("0");
+  db.deleteDoc(doc);
+  T(db.last_req.status="202","Should return 202 status");
+
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+
+}
diff --git a/test/javascript/tests-cluster/without-quorum/db-creation.js b/test/javascript/tests-cluster/without-quorum/doc_crud_overridden_quorum.js
similarity index 58%
rename from test/javascript/tests-cluster/without-quorum/db-creation.js
rename to test/javascript/tests-cluster/without-quorum/doc_crud_overridden_quorum.js
index 0d8ff83..44ab86e 100644
--- a/test/javascript/tests-cluster/without-quorum/db-creation.js
+++ b/test/javascript/tests-cluster/without-quorum/doc_crud_overridden_quorum.js
@@ -10,19 +10,25 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Do DB creation under cluster without quorum conditions.
-couchTests.db_creation = function(debug) {
-
+couchTests.doc_crud_overridden_quorum = function(debug) {
+  var db_name = get_random_db_name();
+  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"},{"w":1});
+  db.createDb();
   if (debug) debugger;
 
-  var db_name = get_random_db_name()
-  var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+  db.save({_id:"0",a:1});
+  T(db.last_req.status=="201","Should return 201 status");
+
+  var doc = db.open("0");
+  db.save(doc);
+  T(db.last_req.status=="201","Should return 201 status");
 
-  // DB Creation should return 202- Accepted
-  xhr = CouchDB.request("PUT", "/" + db_name + "/");
-  T(xhr.status == 202);
+  doc = db.open("0");
+  db.deleteDoc(doc);
+  T(db.last_req.status="200","Should return 200 status");
 
+  //db.deleteDb();
   // cleanup
   // TODO DB deletions fails if the quorum is not met.
   xhr = CouchDB.request("DELETE", "/" + db_name + "/");
-};
+}


Mime
View raw message