diff options
author | Benety Goh <benety@mongodb.com> | 2016-01-05 12:01:04 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-01-07 15:11:47 -0500 |
commit | e47291432ae065ff8103e8e598fa6402e4352245 (patch) | |
tree | 0558f9f39bcc2a87b81f1dd2032a3abbdb34b9f7 /jstests | |
parent | 95933f3bc721ccbcfda98e12ef85f21801add565 (diff) | |
download | mongo-e47291432ae065ff8103e8e598fa6402e4352245.tar.gz |
SERVER-21583 added applyOps test case for creating foreground and background indexes
(cherry picked from commit 4ed0efa3368a89cb808c62b2d9e916acf8202ff7)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/apply_ops1.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/core/apply_ops1.js b/jstests/core/apply_ops1.js index bc34b9e92bf..cd2b57216e8 100644 --- a/jstests/core/apply_ops1.js +++ b/jstests/core/apply_ops1.js @@ -122,4 +122,37 @@ assert.eq(true, res.results[0], "Valid update failed"); assert.eq(true, res.results[1], "Valid update failed"); + + // Foreground index build. + res = assert.commandWorked(db.adminCommand({ + applyOps: [{"op": "i", "ns": db.getName() + ".system.indexes", "o": { + ns: t.getFullName(), + key: {a: 1}, + name: "a_1", + } + }]})); + assert.eq(1, res.applied, "Incorrect number of operations applied"); + assert.eq(true, res.results[0], "Foreground index creation failed"); + res = t.getIndexes(); + assert.eq( + 1, + res.filter(function(element, index, array) {return element.name == 'a_1';}).length, + 'Foreground index not found in listIndexes result: ' + tojson(res)); + + // Background indexes are created in the foreground when processed by applyOps. + res = assert.commandWorked(db.adminCommand({ + applyOps: [{"op": "i", "ns": db.getName() + ".system.indexes", "o": { + ns: t.getFullName(), + key: {b: 1}, + name: "b_1", + background: true, + } + }]})); + assert.eq(1, res.applied, "Incorrect number of operations applied"); + assert.eq(true, res.results[0], "Background index creation failed"); + res = t.getIndexes(); + assert.eq( + 1, + res.filter(function(element, index, array) {return element.name == 'b_1';}).length, + 'Background index not found in listIndexes result: ' + tojson(res)); })(); |