2011-08-17 11:53:18 -04:00
|
|
|
// Tests bulk insert of docs from the shell
|
|
|
|
|
|
2016-02-04 12:29:01 -05:00
|
|
|
var coll = db.bulkInsertTest;
|
|
|
|
|
coll.drop();
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2014-03-14 15:21:49 -04:00
|
|
|
var seed = new Date().getTime();
|
2016-03-09 12:17:50 -05:00
|
|
|
Random.srand(seed);
|
2014-03-14 15:21:49 -04:00
|
|
|
print("Seed for randomized test is " + seed);
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
var bulkSize = Math.floor(Random.rand() * 200) + 1;
|
|
|
|
|
var numInserts = Math.floor(Random.rand() * 300) + 1;
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
print("Inserting " + numInserts + " bulks of " + bulkSize + " documents.");
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
for (var i = 0; i < numInserts; i++) {
|
2016-02-04 12:29:01 -05:00
|
|
|
var bulk = [];
|
2016-03-09 12:17:50 -05:00
|
|
|
for (var j = 0; j < bulkSize; j++) {
|
|
|
|
|
bulk.push({hi: "there", i: i, j: j});
|
2011-08-17 11:53:18 -04:00
|
|
|
}
|
2016-03-09 12:17:50 -05:00
|
|
|
|
|
|
|
|
coll.insert(bulk);
|
2011-08-17 11:53:18 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(coll.count(), bulkSize * numInserts);
|