summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@mongodb.com>2014-03-28 10:11:47 -0400
committerShaun Verch <shaun.verch@mongodb.com>2014-03-28 13:49:45 -0400
commita73fb4cab5dbc5caf18ebccd3d6ef0eda3fd6d96 (patch)
treee87e8fdc7d98ba3739241dab63b222cd0e609cda /jstests
parent9537c9c5355de719d367914deb1f57bc8c6b5017 (diff)
downloadmongo-a73fb4cab5dbc5caf18ebccd3d6ef0eda3fd6d96.tar.gz
SERVER-13379 Canonicalize profile as operationProfiling.mode
(cherry picked from commit 6ddce18d5ac886e9dadefb009454d4c8f0d2f5ae)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/profile_options.js75
-rw-r--r--jstests/libs/config_files/set_profiling.json5
2 files changed, 80 insertions, 0 deletions
diff --git a/jstests/core/profile_options.js b/jstests/core/profile_options.js
new file mode 100644
index 00000000000..0ba4a5b40c3
--- /dev/null
+++ b/jstests/core/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.");
diff --git a/jstests/libs/config_files/set_profiling.json b/jstests/libs/config_files/set_profiling.json
new file mode 100644
index 00000000000..944f0de1575
--- /dev/null
+++ b/jstests/libs/config_files/set_profiling.json
@@ -0,0 +1,5 @@
+{
+ "operationProfiling" : {
+ "mode" : "all"
+ }
+}