1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/**
* Verify that adding 'comment' field to any command shouldn't cause unexpected failures.
* @tags: [
* requires_capped,
* requires_journaling,
* requires_persistence,
* requires_replication,
* requires_sharding,
* requires_wiredtiger,
* ]
*/
(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();
})();
|