diff options
author | Benety Goh <benety@mongodb.com> | 2016-01-05 12:01:04 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-01-07 12:21:53 -0500 |
commit | c5d5cd03e0e14df045ed7d480041c663419ad848 (patch) | |
tree | b358fa3e4eaa5258667a83333c8d0a91bf721cfb /jstests | |
parent | 84daeccc1e848f7ca2c5de2c8652a5e2c4a473cd (diff) | |
download | mongo-c5d5cd03e0e14df045ed7d480041c663419ad848.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 8c40639266d..f4c78def974 100644 --- a/jstests/core/apply_ops1.js +++ b/jstests/core/apply_ops1.js @@ -150,4 +150,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)); })(); |