diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/rpc_protocols.js')
-rw-r--r-- | jstests/noPassthroughWithMongod/rpc_protocols.js | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/jstests/noPassthroughWithMongod/rpc_protocols.js b/jstests/noPassthroughWithMongod/rpc_protocols.js index ef847e2a359..95e028526c0 100644 --- a/jstests/noPassthroughWithMongod/rpc_protocols.js +++ b/jstests/noPassthroughWithMongod/rpc_protocols.js @@ -8,65 +8,66 @@ var RPC_PROTOCOLS = {OP_QUERY: "opQueryOnly", OP_MSG: "opMsgOnly"}; (function() { - "use strict"; +"use strict"; - db.rpcProtocols.drop(); +db.rpcProtocols.drop(); - var oldProfilingLevel = db.getProfilingLevel(); +var oldProfilingLevel = db.getProfilingLevel(); - assert.commandWorked(db.setProfilingLevel(2)); +assert.commandWorked(db.setProfilingLevel(2)); - function runInShell(rpcProtocol, func) { - assert(0 == _runMongoProgram("mongo", - "--rpcProtocols=" + rpcProtocol, - "--readMode=commands", // ensure we use the find command. - "--eval", - "(" + func.toString() + ")();", - db.getMongo().host)); - } +function runInShell(rpcProtocol, func) { + assert(0 == + _runMongoProgram("mongo", + "--rpcProtocols=" + rpcProtocol, + "--readMode=commands", // ensure we use the find command. + "--eval", + "(" + func.toString() + ")();", + db.getMongo().host)); +} - // Test that --rpcProtocols=opQueryOnly forces OP_QUERY commands. - runInShell(RPC_PROTOCOLS.OP_QUERY, function() { - assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); - db.getSiblingDB("test").rpcProtocols.find().comment("opQueryCommandLine").itcount(); - }); - var profileDoc = db.system.profile.findOne({"command.comment": "opQueryCommandLine"}); - assert(profileDoc !== null); - assert.eq(profileDoc.protocol, "op_query"); +// Test that --rpcProtocols=opQueryOnly forces OP_QUERY commands. +runInShell(RPC_PROTOCOLS.OP_QUERY, function() { + assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); + db.getSiblingDB("test").rpcProtocols.find().comment("opQueryCommandLine").itcount(); +}); +var profileDoc = db.system.profile.findOne({"command.comment": "opQueryCommandLine"}); +assert(profileDoc !== null); +assert.eq(profileDoc.protocol, "op_query"); - // Test that --rpcProtocols=opMsgOnly forces OP_MSG commands. - runInShell(RPC_PROTOCOLS.OP_MSG, function() { - assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); - db.getSiblingDB("test").rpcProtocols.find().comment("opMsgCommandLine").itcount(); - }); - profileDoc = db.system.profile.findOne({"command.comment": "opMsgCommandLine"}); - assert(profileDoc !== null); - assert.eq(profileDoc.protocol, "op_msg"); +// Test that --rpcProtocols=opMsgOnly forces OP_MSG commands. +runInShell(RPC_PROTOCOLS.OP_MSG, function() { + assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); + db.getSiblingDB("test").rpcProtocols.find().comment("opMsgCommandLine").itcount(); +}); +profileDoc = db.system.profile.findOne({"command.comment": "opMsgCommandLine"}); +assert(profileDoc !== null); +assert.eq(profileDoc.protocol, "op_msg"); - // Test that .setClientRPCProtocols("opQueryOnly") forces OP_QUERY commands. We start the shell - // in OP_MSG only mode, then switch it to OP_QUERY mode at runtime. - runInShell(RPC_PROTOCOLS.OP_MSG, function() { - assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); - db.getMongo().setClientRPCProtocols("opQueryOnly"); - assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); - db.getSiblingDB("test").rpcProtocols.find().comment("opQueryRuntime").itcount(); - }); - profileDoc = db.system.profile.findOne({"command.comment": "opQueryRuntime"}); - assert(profileDoc !== null); - assert.eq(profileDoc.protocol, "op_query"); +// Test that .setClientRPCProtocols("opQueryOnly") forces OP_QUERY commands. We start the shell +// in OP_MSG only mode, then switch it to OP_QUERY mode at runtime. +runInShell(RPC_PROTOCOLS.OP_MSG, function() { + assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); + db.getMongo().setClientRPCProtocols("opQueryOnly"); + assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); + db.getSiblingDB("test").rpcProtocols.find().comment("opQueryRuntime").itcount(); +}); +profileDoc = db.system.profile.findOne({"command.comment": "opQueryRuntime"}); +assert(profileDoc !== null); +assert.eq(profileDoc.protocol, "op_query"); - // Test that .setClientRPCProtocols("opMsgOnly") forces OP_MSG commands. We start the - // shell in OP_QUERY only mode, then switch it to OP_MSG mode at runtime. - runInShell(RPC_PROTOCOLS.OP_QUERY, function() { - assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); - db.getMongo().setClientRPCProtocols("opMsgOnly"); - assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); - db.getSiblingDB("test").rpcProtocols.find().comment("opMsgRuntime").itcount(); - }); - profileDoc = db.system.profile.findOne({"command.comment": "opMsgRuntime"}); - assert(profileDoc !== null); - assert.eq(profileDoc.protocol, "op_msg"); +// Test that .setClientRPCProtocols("opMsgOnly") forces OP_MSG commands. We start the +// shell in OP_QUERY only mode, then switch it to OP_MSG mode at runtime. +runInShell(RPC_PROTOCOLS.OP_QUERY, function() { + assert(db.getMongo().getClientRPCProtocols() === "opQueryOnly"); + db.getMongo().setClientRPCProtocols("opMsgOnly"); + assert(db.getMongo().getClientRPCProtocols() === "opMsgOnly"); + db.getSiblingDB("test").rpcProtocols.find().comment("opMsgRuntime").itcount(); +}); +profileDoc = db.system.profile.findOne({"command.comment": "opMsgRuntime"}); +assert(profileDoc !== null); +assert.eq(profileDoc.protocol, "op_msg"); - // Reset profiling level. - assert.commandWorked(db.setProfilingLevel(oldProfilingLevel)); +// Reset profiling level. +assert.commandWorked(db.setProfilingLevel(oldProfilingLevel)); })(); |