blob: 5eeea743c6cc5c9b8f65d526cc1ece9a819c69cb (
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
|
var db;
(function() {
"use strict";
const conn = MongoRunner.runMongod();
assert.neq(null, conn, "mongod failed to start.");
db = conn.getDB("test");
const t = db.foo;
t.drop();
const N = 10000;
var bulk = t.initializeUnorderedBulkOp();
for (let i = 0; i < N; i++) {
bulk.insert({_id: i, x: 1});
}
assert.commandWorked(bulk.execute());
const join = startParallelShell(
"while( db.foo.findOne( { _id : 0 } ).x == 1 ); db.foo.createIndex( { x : 1 } );");
assert.commandWorked(t.update({
$where: function() {
sleep(1);
return true;
}
},
{$set: {x: 5}},
false,
true));
join();
assert.eq(N, t.find({x: 5}).count());
MongoRunner.stopMongod(conn);
})();
|