janl closed pull request #1139: Fix for issue #1136 - Error 500 deleting DB 
without quorum
URL: https://github.com/apache/couchdb/pull/1139
 
 
   

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/src/fabric/src/fabric_db_delete.erl 
b/src/fabric/src/fabric_db_delete.erl
index 9ba55fbb8e..c146cb6cd6 100644
--- a/src/fabric/src/fabric_db_delete.erl
+++ b/src/fabric/src/fabric_db_delete.erl
@@ -79,12 +79,12 @@ maybe_stop(W, Counters) ->
         case {Ok + NotFound, Ok, NotFound} of
         {W, 0, W} ->
             {#shard{dbname=Name}, _} = hd(Counters),
-            couch_log:warning("~p not_found ~s", [?MODULE, Name]),
+            couch_log:warning("~p not_found ~d", [?MODULE, Name]),
             {stop, not_found};
         {W, _, _} ->
             {stop, ok};
-        {N, M, _} when N >= (W div 2 + 1), M > 0 ->
-            {stop, accepted};
+        {_, M, _} when M > 0 ->
+            {stop,accepted};
         _ ->
             {error, internal_server_error}
         end
diff --git a/test/javascript/run b/test/javascript/run
index 8ae4244675..ca69e1ff2e 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
index bef4cae43d..079fb493d5 100644
--- a/test/javascript/tests-cluster/with-quorum/db_deletion.js
+++ b/test/javascript/tests-cluster/with-quorum/db_deletion.js
@@ -10,15 +10,21 @@
 // License for the specific language governing permissions and limitations 
under
 // the License.
 
-// Do DB deletion in a cluster with quorum conditions.
+// 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.deleteDb();
-  T(db.last_req.status="200","Should return 200");
+  // DB Deletion should return 202 - Acceted as the custer is not complete
+  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 0d8ff8367b..a21d37746e 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();
 };
diff --git a/test/javascript/tests-cluster/without-quorum/db_deletion.js 
b/test/javascript/tests-cluster/without-quorum/db_deletion.js
index 04b15c0589..006345e30b 100644
--- a/test/javascript/tests-cluster/without-quorum/db_deletion.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 deletion in a cluster with quorum conditions.
+// 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.deleteDb();
-  // 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(db.last_req.status="202","Should return 202");
-  console.log("Skipped-TODO: Fix issue 500 Error on delete. 202->"+xhr.status)
-
+  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_deletion_overridden_quorum.js 
b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
index 4a1efce23b..11b344cfb3 100644
--- 
a/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
+++ 
b/test/javascript/tests-cluster/without-quorum/db_deletion_overridden_quorum.js
@@ -19,11 +19,7 @@ couchTests.db_deletion_overridden_quorum = function(debug) {
   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.
+  // DB deletions does not consider overriden quorum param.
   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);
-
+  T(db.last_req.status="202","Should return 202");
 };


 

----------------------------------------------------------------
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

Reply via email to