summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2009-11-03 20:51:04 +0000
committerDamien F. Katz <damien@apache.org>2009-11-03 20:51:04 +0000
commit4387dc1a5b10c63a540cefcb2bb7c6e5d9b9fd8b (patch)
treed14597954d2065ef880c97998631d0842f19224f /share
parentf2689f944e1c0f573afe4393ff26bbc988db8baf (diff)
Added batching of multiple updating requests, to improve throughput with many writers. Also removed the couch_batch_save module, now batch requests are simply saved async as immediately, batching with outhr updates if possible.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@832550 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/test/batch_save.js61
1 files changed, 23 insertions, 38 deletions
diff --git a/share/www/script/test/batch_save.js b/share/www/script/test/batch_save.js
index e321b108..1c8a2be9 100644
--- a/share/www/script/test/batch_save.js
+++ b/share/www/script/test/batch_save.js
@@ -16,45 +16,30 @@ couchTests.batch_save = function(debug) {
db.createDb();
if (debug) debugger;
- // commit should work fine with no batches
- T(db.ensureFullCommit().ok);
-
- // PUT a doc with ?batch=ok
- T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);
-
- // test that response is 202 Accepted
- T(db.last_req.status == 202);
-
- T(db.allDocs().total_rows == 0);
-
- restartServer();
-
- // lost the updates
- T(db.allDocs().total_rows == 0);
-
- T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);
- T(db.save({_id:"1",a:1,b:1}, {batch : "ok"}).ok);
- T(db.save({_id:"2",a:1,b:1}, {batch : "ok"}).ok);
-
- T(db.ensureFullCommit().ok);
- T(db.allDocs().total_rows == 3);
+ var i
+ for(i=0; i < 100; i++) {
+ T(db.save({_id:i.toString(),a:i,b:i}, {batch : "ok"}).ok);
+
+ // test that response is 202 Accepted
+ T(db.last_req.status == 202);
+ }
+
+ for(i=0; i < 100; i++) {
+ // attempt to save the same document a bunch of times
+ T(db.save({_id:"foo",a:i,b:i}, {batch : "ok"}).ok);
+
+ // test that response is 202 Accepted
+ T(db.last_req.status == 202);
+ }
+
+ while(db.allDocs().total_rows != 101){};
// repeat the tests for POST
- var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
- T(JSON.parse(resp.responseText).ok);
-
- // test that response is 202 Accepted
- T(resp.status == 202);
-
- T(db.allDocs().total_rows == 3);
- // restartServer();
- // // lost the POSTed doc
- // T(db.allDocs().total_rows == 3);
-
- var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
- T(JSON.parse(resp.responseText).ok);
-
- T(db.ensureFullCommit().ok);
- T(db.allDocs().total_rows == 5);
+ for(i=0; i < 100; i++) {
+ var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
+ T(JSON.parse(resp.responseText).ok);
+ }
+
+ while(db.allDocs().total_rows != 201){};
};