summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/dup_bgindex.js
blob: dd62117cf9f224685a4e7652cc4d3f1ce3b69730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Try to create two identical indexes, via background. Shouldn't be allowed by the server.
(function() {
var t = db.duplIndexTest;
t.drop();
docs = [];
for (var i = 0; i < 10000; i++) {
    docs.push({name: "foo", z: {a: 17, b: 4}, i: i});
}
assert.commandWorked(t.insert(docs));
var cmd = "assert.commandWorked(db.duplIndexTest.createIndex( { i : 1 }, {background:true} ));";
var join1 = startParallelShell(cmd);
var join2 = startParallelShell(cmd);
assert.commandWorked(t.createIndex({i: 1}, {background: true}));
assert.eq(1, t.find({i: 1}).count(), "Should find only one doc");
assert.commandWorked(t.dropIndex({i: 1}));
assert.eq(1, t.find({i: 1}).count(), "Should find only one doc");
join1();
join2();
})();