diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/testing_only_commands.js')
| -rw-r--r-- | jstests/noPassthroughWithMongod/testing_only_commands.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/jstests/noPassthroughWithMongod/testing_only_commands.js b/jstests/noPassthroughWithMongod/testing_only_commands.js index 329be92da7e..07121f76770 100644 --- a/jstests/noPassthroughWithMongod/testing_only_commands.js +++ b/jstests/noPassthroughWithMongod/testing_only_commands.js @@ -1,6 +1,6 @@ /** - * Test to make sure that commands that should only work when testing commands are enabled - * via the --enableTestCommands flag fail when that flag isn't provided. + * Test to make sure that commands and agg stages that should only work when testing commands are + * enabled via the --enableTestCommands flag fail when that flag isn't provided. */ var testOnlyCommands = [ @@ -30,12 +30,29 @@ var assertCmdFound = function(db, cmdName) { } }; +const isBoundedSortEnabled = function(conn) { + const db = conn.getDB('TestDB'); + const coll = db.bounded_sort_coll; + coll.drop(); + assert.commandWorked(db.createCollection(coll.getName())); + + const pipeline = [{$_internalBoundedSort: {sortKey: {t: 1}, bound: {base: "min"}}}]; + const result = db.runCommand({aggregate: coll.getName(), pipeline: pipeline, cursor: {}}); + if (result.ok) { + return true; + } + // Otherwise it should be disabled with error code 5491300. + assert.eq(result.code, 5491300); + return false; +}; + TestData.enableTestCommands = false; var conn = MongoRunner.runMongod({}); for (i in testOnlyCommands) { assertCmdNotFound(conn.getDB('test'), testOnlyCommands[i]); } +assert.eq(isBoundedSortEnabled(conn), false); MongoRunner.stopMongod(conn); // Now enable the commands @@ -45,4 +62,5 @@ var conn = MongoRunner.runMongod({}); for (i in testOnlyCommands) { assertCmdFound(conn.getDB('test'), testOnlyCommands[i]); } +assert.eq(isBoundedSortEnabled(conn), true); MongoRunner.stopMongod(conn); |
