summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/index_multi.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthroughWithMongod/index_multi.js')
-rw-r--r--jstests/noPassthroughWithMongod/index_multi.js100
1 files changed, 45 insertions, 55 deletions
diff --git a/jstests/noPassthroughWithMongod/index_multi.js b/jstests/noPassthroughWithMongod/index_multi.js
index ec162821d4b..8d728fac8d9 100644
--- a/jstests/noPassthroughWithMongod/index_multi.js
+++ b/jstests/noPassthroughWithMongod/index_multi.js
@@ -9,19 +9,20 @@ db.results.drop();
var bulk = coll.initializeUnorderedBulkOp();
print("Populate the collection with random data");
for (var i = 0; i < 1e4; i++) {
- var doc = {"_id" : i};
+ var doc = {
+ "_id": i
+ };
- for (var j=0; j<100; j++) {
+ for (var j = 0; j < 100; j++) {
// Skip some of the fields
if (Random.rand() < .1) {
continue;
}
// Make 0, 10, etc. multikey indexes
else if (j % 10 == 0) {
- doc["field"+j] = [Random.rand(), Random.rand(), Random.rand()];
- }
- else {
- doc["field"+j] = Random.rand();
+ doc["field" + j] = [Random.rand(), Random.rand(), Random.rand()];
+ } else {
+ doc["field" + j] = Random.rand();
}
}
@@ -33,66 +34,54 @@ assert.writeOK(bulk.execute());
var specs = [];
var multikey = [];
-var setupDBStr =
- "var conn = null;" +
- "assert.soon(function() {" +
- " try {" +
- " conn = new Mongo(\"" + db.getMongo().host + "\");" +
- " return conn;" +
- " } catch (x) {" +
- " return false;" +
- " }" +
- "}, 'Timed out waiting for temporary connection to connect', 30000, 5000);" +
- "var db = conn.getDB('" + db.getName() + "');";
+var setupDBStr = "var conn = null;" + "assert.soon(function() {" + " try {" +
+ " conn = new Mongo(\"" + db.getMongo().host + "\");" + " return conn;" +
+ " } catch (x) {" + " return false;" + " }" +
+ "}, 'Timed out waiting for temporary connection to connect', 30000, 5000);" +
+ "var db = conn.getDB('" + db.getName() + "');";
var indexJobs = [];
print("Create 3 triple indexes");
for (var i = 90; i < 93; i++) {
var spec = {};
- spec["field"+i] = 1;
- spec["field"+(i+1)] = 1;
- spec["field"+(i+2)] = 1;
- indexJobs.push(startParallelShell(setupDBStr +
- "printjson(db.index_multi.createIndex(" + tojson(spec) + "," +
- "{ background: true }));" +
- "db.results.insert(Object.extend(" +
- "db.runCommand({ getlasterror: 1 }), " + tojson(spec) +
- ") );",
- null, // port
- true)); // noconnect
+ spec["field" + i] = 1;
+ spec["field" + (i + 1)] = 1;
+ spec["field" + (i + 2)] = 1;
+ indexJobs.push(startParallelShell(
+ setupDBStr + "printjson(db.index_multi.createIndex(" + tojson(spec) + "," +
+ "{ background: true }));" + "db.results.insert(Object.extend(" +
+ "db.runCommand({ getlasterror: 1 }), " + tojson(spec) + ") );",
+ null, // port
+ true)); // noconnect
specs.push(spec);
- multikey.push(i % 10 == 0 || (i+1) % 10 == 0 || (i+2) % 10 == 0);
+ multikey.push(i % 10 == 0 || (i + 1) % 10 == 0 || (i + 2) % 10 == 0);
}
print("Create 30 compound indexes");
for (var i = 30; i < 90; i += 2) {
var spec = {};
- spec["field"+i] = 1;
- spec["field"+(i+1)] = 1;
- indexJobs.push(startParallelShell(setupDBStr +
- "printjson(db.index_multi.createIndex(" + tojson(spec) + ", " +
- "{ background: true }));" +
- "db.results.insert(Object.extend(" +
- "db.runCommand({ getlasterror: 1 }), " + tojson(spec) +
- ") );",
- null, // port
- true)); // noconnect
+ spec["field" + i] = 1;
+ spec["field" + (i + 1)] = 1;
+ indexJobs.push(startParallelShell(
+ setupDBStr + "printjson(db.index_multi.createIndex(" + tojson(spec) + ", " +
+ "{ background: true }));" + "db.results.insert(Object.extend(" +
+ "db.runCommand({ getlasterror: 1 }), " + tojson(spec) + ") );",
+ null, // port
+ true)); // noconnect
specs.push(spec);
- multikey.push(i % 10 == 0 || (i+1) % 10 == 0);
+ multikey.push(i % 10 == 0 || (i + 1) % 10 == 0);
}
print("Create 30 indexes");
for (var i = 0; i < 30; i++) {
var spec = {};
- spec["field"+i] = 1;
- indexJobs.push(startParallelShell(setupDBStr +
- "printjson(db.index_multi.createIndex(" + tojson(spec) + ", " +
- "{ background: true }));" +
- "db.results.insert(Object.extend(" +
- "db.runCommand({ getlasterror: 1 }), " + tojson(spec) +
- ") );",
- null, // port
- true)); // noconnect
+ spec["field" + i] = 1;
+ indexJobs.push(startParallelShell(
+ setupDBStr + "printjson(db.index_multi.createIndex(" + tojson(spec) + ", " +
+ "{ background: true }));" + "db.results.insert(Object.extend(" +
+ "db.runCommand({ getlasterror: 1 }), " + tojson(spec) + ") );",
+ null, // port
+ true)); // noconnect
specs.push(spec);
multikey.push(i % 10 == 0);
}
@@ -100,15 +89,16 @@ for (var i = 0; i < 30; i++) {
print("Do some sets and unsets");
bulk = coll.initializeUnorderedBulkOp();
for (i = 0; i < 1e4; i++) {
- var criteria = {_id: Random.randInt(1e5)};
+ var criteria = {
+ _id: Random.randInt(1e5)
+ };
var mod = {};
if (Random.rand() < .5) {
mod['$set'] = {};
- mod['$set']['field'+Random.randInt(100)] = Random.rand();
- }
- else {
+ mod['$set']['field' + Random.randInt(100)] = Random.rand();
+ } else {
mod['$unset'] = {};
- mod['$unset']['field'+Random.randInt(100)] = true;
+ mod['$unset']['field' + Random.randInt(100)] = true;
}
bulk.find(criteria).update(mod);
@@ -120,7 +110,7 @@ indexJobs.forEach(function(join) {
});
printjson(db.results.find().toArray());
-//assert.eq(coll.getIndexes().length, 64, "didn't see 64 indexes");
+// assert.eq(coll.getIndexes().length, 64, "didn't see 64 indexes");
print("Make sure we end up with 64 indexes");
for (var i in specs) {