diff options
author | Arun Banala <arun.banala@10gen.com> | 2019-09-24 16:50:09 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-24 16:50:09 +0000 |
commit | 60518c8920064b30df53129ea880dacfcb04be71 (patch) | |
tree | aa9054360e25e2b3505dbced16bfb5922e606bb9 /jstests/noPassthrough/comment_field_passthrough.js | |
parent | 7edbbc86d4ac06fddd3ab3482d2985392811032b (diff) | |
download | mongo-60518c8920064b30df53129ea880dacfcb04be71.tar.gz |
SERVER-29794 Adding a comment to all commands
Diffstat (limited to 'jstests/noPassthrough/comment_field_passthrough.js')
-rw-r--r-- | jstests/noPassthrough/comment_field_passthrough.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/jstests/noPassthrough/comment_field_passthrough.js b/jstests/noPassthrough/comment_field_passthrough.js new file mode 100644 index 00000000000..de41d8a87f5 --- /dev/null +++ b/jstests/noPassthrough/comment_field_passthrough.js @@ -0,0 +1,61 @@ +/** + * Verify that adding 'comment' field to any command shouldn't cause unexpected failures. + */ +(function() { + +"use strict"; + +load("jstests/auth/lib/commands_lib.js"); // Provides an exhaustive list of commands. + +const tests = authCommandsLib.tests; + +// The following commands require additional start up configuration and hence need to be skipped. +const blacklistedTests = + ["startRecordingTraffic", "stopRecordingTraffic", "addShardToZone", "removeShardFromZone"]; + +function runTests(tests, conn, impls) { + const firstDb = conn.getDB(firstDbName); + const secondDb = conn.getDB(secondDbName); + const isMongos = authCommandsLib.isMongos(conn); + for (const test of tests) { + if (!blacklistedTests.includes(test.testname)) { + authCommandsLib.runOneTest(conn, test, impls, isMongos); + } + } +} + +const impls = { + runOneTest: function(conn, testObj) { + const testCase = testObj.testcases[0]; + + const runOnDb = conn.getDB(testCase.runOnDb); + const state = testObj.setup && testObj.setup(runOnDb); + + const command = (typeof (testObj.command) === "function") + ? testObj.command(state, testCase.commandArgs) + : testObj.command; + command['comment'] = "comment"; + const res = runOnDb.runCommand(command); + assert(res.ok == 1 || testCase.expectFail || res.code == ErrorCodes.CommandNotSupported, + tojson(res)); + + if (testObj.teardown) { + testObj.teardown(runOnDb, res); + } + } +}; + +let conn = MongoRunner.runMongod(); + +// Test with standalone mongod. +runTests(tests, conn, impls); + +MongoRunner.stopMongod(conn); + +conn = new ShardingTest({shards: 1, mongos: 2}); + +// Test with a sharded cluster. +runTests(tests, conn, impls); + +conn.stop(); +})(); |