summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorMartin Bligh <mbligh@mongodb.com>2015-09-11 08:49:27 -0400
committerMartin Bligh <mbligh@mongodb.com>2015-09-11 08:49:27 -0400
commitae0ca8279cf4899a2d2c1e81311e9709a10ff1df (patch)
tree10cc35adfc66433e6d6140d068d782e0ef5ef1a8 /jstests/noPassthroughWithMongod
parent58c7ad85c90619d4fa0e7e4df3b9f4d643b9b73b (diff)
downloadmongo-ae0ca8279cf4899a2d2c1e81311e9709a10ff1df.tar.gz
SERVER-19564: Use write vectors for the "non-command" path of insertMulti
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/insertMulti.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/insertMulti.js b/jstests/noPassthroughWithMongod/insertMulti.js
new file mode 100644
index 00000000000..b857e8c159a
--- /dev/null
+++ b/jstests/noPassthroughWithMongod/insertMulti.js
@@ -0,0 +1,50 @@
+// check the insertMulti path works, including the error handling
+
+(function() {
+ "use strict";
+
+ function makeDocument(docSize) {
+ var doc = { "fieldName":"" };
+ var longString = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+ while(Object.bsonsize(doc) < docSize) {
+ if (Object.bsonsize(doc) < docSize - longString.length) {
+ doc.fieldName += longString;
+ } else {
+ doc.fieldName += "x";
+ }
+ }
+ return doc;
+ }
+
+ db.getMongo().forceWriteMode('legacy');
+ var t = db.foo;
+
+ t.drop();
+ t.insert([{_id:1},{_id:2}]);
+ assert.eq(t.count(), 2);
+ t.insert([{_id:3},{_id:2},{_id:4}], 0); // no ContinueOnError
+ assert.eq(t.count(), 3);
+ assert.eq(t.count({ "_id" : 1 }), 1);
+ assert.eq(t.count({ "_id" : 2 }), 1);
+ assert.eq(t.count({ "_id" : 3 }), 1);
+ assert.eq(t.count({ "_id" : 4 }), 0);
+
+ t.drop();
+ t.insert([{_id:1},{_id:2}]);
+ assert.eq(t.count(), 2);
+ t.insert([{_id:3},{_id:2},{_id:4}], 1); // ContinueOnError
+ assert.eq(t.count(), 4);
+ assert.eq(t.count({ "_id" : 1 }), 1);
+ assert.eq(t.count({ "_id" : 2 }), 1);
+ assert.eq(t.count({ "_id" : 3 }), 1);
+ assert.eq(t.count({ "_id" : 4 }), 1);
+
+ // Push a large vector in bigger than the subset size we'll break it up into
+ t.drop();
+ var doc = makeDocument(16 * 1024);
+ var docs = [];
+ for (var i = 0; i < 1500; i++)
+ docs.push(Object.extend({}, doc));
+ t.insert(docs);
+ assert.eq(t.count(), docs.length);
+})();