diff options
author | jjrodrig <jjrodrig@gmail.com> | 2018-02-01 19:31:29 +0100 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2018-07-13 13:43:43 +0200 |
commit | 80e431f11a401f78651dd4f8f34326b2e5109557 (patch) | |
tree | df14a0c13fee227f04213ed8848213270f6a83f0 | |
parent | bfc610f3b9bbe087f4d00a570bb9cde3df78a35f (diff) | |
download | couchdb-80e431f11a401f78651dd4f8f34326b2e5109557.tar.gz |
Fix for issue #1136 - Error 500 deleting DB without quorum
Complete deletion tests with not found
-rw-r--r-- | src/fabric/src/fabric_db_delete.erl | 6 | ||||
-rwxr-xr-x | test/javascript/run | 8 | ||||
-rw-r--r-- | test/javascript/tests-cluster/with-quorum/db-deletion.js | 30 | ||||
-rw-r--r-- | test/javascript/tests-cluster/without-quorum/db-deletion.js | 30 | ||||
-rw-r--r-- | test/javascript/tests-cluster/without-quorum/db_creation.js | 3 |
5 files changed, 68 insertions, 9 deletions
diff --git a/src/fabric/src/fabric_db_delete.erl b/src/fabric/src/fabric_db_delete.erl index 9ba55fbb8..a1b51088b 100644 --- a/src/fabric/src/fabric_db_delete.erl +++ b/src/fabric/src/fabric_db_delete.erl @@ -81,10 +81,10 @@ maybe_stop(W, Counters) -> {#shard{dbname=Name}, _} = hd(Counters), couch_log:warning("~p not_found ~s", [?MODULE, Name]), {stop, not_found}; - {W, _, _} -> - {stop, ok}; {N, M, _} when N >= (W div 2 + 1), M > 0 -> - {stop, accepted}; + {stop, ok}; + {_, M, _} when M > 0 -> + {stop,accepted}; _ -> {error, internal_server_error} end diff --git a/test/javascript/run b/test/javascript/run index 8ae424467..ca69e1ff2 100755 --- a/test/javascript/run +++ b/test/javascript/run @@ -134,10 +134,11 @@ def main(): tmp.append(name) tests = tmp - fmt = mkformatter(tests) passed = 0 failed = 0 - for test in tests: + if len(tests) > 0 : + fmt = mkformatter(tests) + for test in tests: result = run_couchjs(test, fmt) if result == 0: passed += 1 @@ -169,8 +170,7 @@ def build_test_case_paths(path,args=None): elif os.path.isfile(pname + ".js"): tests.append(pname + ".js") else: - sys.stderr.write("Unknown test: " + name + os.linesep) - exit(1) + sys.stderr.write("Waring - Unknown test: " + name + os.linesep) return tests 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 000000000..f561e3a0c --- /dev/null +++ b/test/javascript/tests-cluster/with-quorum/db-deletion.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 deletion under 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 Deletion should return 200 - Ok + xhr = CouchDB.request("DELETE", "/" + db_name + "/"); + T(xhr.status == 200); + +// DB Deletion should return 404 - Not found + xhr = CouchDB.request("DELETE", "/not-existing-db/"); + T(xhr.status == 404); +}; 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 000000000..006345e30 --- /dev/null +++ b/test/javascript/tests-cluster/without-quorum/db-deletion.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. +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 Deletion should return 202 - Acepted + xhr = CouchDB.request("DELETE", "/" + db_name + "/"); + T(xhr.status == 202); + + // DB Deletion should return 404 - Not found + xhr = CouchDB.request("DELETE", "/not-existing-db/"); + T(xhr.status == 404); +}; diff --git a/test/javascript/tests-cluster/without-quorum/db_creation.js b/test/javascript/tests-cluster/without-quorum/db_creation.js index 0d8ff8367..a21d37746 100644 --- a/test/javascript/tests-cluster/without-quorum/db_creation.js +++ b/test/javascript/tests-cluster/without-quorum/db_creation.js @@ -23,6 +23,5 @@ couchTests.db_creation = function(debug) { T(xhr.status == 202); // cleanup - // TODO DB deletions fails if the quorum is not met. - xhr = CouchDB.request("DELETE", "/" + db_name + "/"); + db.deleteDb(); }; |