blob: aa64e8d21e5ff42286a740d42ef49d7f126ecdd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
'use strict';
/**
* indexed_insert_unordered_bulk.js
*
* Inserts multiple documents into an indexed collection. Asserts that all
* documents appear in both a collection scan and an index scan.
*
* Uses an unordered, bulk operation to perform the inserts.
*/
load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload
load('jstests/concurrency/fsm_workloads/indexed_insert_base.js'); // for $config
var $config =
extendWorkload($config,
function($config, $super) {
$config.data.indexedField = 'indexed_insert_unordered_bulk';
$config.data.shardKey = {};
$config.data.shardKey[$config.data.indexedField] = 1;
$config.states.insert = function insert(db, collName) {
var doc = {};
doc[this.indexedField] = this.indexedValue;
var bulk = db[collName].initializeUnorderedBulkOp();
for (var i = 0; i < this.docsPerInsert; ++i) {
bulk.insert(doc);
}
var res = bulk.execute();
assertAlways.writeOK(res);
assertAlways.eq(this.docsPerInsert, res.nInserted, tojson(res));
this.nInserted += this.docsPerInsert;
};
$config.data.docsPerInsert = 15;
return $config;
});
|