janl closed pull request #1157: Add testing for http API status code responses in different quorum conditions URL: https://github.com/apache/couchdb/pull/1157
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/test/javascript/tests-cluster/with-quorum/attachments.js b/test/javascript/tests-cluster/with-quorum/attachments.js new file mode 100644 index 0000000000..f578f877c1 --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/attachments.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= 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 == 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"} + }); + T(xhr.status == 201,"Should return 201"); + + db.deleteDb(); +} diff --git a/test/javascript/tests-cluster/with-quorum/attachments_delete.js b/test/javascript/tests-cluster/with-quorum/attachments_delete.js new file mode 100644 index 0000000000..ed7d2db9a1 --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/attachments_delete.js @@ -0,0 +1,32 @@ +// 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 == 201,"Should return 201 Accepted"); + var rev = JSON.parse(xhr.responseText).rev; + + xhr = CouchDB.request("DELETE", "/" + db_name + "/dummy/foo.txt?rev=" + rev); + T(xhr.status == 200,"Should return 200 Ok but returns "+xhr.status); + + 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 0000000000..1994a0ac24 --- /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 0000000000..22c8a4c877 --- /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% rename from test/javascript/tests-cluster/with-quorum/db-creation.js rename to test/javascript/tests-cluster/with-quorum/db_creation.js diff --git a/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js new file mode 100644 index 0000000000..14d319ccd7 --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/db_creation_overridden_quorum.js @@ -0,0 +1,28 @@ +// 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. + +// 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"},{"w":3}); + + // DB Creation should return 202 - Accepted + xhr = CouchDB.request("PUT", "/" + db_name + "/"); + 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_deletion.js b/test/javascript/tests-cluster/with-quorum/db_deletion.js new file mode 100644 index 0000000000..bef4cae43d --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/db_deletion.js @@ -0,0 +1,24 @@ +// 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. + +// 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.deleteDb(); + T(db.last_req.status="200","Should return 200"); +}; diff --git a/test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js new file mode 100644 index 0000000000..01417eb63d --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/db_deletion_overridden_quorum.js @@ -0,0 +1,23 @@ +// 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. + +// 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"},{"w":3}); + db.createDb(); + db.deleteDb(); + T(db.last_req.status="202","Should return 202"); +}; diff --git a/test/javascript/tests-cluster/with-quorum/doc_bulk.js b/test/javascript/tests-cluster/with-quorum/doc_bulk.js new file mode 100644 index 0000000000..4bdd3c84ba --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_bulk.js @@ -0,0 +1,25 @@ +// 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.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; + + var docs = makeDocs(5); + // Create the docs + var results = db.bulkSave(docs); + T(db.last_req.status="201","Should return 201") + + db.deleteDb(); +} diff --git a/test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js new file mode 100644 index 0000000000..0cf9a7e8cc --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_bulk_overridden_quorum.js @@ -0,0 +1,25 @@ +// 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.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 docs = makeDocs(5); + // Create the docs + var results = db.bulkSave(docs); + T(db.last_req.status="202","Should return 202") + + db.deleteDb(); +} diff --git a/test/javascript/tests-cluster/with-quorum/doc_copy.js b/test/javascript/tests-cluster/with-quorum/doc_copy.js new file mode 100644 index 0000000000..386ca5671f --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_copy.js @@ -0,0 +1,27 @@ +// 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.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; + + db.save({_id:"dummy"}); + + var xhr = CouchDB.request("COPY", "/" + db_name + "/dummy", { + headers: {"Destination":"dummy2"} + }); + T(xhr.status=="201","Should return 201 "); + + db.deleteDb(); +} diff --git a/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js new file mode 100644 index 0000000000..23fbc9754a --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_copy_overridden_quorum.js @@ -0,0 +1,30 @@ +// 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.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; + + db.save({_id:"dummy"}); + + 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); + + db.deleteDb(); + +} diff --git a/test/javascript/tests-cluster/with-quorum/doc_crud.js b/test/javascript/tests-cluster/with-quorum/doc_crud.js new file mode 100644 index 0000000000..f016cefdd0 --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_crud.js @@ -0,0 +1,31 @@ +// 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.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; + + db.save({_id:"0",a:1}); + T(db.last_req.status=="201"); + + var doc = db.open("0"); + db.save(doc); + T(db.last_req.status=="201"); + + doc = db.open("0"); + db.deleteDoc(doc); + T(db.last_req.status="200"); + db.deleteDb(); + +} diff --git a/test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js b/test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js new file mode 100644 index 0000000000..41502ca5e0 --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/doc_crud_overridden_quorum.js @@ -0,0 +1,31 @@ +// 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.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; + + 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"); + + doc = db.open("0"); + db.deleteDoc(doc); + T(db.last_req.status="202","Should return 202 status"); + + 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 0000000000..57563439a5 --- /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 0000000000..d05fcaffa0 --- /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 0000000000..906391ae1a --- /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 0000000000..434578f3a1 --- /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% rename from test/javascript/tests-cluster/without-quorum/db-creation.js rename to test/javascript/tests-cluster/without-quorum/db_creation.js diff --git a/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js new file mode 100644 index 0000000000..6d5d798d17 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/db_creation_overridden_quorum.js @@ -0,0 +1,30 @@ +// 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. + +// 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"},{"w":1}); + + // DB Creation should return 201 - Created + xhr = CouchDB.request("PUT", "/" + db_name + "/"); + 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_deletion.js b/test/javascript/tests-cluster/without-quorum/db_deletion.js new file mode 100644 index 0000000000..04b15c0589 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/db_deletion.js @@ -0,0 +1,28 @@ +// 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. + +// 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.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_deletion_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js new file mode 100644 index 0000000000..4a1efce23b --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js @@ -0,0 +1,29 @@ +// 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. + +// 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"},{"w":1}); + db.createDb(); + + + //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/doc_bulk.js b/test/javascript/tests-cluster/without-quorum/doc_bulk.js new file mode 100644 index 0000000000..91578d88a4 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_bulk.js @@ -0,0 +1,28 @@ +// 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.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; + + 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/doc_bulk_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/doc_bulk_overridden_quorum.js new file mode 100644 index 0000000000..56fb11e59c --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_bulk_overridden_quorum.js @@ -0,0 +1,28 @@ +// 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.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 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/doc_copy.js b/test/javascript/tests-cluster/without-quorum/doc_copy.js new file mode 100644 index 0000000000..7d7c35fccb --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_copy.js @@ -0,0 +1,30 @@ +// 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.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; + + db.save({_id:"dummy"}); + + 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/doc_copy_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js new file mode 100644 index 0000000000..e72425d86e --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_copy_overridden_quorum.js @@ -0,0 +1,33 @@ +// 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.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; + + db.save({_id:"dummy"}); + + 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/doc_crud.js b/test/javascript/tests-cluster/without-quorum/doc_crud.js new file mode 100644 index 0000000000..aa706976b3 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_crud.js @@ -0,0 +1,35 @@ +// 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.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; + + 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"); + + 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/doc_crud_overridden_quorum.js b/test/javascript/tests-cluster/without-quorum/doc_crud_overridden_quorum.js new file mode 100644 index 0000000000..44ab86ec05 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/doc_crud_overridden_quorum.js @@ -0,0 +1,34 @@ +// 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.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; + + 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"); + + 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 + "/"); +} ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
