summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2011-01-18 00:44:51 +0000
committerAdam Kocoloski <kocolosk@apache.org>2011-01-18 00:44:51 +0000
commit409455a31b976020cba49c6ce8d413eca0480dea (patch)
tree8afcdcf036cb6c4d5387d6b147274ee2e3f71c89 /share/www/script
parent84052a85cd93d07a324b3e77c97f2a9552b05f93 (diff)
Avoid bug in rev tree logic during attachment uploads
This is a workaround for a bug in couch_key_tree, described in COUCHDB-902, which would cause uploads to fail with spurious conflicts. A patch for the key tree itself will be landing on trunk. Thanks Bob Dionne, Klaus Trainer. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1060150 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/couch_tests.js1
-rw-r--r--share/www/script/test/attachment_conflicts.js56
2 files changed, 57 insertions, 0 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 0b8f9288..eb573526 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -34,6 +34,7 @@ loadTest("basics.js");
loadTest("all_docs.js");
loadTest("attachments.js");
loadTest("attachments_multipart.js");
+loadTest("attachment_conflicts.js");
loadTest("attachment_names.js");
loadTest("attachment_paths.js");
loadTest("attachment_ranges.js");
diff --git a/share/www/script/test/attachment_conflicts.js b/share/www/script/test/attachment_conflicts.js
new file mode 100644
index 00000000..c400277e
--- /dev/null
+++ b/share/www/script/test/attachment_conflicts.js
@@ -0,0 +1,56 @@
+// 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 some edit conflict detection tests for attachments.
+couchTests.attachment_conflicts = function(debug) {
+
+ var dbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
+ var dbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"});
+ dbA.deleteDb();
+ dbA.createDb();
+ dbB.deleteDb();
+ dbB.createDb();
+
+ if (debug) debugger;
+
+ T(dbA.save({"_id":"doc", "foo":"bar"}).ok);
+
+ // create conflict
+ T(CouchDB.replicate("test_suite_db_a", "test_suite_db_b").ok);
+
+ var doc = dbA.open("doc");
+ var rev11 = doc._rev;
+ T(dbA.save({"_id":"doc", "foo":"bar2","_rev":rev11}).ok);
+
+ doc = dbB.open("doc");
+ var rev12 = doc._rev;
+ T(dbB.save({"_id":"doc", "foo":"bar3","_rev":rev12}).ok);
+
+ T(CouchDB.replicate("test_suite_db_a", "test_suite_db_b").ok);
+
+ // the attachment
+ var bin_data = "JHAPDO*AU£PN ){(3u[d 93DQ9¡€])} ææøo'∂ƒæ≤çæππ•¥∫¶®#†π¶®¥π€ª®˙π8np";
+
+ doc = dbB.open("doc");
+ var rev13 = doc._rev;
+
+ // test that we can can attach to conflicting documents
+ var xhr = CouchDB.request("PUT", "/test_suite_db_b/doc/attachment.txt", {
+ headers: {
+ "Content-Type": "text/plain;charset=utf-8",
+ "If-Match": rev13
+ },
+ body: bin_data
+ });
+ T(xhr.status == 201);
+
+};