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
commit 80e431f11a401f78651dd4f8f34326b2e5109557 Author: jjrodrig <[email protected]> AuthorDate: Thu Feb 1 19:31:29 2018 +0100 Fix for issue #1136 - Error 500 deleting DB without quorum Complete deletion tests with not found --- src/fabric/src/fabric_db_delete.erl | 6 +++--- test/javascript/run | 8 ++++---- .../db_creation.js => with-quorum/db-deletion.js} | 18 ++++++++++-------- .../without-quorum/{db_creation.js => db-deletion.js} | 18 ++++++++++-------- .../tests-cluster/without-quorum/db_creation.js | 3 +-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/fabric/src/fabric_db_delete.erl b/src/fabric/src/fabric_db_delete.erl index 9ba55fb..a1b5108 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 8ae4244..ca69e1f 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/without-quorum/db_creation.js b/test/javascript/tests-cluster/with-quorum/db-deletion.js similarity index 70% copy from test/javascript/tests-cluster/without-quorum/db_creation.js copy to test/javascript/tests-cluster/with-quorum/db-deletion.js index 0d8ff83..f561e3a 100644 --- a/test/javascript/tests-cluster/without-quorum/db_creation.js +++ b/test/javascript/tests-cluster/with-quorum/db-deletion.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) { +// 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 Creation should return 202- Accepted - xhr = CouchDB.request("PUT", "/" + db_name + "/"); - T(xhr.status == 202); - - // cleanup - // TODO DB deletions fails if the quorum is not met. + 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_creation.js b/test/javascript/tests-cluster/without-quorum/db-deletion.js similarity index 72% copy from test/javascript/tests-cluster/without-quorum/db_creation.js copy to test/javascript/tests-cluster/without-quorum/db-deletion.js index 0d8ff83..006345e 100644 --- a/test/javascript/tests-cluster/without-quorum/db_creation.js +++ b/test/javascript/tests-cluster/without-quorum/db-deletion.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) { +// 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 Creation should return 202- Accepted - xhr = CouchDB.request("PUT", "/" + db_name + "/"); - T(xhr.status == 202); - - // cleanup - // TODO DB deletions fails if the quorum is not met. + 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 0d8ff83..a21d377 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(); };
