diff options
author | Matt Kangas <matt.kangas@mongodb.com> | 2014-03-29 14:22:17 -0400 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-03-29 14:22:17 -0400 |
commit | 91a7d38a6beaf53aeb5390e64da7366db5b9d858 (patch) | |
tree | fa6574168c936e5e0cd46dc32af19352386ba8c8 /jstests/noPassthrough | |
parent | d75b92d849ebeb60fe8ba8ba43fd3bee114c9043 (diff) | |
download | mongo-91a7d38a6beaf53aeb5390e64da7366db5b9d858.tar.gz |
SERVER-13379 jstests that start servers can't live in core
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r-- | jstests/noPassthrough/logging_options.js | 127 | ||||
-rw-r--r-- | jstests/noPassthrough/network_options.js | 185 | ||||
-rw-r--r-- | jstests/noPassthrough/profile_options.js | 75 |
3 files changed, 387 insertions, 0 deletions
diff --git a/jstests/noPassthrough/logging_options.js b/jstests/noPassthrough/logging_options.js new file mode 100644 index 00000000000..b3d999a53a8 --- /dev/null +++ b/jstests/noPassthrough/logging_options.js @@ -0,0 +1,127 @@ +var baseName = "jstests_core_logging_options"; + +function removeOptionsAddedByFramework(getCmdLineOptsResult) { + // Remove options that we are not interested in checking, but that get set by the test + delete getCmdLineOptsResult.parsed.setParameter + delete getCmdLineOptsResult.parsed.storage + delete getCmdLineOptsResult.parsed.net + delete getCmdLineOptsResult.parsed.fastsync + delete getCmdLineOptsResult.parsed.security + return getCmdLineOptsResult; +} + +function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) { + + // Start mongod with options + var mongod = MongoRunner.runMongod(mongoRunnerConfig); + + // Get the parsed options + var getCmdLineOptsResult = mongod.adminCommand("getCmdLineOpts"); + printjson(getCmdLineOptsResult); + + // Remove options added by the test framework + getCmdLineOptsResult = removeOptionsAddedByFramework(getCmdLineOptsResult); + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + MongoRunner.stopMongod(mongod.port); +} + +// Verbosity testing +jsTest.log("Testing \"verbose\" command line option with no args"); +var expectedResult = { + "parsed" : { + "systemLog" : { + "verbosity" : 1 + } + } +}; +testGetCmdLineOpts({ verbose : "" }, expectedResult); + +jsTest.log("Testing \"verbose\" command line option with one \"v\""); +var expectedResult = { + "parsed" : { + "systemLog" : { + "verbosity" : 1 + } + } +}; +testGetCmdLineOpts({ verbose : "v" }, expectedResult); + +jsTest.log("Testing \"verbose\" command line option with two \"v\"s"); +var expectedResult = { + "parsed" : { + "systemLog" : { + "verbosity" : 2 + } + } +}; +testGetCmdLineOpts({ verbose : "vv" }, expectedResult); + +jsTest.log("Testing \"v\" command line option"); +var expectedResult = { + "parsed" : { + "systemLog" : { + "verbosity" : 1 + } + } +}; +// Currently the test converts "{ v : 1 }" to "-v" when it spawns the binary. +testGetCmdLineOpts({ v : 1 }, expectedResult); + +jsTest.log("Testing \"vv\" command line option"); +var expectedResult = { + "parsed" : { + "systemLog" : { + "verbosity" : 2 + } + } +}; +// Currently the test converts "{ v : 2 }" to "-vv" when it spawns the binary. +testGetCmdLineOpts({ v : 2 }, expectedResult); + +jsTest.log("Testing \"systemLog.verbosity\" config file option"); +expectedResult = { + "parsed" : { + "config" : "jstests/libs/config_files/set_verbosity.json", + "systemLog" : { + "verbosity" : 5 + } + } +}; +testGetCmdLineOpts({ config : "jstests/libs/config_files/set_verbosity.json" }, expectedResult); + + + +// Log output testing +var baseDir = MongoRunner.dataPath + baseName; +var logDir = MongoRunner.dataPath + baseName + "/logs/"; + +// ensure log directory exists +assert(mkdir(baseDir)); +assert(mkdir(logDir)); + +jsTest.log("Testing \"logpath\" command line option"); +var expectedResult = { + "parsed" : { + "systemLog" : { + "destination" : "file", + "path" : logDir + "/mylog.log" + } + } +}; +testGetCmdLineOpts({ logpath : logDir + "/mylog.log" }, expectedResult); + + + +jsTest.log("Testing with no explicit logging setting"); +expectedResult = { + "parsed" : { } +}; +testGetCmdLineOpts({}, expectedResult); + +resetDbpath(baseDir); + +print(baseName + " succeeded."); diff --git a/jstests/noPassthrough/network_options.js b/jstests/noPassthrough/network_options.js new file mode 100644 index 00000000000..6c192f3f68f --- /dev/null +++ b/jstests/noPassthrough/network_options.js @@ -0,0 +1,185 @@ +var baseName = "jstests_core_network_options"; + +function removeOptionsAddedByFramework(getCmdLineOptsResult) { + // Remove options that we are not interested in checking, but that get set by the test + delete getCmdLineOptsResult.parsed.setParameter + delete getCmdLineOptsResult.parsed.storage + delete getCmdLineOptsResult.parsed.net.port + delete getCmdLineOptsResult.parsed.fastsync + delete getCmdLineOptsResult.parsed.security + return getCmdLineOptsResult; +} + +function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) { + + // Start mongod with options + var mongod = MongoRunner.runMongod(mongoRunnerConfig); + + // Get the parsed options + var getCmdLineOptsResult = mongod.adminCommand("getCmdLineOpts"); + printjson(getCmdLineOptsResult); + + // Remove options added by the test framework + getCmdLineOptsResult = removeOptionsAddedByFramework(getCmdLineOptsResult); + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + MongoRunner.stopMongod(mongod.port); +} + +// Object Check +jsTest.log("Testing \"objcheck\" command line option"); +var expectedResult = { + "parsed" : { + "net" : { + "wireObjectCheck" : true + } + } +}; +testGetCmdLineOpts({ objcheck : "" }, expectedResult); + +jsTest.log("Testing \"noobjcheck\" command line option"); +expectedResult = { + "parsed" : { + "net" : { + "wireObjectCheck" : false + } + } +}; +testGetCmdLineOpts({ noobjcheck : "" }, expectedResult); + +jsTest.log("Testing \"net.wireObjectCheck\" config file option"); +expectedResult = { + "parsed" : { + "config" : "jstests/libs/config_files/enable_objcheck.json", + "net" : { + "wireObjectCheck" : true + } + } +}; +testGetCmdLineOpts({ config : "jstests/libs/config_files/enable_objcheck.json" }, expectedResult); + +jsTest.log("Testing with no explicit network option setting"); +expectedResult = { + "parsed" : { + "net" : { } + } +}; +testGetCmdLineOpts({}, expectedResult); + + + +// HTTP Interface +jsTest.log("Testing \"httpinterface\" command line option"); +var expectedResult = { + "parsed" : { + "net" : { + "http" : { + "enabled" : true + } + } + } +}; +testGetCmdLineOpts({ httpinterface : "" }, expectedResult); + +jsTest.log("Testing \"nohttpinterface\" command line option"); +expectedResult = { + "parsed" : { + "net" : { + "http" : { + "enabled" : false + } + } + } +}; +testGetCmdLineOpts({ nohttpinterface : "" }, expectedResult); + +jsTest.log("Testing implicit enabling of http interface with \"jsonp\" command line option"); +expectedResult = { + "parsed" : { + "net" : { + "http" : { + "JSONPEnabled" : true, + "enabled" : true + } + } + } +}; +testGetCmdLineOpts({ jsonp : "" }, expectedResult); + +jsTest.log("Testing implicit enabling of http interface with \"rest\" command line option"); +expectedResult = { + "parsed" : { + "net" : { + "http" : { + "RESTInterfaceEnabled" : true, + "enabled" : true + } + } + } +}; +testGetCmdLineOpts({ rest : "" }, expectedResult); + +jsTest.log("Testing \"net.http.enabled\" config file option"); +expectedResult = { + "parsed" : { + "config" : "jstests/libs/config_files/enable_httpinterface.json", + "net" : { + "http" : { + "enabled" : true + } + } + } +}; +testGetCmdLineOpts({ config : "jstests/libs/config_files/enable_httpinterface.json" }, expectedResult); + +jsTest.log("Testing with no explicit network option setting"); +expectedResult = { + "parsed" : { + "net" : { } + } +}; +testGetCmdLineOpts({}, expectedResult); + + + +// Unix Socket +if (!_isWindows()) { + jsTest.log("Testing \"nounixsocket\" command line option"); + expectedResult = { + "parsed" : { + "net" : { + "unixDomainSocket" : { + "enabled" : false + } + } + } + }; + testGetCmdLineOpts({ nounixsocket : "" }, expectedResult); + + jsTest.log("Testing \"net.wireObjectCheck\" config file option"); + expectedResult = { + "parsed" : { + "config" : "jstests/libs/config_files/enable_unixsocket.json", + "net" : { + "unixDomainSocket" : { + "enabled" : true + } + } + } + }; + testGetCmdLineOpts({ config : "jstests/libs/config_files/enable_unixsocket.json" }, + expectedResult); + + jsTest.log("Testing with no explicit network option setting"); + expectedResult = { + "parsed" : { + "net" : { } + } + }; + testGetCmdLineOpts({}, expectedResult); +} + +print(baseName + " succeeded."); diff --git a/jstests/noPassthrough/profile_options.js b/jstests/noPassthrough/profile_options.js new file mode 100644 index 00000000000..0ba4a5b40c3 --- /dev/null +++ b/jstests/noPassthrough/profile_options.js @@ -0,0 +1,75 @@ +var baseName = "jstests_core_profile_options"; + +function removeOptionsAddedByFramework(getCmdLineOptsResult) { + // Remove options that we are not interested in checking, but that get set by the test + delete getCmdLineOptsResult.parsed.setParameter + delete getCmdLineOptsResult.parsed.storage + delete getCmdLineOptsResult.parsed.net + delete getCmdLineOptsResult.parsed.fastsync + delete getCmdLineOptsResult.parsed.security + return getCmdLineOptsResult; +} + +function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) { + + // Start mongod with options + var mongod = MongoRunner.runMongod(mongoRunnerConfig); + + // Get the parsed options + var getCmdLineOptsResult = mongod.adminCommand("getCmdLineOpts"); + printjson(getCmdLineOptsResult); + + // Remove options added by the test framework + getCmdLineOptsResult = removeOptionsAddedByFramework(getCmdLineOptsResult); + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + MongoRunner.stopMongod(mongod.port); +} + +jsTest.log("Testing \"profile\" command line option with profiling off"); +var expectedResult = { + "parsed" : { + "operationProfiling" : { + "mode" : "off" + } + } +}; +testGetCmdLineOpts({ profile : "0" }, expectedResult); + +jsTest.log("Testing \"profile\" command line option with profiling slow operations on"); +var expectedResult = { + "parsed" : { + "operationProfiling" : { + "mode" : "slowOp" + } + } +}; +testGetCmdLineOpts({ profile : "1" }, expectedResult); + +jsTest.log("Testing \"profile\" command line option with profiling all on"); +var expectedResult = { + "parsed" : { + "operationProfiling" : { + "mode" : "all" + } + } +}; +testGetCmdLineOpts({ profile : "2" }, expectedResult); + +jsTest.log("Testing \"operationProfiling.mode\" config file option"); +expectedResult = { + "parsed" : { + "config" : "jstests/libs/config_files/set_profiling.json", + "operationProfiling" : { + "mode" : "all" + } + } +}; +testGetCmdLineOpts({ config : "jstests/libs/config_files/set_profiling.json" }, expectedResult); + + + +print(baseName + " succeeded."); |