blob: a6fe673a37622d82470499db5e3063e5d2454ed7 (
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
44
45
46
47
|
// background indexing test during inserts.
assert(db.getName() == "test");
t = db.bg1;
t.drop();
var a = new Mongo(db.getMongo().host).getDB(db.getName());
var bulk = t.initializeUnorderedBulkOp();
for (var i = 0; i < 100000; i++) {
bulk.insert({y: 'aaaaaaaaaaaa', i: i});
if (i % 10000 == 0) {
assert.commandWorked(bulk.execute());
bulk = t.initializeUnorderedBulkOp();
print(i);
}
}
// start bg indexing
a.bg1.createIndex({i: 1}, {name: "i_1", background: true});
// add more data
bulk = t.initializeUnorderedBulkOp();
for (var i = 0; i < 100000; i++) {
bulk.insert({i: i});
if (i % 10000 == 0) {
printjson(db.currentOp());
assert.commandWorked(bulk.execute());
bulk = t.initializeUnorderedBulkOp();
print(i);
}
}
assert.commandWorked(bulk.execute());
printjson(db.currentOp());
for (var i = 0; i < 40; i++) {
if (db.currentOp().inprog.length == 0)
break;
print("waiting");
sleep(1000);
}
var idx = t.getIndexes();
assert(idx[1].key.i == 1);
|