2011-08-17 11:53:18 -04:00
|
|
|
// Tests bulk insert of docs from the shell
|
2018-04-06 10:33:03 -04:00
|
|
|
//
|
|
|
|
|
// @tags: [requires_fastcount]
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let coll = db.bulkInsertTest;
|
2016-02-04 12:29:01 -05:00
|
|
|
coll.drop();
|
2011-08-17 11:53:18 -04:00
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let 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
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let bulkSize = Math.floor(Random.rand() * 200) + 1;
|
|
|
|
|
let 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
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
for (let i = 0; i < numInserts; i++) {
|
|
|
|
|
let bulk = [];
|
|
|
|
|
for (let j = 0; j < bulkSize; j++) {
|
2016-03-09 12:17:50 -05:00
|
|
|
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);
|