diff options
author | Geert Bosch <geert@mongodb.com> | 2019-03-06 10:08:48 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2019-03-06 10:19:43 -0500 |
commit | 260b3f451b95cab5f1e59be2d5f50a1cb78f2e5b (patch) | |
tree | d958667692b2eb8138a37cbadce921c15e2cb300 /jstests/noPassthroughWithMongod | |
parent | d926100d60c59baae6d777cde7bc2f231c8ec1af (diff) | |
download | mongo-260b3f451b95cab5f1e59be2d5f50a1cb78f2e5b.tar.gz |
SERVER-39983 Speed up dup_bgindex.js
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/dup_bgindex.js | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/jstests/noPassthroughWithMongod/dup_bgindex.js b/jstests/noPassthroughWithMongod/dup_bgindex.js index cd0078248bb..298f585d543 100644 --- a/jstests/noPassthroughWithMongod/dup_bgindex.js +++ b/jstests/noPassthroughWithMongod/dup_bgindex.js @@ -1,16 +1,19 @@ // Try to create two identical indexes, via background. Shouldn't be allowed by the server. -// This test runs fairly quickly but cannot be in /jstests/. So it lives in slowNightly for now. -var t = db.duplIndexTest; -t.drop(); -for (var i = 0; i < 10000; i++) { - t.insert({name: "foo", z: {a: 17, b: 4}, i: i}); -} -var cmd = "db.duplIndexTest.ensureIndex( { i : 1 }, {background:true} );"; -var join1 = startParallelShell(cmd); -var join2 = startParallelShell(cmd); -t.ensureIndex({i: 1}, {background: true}); -assert.eq(1, t.find({i: 1}).count(), "Should find only one doc"); -t.dropIndex({i: 1}); -assert.eq(1, t.find({i: 1}).count(), "Should find only one doc"); -join1(); -join2(); +(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.ensureIndex( { i : 1 }, {background:true} ));"; + var join1 = startParallelShell(cmd); + var join2 = startParallelShell(cmd); + assert.commandWorked(t.ensureIndex({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(); +})(); |