blob: 2832ea215d309c36a42160e1019bf5fafe1e405b (
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
41
42
43
|
'use strict';
/**
* distinct.js
*
* Runs distinct on an indexed field and verifies the result.
* The indexed field contains unique values.
* Each thread operates on a separate collection.
*/
var $config = (function() {
var data = {numDocs: 1000, prefix: 'distinct_fsm', shardKey: {i: 1}};
var states = (function() {
function init(db, collName) {
this.threadCollName = this.prefix + '_' + this.tid;
var bulk = db[this.threadCollName].initializeUnorderedBulkOp();
for (var i = 0; i < this.numDocs; ++i) {
bulk.insert({i: i});
}
var res = bulk.execute();
assertAlways.commandWorked(res);
assertAlways.eq(this.numDocs, res.nInserted);
assertAlways.commandWorked(db[this.threadCollName].ensureIndex({i: 1}));
}
function distinct(db, collName) {
assertWhenOwnColl.eq(this.numDocs, db[this.threadCollName].distinct('i').length);
}
return {init: init, distinct: distinct};
})();
var transitions = {init: {distinct: 1}, distinct: {distinct: 1}};
return {
data: data,
threadCount: 10,
iterations: 20,
states: states,
transitions: transitions,
};
})();
|