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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
'use strict';
/**
* remove_multiple_documents.js
*
* Each thread first inserts 200 documents, each containing the thread id and
* a random float. Then on each iteration, each thread repeatedly removes some
* of the documents it inserted.
*/
var $config = (function() {
var states = {
init: function init(db, collName) {
this.numDocs = 200;
for (var i = 0; i < this.numDocs; ++i) {
db[collName].insert({ tid: this.tid, rand: Random.rand() });
}
},
remove: function remove(db, collName) {
// choose a random interval to remove documents from
var low = Random.rand();
var high = low + 0.05 * Random.rand();
var res = db[collName].remove({
tid: this.tid,
rand: { $gte: low, $lte: high }
});
assertAlways.gte(res.nRemoved, 0);
assertAlways.lte(res.nRemoved, this.numDocs);
this.numDocs -= res.nRemoved;
},
count: function count(db, collName) {
var numDocs = db[collName].find({ tid: this.tid }).itcount();
assertWhenOwnColl.eq(this.numDocs, numDocs);
}
};
var transitions = {
init: { count: 1 },
count: { remove: 1 },
remove: {
remove: 0.825,
count: 0.125
}
};
return {
threadCount: 10,
iterations: 20,
states: states,
transitions: transitions
};
})();
|