summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-10-21 02:02:26 -0400
committerShaun Verch <shaun.verch@10gen.com>2013-10-23 19:41:30 -0400
commit22f5a8622731353890352dbaccdebdc937ae8508 (patch)
treecdce2b2de98c0d5b23aa67a1548fe9c865f4eb50
parent89218f62b7ad5114df7e956bec47b4c1f96f1fed (diff)
downloadmongo-22f5a8622731353890352dbaccdebdc937ae8508.tar.gz
SERVER-11144 Create unit tests for registration in all option files
-rw-r--r--src/mongo/SConscript127
-rw-r--r--src/mongo/db/mongod_options.cpp32
-rw-r--r--src/mongo/db/mongod_options_init.cpp66
-rw-r--r--src/mongo/db/mongod_options_test.cpp1057
-rw-r--r--src/mongo/dbtests/framework_options.cpp26
-rw-r--r--src/mongo/dbtests/framework_options_init.cpp48
-rw-r--r--src/mongo/dbtests/framework_options_test.cpp190
-rw-r--r--src/mongo/s/mongos_options.cpp32
-rw-r--r--src/mongo/s/mongos_options_init.cpp54
-rw-r--r--src/mongo/s/mongos_options_test.cpp669
-rw-r--r--src/mongo/shell/shell_options.cpp26
-rw-r--r--src/mongo/shell/shell_options_init.cpp48
-rw-r--r--src/mongo/shell/shell_options_test.cpp278
-rw-r--r--src/mongo/tools/bsondump_options.cpp26
-rw-r--r--src/mongo/tools/bsondump_options_init.cpp48
-rw-r--r--src/mongo/tools/bsondump_options_test.cpp211
-rw-r--r--src/mongo/tools/mongobridge_options.cpp29
-rw-r--r--src/mongo/tools/mongobridge_options_init.cpp49
-rw-r--r--src/mongo/tools/mongobridge_options_test.cpp85
-rw-r--r--src/mongo/tools/mongodump_options.cpp26
-rw-r--r--src/mongo/tools/mongodump_options_init.cpp48
-rw-r--r--src/mongo/tools/mongodump_options_test.cpp378
-rw-r--r--src/mongo/tools/mongoexport_options.cpp26
-rw-r--r--src/mongo/tools/mongoexport_options_init.cpp48
-rw-r--r--src/mongo/tools/mongoexport_options_test.cpp425
-rw-r--r--src/mongo/tools/mongofiles_options.cpp26
-rw-r--r--src/mongo/tools/mongofiles_options_init.cpp48
-rw-r--r--src/mongo/tools/mongofiles_options_test.cpp377
-rw-r--r--src/mongo/tools/mongoimport_options.cpp26
-rw-r--r--src/mongo/tools/mongoimport_options_init.cpp48
-rw-r--r--src/mongo/tools/mongoimport_options_test.cpp440
-rw-r--r--src/mongo/tools/mongooplog_options.cpp26
-rw-r--r--src/mongo/tools/mongooplog_options_init.cpp48
-rw-r--r--src/mongo/tools/mongooplog_options_test.cpp360
-rw-r--r--src/mongo/tools/mongorestore_options.cpp26
-rw-r--r--src/mongo/tools/mongorestore_options_init.cpp48
-rw-r--r--src/mongo/tools/mongorestore_options_test.cpp442
-rw-r--r--src/mongo/tools/mongostat_options.cpp26
-rw-r--r--src/mongo/tools/mongostat_options_init.cpp48
-rw-r--r--src/mongo/tools/mongostat_options_test.cpp342
-rw-r--r--src/mongo/tools/mongotop_options.cpp26
-rw-r--r--src/mongo/tools/mongotop_options_init.cpp48
-rw-r--r--src/mongo/tools/mongotop_options_test.cpp305
43 files changed, 6362 insertions, 400 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 1fb157f4fed..fe9fd601beb 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -795,7 +795,7 @@ env.StaticLibrary("mongodwebserver",
],
LIBDEPS=["coredb", "mongodandmongos"])
-mongodOnlyFiles = [ "db/db.cpp", "db/commands/touch.cpp", "db/mongod_options.cpp" ]
+mongodOnlyFiles = [ "db/db.cpp", "db/commands/touch.cpp", "db/mongod_options_init.cpp" ]
# ----- TARGETS ------
@@ -807,6 +807,18 @@ if has_option( 'use-cpu-profiler' ):
env.StaticLibrary("coreserver", coreServerFiles, LIBDEPS=["mongocommon", "scripting"])
+# mongod options
+env.Library("mongod_options", ["db/mongod_options.cpp"],
+ LIBDEPS=['server_options',
+ 'mongocommon',
+ 'serveronly',
+ 'coreserver',
+ 'coredb',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('mongod_options_test', 'db/mongod_options_test.cpp',
+ LIBDEPS=['mongod_options'],
+ NO_CRUTCH=True)
+
# main db target
mongod = env.Install(
'#/', env.Program( "mongod", mongodOnlyFiles,
@@ -816,14 +828,21 @@ mongod = env.Install(
"mongodwebserver",
"ntservice",
"serveronly",
+ "mongod_options",
] ) )
Default( mongod )
# tools
allToolFiles = ["tools/tool.cpp",
"tools/stat_util.cpp",
- "tools/tool_options.cpp",
"tools/tool_logger.cpp"]
+env.StaticLibrary("tool_options", "tools/tool_options.cpp",
+ LIBDEPS=["server_options",
+ "$BUILD_DIR/mongo/util/options_parser/options_parser",
+ "serveronly",
+ "coreserver",
+ "coredb",
+ ])
env.StaticLibrary("alltools",
allToolFiles,
LIBDEPS=["serveronly",
@@ -833,27 +852,62 @@ env.StaticLibrary("alltools",
"$BUILD_DIR/mongo/db/auth/authmocks"])
normalTools = [ "dump", "restore", "export", "import", "stat", "top", "oplog" ]
-env.Alias( "tools", [ "#/${PROGPREFIX}mongo" + x + "${PROGSUFFIX}" for x in normalTools ] )
-for x in normalTools:
- env.Install( '#/', env.Program("mongo" + x,
- ["tools/" + x + ".cpp", "tools/mongo" + x + "_options.cpp"],
- LIBDEPS=["alltools"]) )
+env.Alias( "tools", [ "#/${PROGPREFIX}mongo" + name + "${PROGSUFFIX}" for name in normalTools ] )
+for name in normalTools:
+ env.Install( '#/', env.Program("mongo" + name,
+ ["tools/" + name + ".cpp", "tools/mongo" + name + "_options_init.cpp"],
+ LIBDEPS=["alltools", "mongo" + name + "_options"]) )
+ env.Library("mongo" + name + "_options", ["tools/mongo" + name + "_options.cpp"],
+ LIBDEPS=['tool_options', '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+ env.CppUnitTest('mongo' + name + '_options_test', 'tools/mongo' + name + '_options_test.cpp',
+ LIBDEPS=['mongo' + name + '_options'],
+ NO_CRUTCH=True)
#some special tools
+env.Library("mongofiles_options", ["tools/mongofiles_options.cpp"],
+ LIBDEPS=['tool_options', '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('mongofiles_options_test', 'tools/mongofiles_options_test.cpp',
+ LIBDEPS=['mongofiles_options'],
+ NO_CRUTCH=True)
+env.Library("bsondump_options", ["tools/bsondump_options.cpp"],
+ LIBDEPS=['tool_options', '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('bsondump_options_test', 'tools/bsondump_options_test.cpp',
+ LIBDEPS=['bsondump_options'],
+ NO_CRUTCH=True)
+env.Library("mongobridge_options", ["tools/mongobridge_options.cpp"],
+ LIBDEPS=['tool_options', '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('mongobridge_options_test', 'tools/mongobridge_options_test.cpp',
+ LIBDEPS=['mongobridge_options'],
+ NO_CRUTCH=True)
+
env.Install( '#/', [
- env.Program( "mongofiles", ["tools/files.cpp", "tools/mongofiles_options.cpp"], LIBDEPS=["alltools", "gridfs"] ),
- env.Program( "bsondump", ["tools/bsondump.cpp", "tools/bsondump_options.cpp"], LIBDEPS=["alltools"]),
- env.Program( "mongobridge", ["tools/bridge.cpp", "tools/mongobridge_options.cpp"],
- LIBDEPS=["serveronly", "coreserver", "coredb"] ),
+ env.Program( "mongofiles", ["tools/files.cpp", "tools/mongofiles_options_init.cpp"],
+ LIBDEPS=["alltools", "gridfs", "mongofiles_options"] ),
+ env.Program( "bsondump", ["tools/bsondump.cpp", "tools/bsondump_options_init.cpp"],
+ LIBDEPS=["alltools", "bsondump_options"]),
+ env.Program( "mongobridge", ["tools/bridge.cpp", "tools/mongobridge_options_init.cpp"],
+ LIBDEPS=["serveronly", "coreserver", "coredb", "mongobridge_options"] ),
env.Program( "mongoperf", "client/examples/mongoperf.cpp",
LIBDEPS=["serveronly", "coreserver", "coredb"] ),
] )
+# mongos options
+env.Library("mongos_options", ["s/mongos_options.cpp"],
+ LIBDEPS=['mongoscore',
+ 'coreshard',
+ 'mongocommon',
+ 'coreserver',
+ 'coredb',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('mongos_options_test', 's/mongos_options_test.cpp',
+ LIBDEPS=['mongos_options'],
+ NO_CRUTCH=True)
+
# mongos
mongos = env.Program(
- "mongos", [ "s/server.cpp", "s/mongos_options.cpp" ] ,
+ "mongos", [ "s/server.cpp", "s/mongos_options_init.cpp" ] ,
LIBDEPS=["mongoscore", "coreserver", "coredb", "mongocommon", "coreshard", "ntservice",
- "mongodandmongos", "s/upgrade" ])
+ "mongodandmongos", "s/upgrade", "mongos_options" ])
env.Install( '#/', mongos )
env.Library("clientandshell", ["client/clientAndShell.cpp"],
@@ -862,10 +916,24 @@ env.Library("clientandshell", ["client/clientAndShell.cpp"],
"gridfs"])
env.Library("allclient", "client/clientOnly.cpp", LIBDEPS=["clientandshell"])
+# dbtests test binary options
+env.Library("framework_options", ["dbtests/framework_options.cpp"],
+ LIBDEPS=['$BUILD_DIR/mongo/util/options_parser/options_parser'])
+env.CppUnitTest('framework_options_test', 'dbtests/framework_options_test.cpp',
+ LIBDEPS=['framework_options',
+ 'mongocommon',
+ 'serveronly',
+ 'server_options',
+ 'coreserver',
+ 'coredb',
+ ],
+ NO_CRUTCH=True)
+
# dbtests test binary
-env.StaticLibrary('testframework', ['dbtests/framework.cpp', 'dbtests/framework_options.cpp'],
+env.StaticLibrary('testframework', ['dbtests/framework.cpp', 'dbtests/framework_options_init.cpp'],
LIBDEPS=['unittest/unittest',
'$BUILD_DIR/mongo/util/options_parser/options_parser',
+ 'framework_options',
])
env.StaticLibrary('mocklib', [
@@ -882,7 +950,9 @@ test = testEnv.Install(
testEnv.Program("test",
[ f for f in Glob("dbtests/*.cpp")
if not str(f).endswith('framework.cpp') and
- not str(f).endswith('framework_options.cpp') ],
+ not str(f).endswith('framework_options.cpp') and
+ not str(f).endswith('framework_options_init.cpp') and
+ not str(f).endswith('framework_options_test.cpp') ],
LIBDEPS = [
"mutable_bson_test_utils",
"mongocommon",
@@ -932,23 +1002,36 @@ env.JSHeader("shell/mongo-server.cpp",
["shell/servers.js", "shell/shardingtest.js",
"shell/servers_misc.js", "shell/replsettest.js", "shell/replsetbridge.js"])
-coreShellFiles = [ "shell/dbshell.cpp",
- "shell/shell_utils.cpp",
+coreShellFiles = [ "shell/shell_utils.cpp",
"shell/shell_utils_extended.cpp",
"shell/shell_utils_launcher.cpp",
"shell/mongo-server.cpp",
"shell/linenoise.cpp",
"shell/linenoise_utf8.cpp",
"shell/mk_wcwidth.cpp",
- "shell/shell_options.cpp" ]
+ "shell/shell_options_init.cpp" ]
if shellEnv is not None:
+ env.Library("shell_core", coreShellFiles,
+ LIBDEPS=['clientandshell',
+ 'scripting',
+ 'mongocommon'])
+ # mongo shell options
+ env.Library("shell_options", ["shell/shell_options.cpp"],
+ LIBDEPS=['$BUILD_DIR/mongo/util/options_parser/options_parser'])
+ env.CppUnitTest('shell_options_test', 'shell/shell_options_test.cpp',
+ LIBDEPS=['shell_options',
+ 'shell_core'],
+ NO_CRUTCH=True)
+
mongo_shell = shellEnv.Program(
"mongo",
- coreShellFiles,
- LIBDEPS=["clientandshell", "mongocommon", "scripting",
- "$BUILD_DIR/mongo/util/options_parser/options_parser",
- "$BUILD_DIR/third_party/shim_pcrecpp"])
+ "shell/dbshell.cpp",
+ LIBDEPS=["$BUILD_DIR/mongo/util/options_parser/options_parser",
+ "$BUILD_DIR/third_party/shim_pcrecpp",
+ "shell_options",
+ "shell_core",
+ ])
shellEnv.Install( '#/', mongo_shell )
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index d4e305622bd..f4fdfd9a269 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/server_options.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/ssl_options.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/version.h"
@@ -760,35 +759,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongodOptions)(InitializerContext* context) {
- return addMongodOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongodOptions)(InitializerContext* context) {
- if (handlePreValidationMongodOptions(moe::startupOptionsParsed, context->args())) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_INITIALIZER_GENERAL(MongodOptions_Store,
- ("BeginStartupOptionStorage",
- "CreateAuthorizationManager"), // Requried to call
- // getGlobalAuthorizationManager().
- ("EndStartupOptionStorage"))
- (InitializerContext* context) {
- Status ret = storeMongodOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
-
} // namespace mongo
diff --git a/src/mongo/db/mongod_options_init.cpp b/src/mongo/db/mongod_options_init.cpp
new file mode 100644
index 00000000000..61b242046a4
--- /dev/null
+++ b/src/mongo/db/mongod_options_init.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2013 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/mongod_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongodOptions)(InitializerContext* context) {
+ return addMongodOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongodOptions)(InitializerContext* context) {
+ if (handlePreValidationMongodOptions(moe::startupOptionsParsed, context->args())) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_INITIALIZER_GENERAL(MongodOptions_Store,
+ ("BeginStartupOptionStorage",
+ "CreateAuthorizationManager"), // Requried to call
+ // getGlobalAuthorizationManager().
+ ("EndStartupOptionStorage"))
+ (InitializerContext* context) {
+ Status ret = storeMongodOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/mongod_options_test.cpp b/src/mongo/db/mongod_options_test.cpp
new file mode 100644
index 00000000000..69d83b0e445
--- /dev/null
+++ b/src/mongo/db/mongod_options_test.cpp
@@ -0,0 +1,1057 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/db/mongod_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongodOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "fastsync") {
+ ASSERT_EQUALS(iterator->_singleName, "fastsync");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "indicate that this instance is starting from a dbpath snapshot of the repl peer");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "pretouch") {
+ ASSERT_EQUALS(iterator->_singleName, "pretouch");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "n pretouch threads for applying master/slave operations");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "command") {
+ ASSERT_EQUALS(iterator->_singleName, "command");
+ ASSERT_EQUALS(iterator->_type, moe::StringVector);
+ ASSERT_EQUALS(iterator->_description, "command");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "cacheSize") {
+ ASSERT_EQUALS(iterator->_singleName, "cacheSize");
+ ASSERT_EQUALS(iterator->_type, moe::Long);
+ ASSERT_EQUALS(iterator->_description, "cache size (in MB) for rec store");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nodur") {
+ ASSERT_EQUALS(iterator->_singleName, "nodur");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable journaling");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nohints") {
+ ASSERT_EQUALS(iterator->_singleName, "nohints");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "ignore query hints");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nopreallocj") {
+ ASSERT_EQUALS(iterator->_singleName, "nopreallocj");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't preallocate journal files");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dur") {
+ ASSERT_EQUALS(iterator->_singleName, "dur");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "durOptions") {
+ ASSERT_EQUALS(iterator->_singleName, "durOptions");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "durability diagnostic options");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "pairwith") {
+ ASSERT_EQUALS(iterator->_singleName, "pairwith");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "DEPRECATED");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "arbiter") {
+ ASSERT_EQUALS(iterator->_singleName, "arbiter");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "DEPRECATED");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "opIdMem") {
+ ASSERT_EQUALS(iterator->_singleName, "opIdMem");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "DEPRECATED");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help,h");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show this usage information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show version information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "config") {
+ ASSERT_EQUALS(iterator->_singleName, "config,f");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "configuration file specifying additional options");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string("v"));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "quieter output");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "specify port number - 27017 by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "bind_ip") {
+ ASSERT_EQUALS(iterator->_singleName, "bind_ip");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "comma separated list of ip addresses to listen on - all local ips by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "maxConns") {
+ ASSERT_EQUALS(iterator->_singleName, "maxConns");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "max number of simultaneous connections - 20000 by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logpath") {
+ ASSERT_EQUALS(iterator->_singleName, "logpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "log file to send write to instead of stdout - has to be a file, not directory");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "syslogFacility") {
+ ASSERT_EQUALS(iterator->_singleName, "syslogFacility");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "syslog facility used for monogdb syslog message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logappend") {
+ ASSERT_EQUALS(iterator->_singleName, "logappend");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "append to logpath instead of over-writing");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logTimestampFormat") {
+ ASSERT_EQUALS(iterator->_singleName, "logTimestampFormat");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Desired format for timestamps in log messages. One of ctime, iso8601-utc or iso8601-local");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "pidfilepath") {
+ ASSERT_EQUALS(iterator->_singleName, "pidfilepath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "full path to pidfile (if not set, no pidfile is created)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "keyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "keyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "private key for cluster authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "setParameter") {
+ ASSERT_EQUALS(iterator->_singleName, "setParameter");
+ ASSERT_EQUALS(iterator->_type, moe::StringVector);
+ ASSERT_EQUALS(iterator->_description, "Set a configurable parameter");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, true);
+ }
+ else if (iterator->_dottedName == "httpinterface") {
+ ASSERT_EQUALS(iterator->_singleName, "httpinterface");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable http interface");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "clusterAuthMode") {
+ ASSERT_EQUALS(iterator->_singleName, "clusterAuthMode");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Authentication mode used for cluster authentication. Alternatives are (keyfile|sendKeyfile|sendX509|x509)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nounixsocket") {
+ ASSERT_EQUALS(iterator->_singleName, "nounixsocket");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable listening on unix sockets");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "unixSocketPrefix") {
+ ASSERT_EQUALS(iterator->_singleName, "unixSocketPrefix");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "alternative directory for UNIX domain sockets (defaults to /tmp)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fork") {
+ ASSERT_EQUALS(iterator->_singleName, "fork");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "fork server process");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "syslog") {
+ ASSERT_EQUALS(iterator->_singleName, "syslog");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "log to system's syslog facility instead of file or stdout");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nohttpinterface") {
+ ASSERT_EQUALS(iterator->_singleName, "nohttpinterface");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable http interface");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "objcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "objcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "inspect client data for validity on receipt (DEFAULT)");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noobjcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "noobjcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "do NOT inspect client data for validity on receipt");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "traceExceptions") {
+ ASSERT_EQUALS(iterator->_singleName, "traceExceptions");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "log stack traces for every exception");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "enableExperimentalIndexStatsCmd") {
+ ASSERT_EQUALS(iterator->_singleName, "enableExperimentalIndexStatsCmd");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on indexes.");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "enableExperimentalStorageDetailsCmd") {
+ ASSERT_EQUALS(iterator->_singleName, "enableExperimentalStorageDetailsCmd");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on storage.");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "auth") {
+ ASSERT_EQUALS(iterator->_singleName, "auth");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "run with security");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "cpu") {
+ ASSERT_EQUALS(iterator->_singleName, "cpu");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "periodically show cpu and iowait utilization");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+#ifdef _WIN32
+ ASSERT_EQUALS(iterator->_description, "directory for datafiles - defaults to \\data\\db\\");
+#else
+ ASSERT_EQUALS(iterator->_description, "directory for datafiles - defaults to /data/db/");
+#endif
+ ASSERT_EQUALS(iterator->_isVisible, true);
+#ifdef _WIN32
+ moe::Value defaultVal(std::string("\\data\\db\\"));
+#else
+ moe::Value defaultVal(std::string("/data/db"));
+#endif
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "diaglog") {
+ ASSERT_EQUALS(iterator->_singleName, "diaglog");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "0=off 1=W 2=R 3=both 7=W+some reads");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each database will be stored in a separate directory");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journalCommitInterval") {
+ ASSERT_EQUALS(iterator->_singleName, "journalCommitInterval");
+ ASSERT_EQUALS(iterator->_type, moe::Unsigned);
+ ASSERT_EQUALS(iterator->_description, "how often to group/batch commit (ms)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journalOptions") {
+ ASSERT_EQUALS(iterator->_singleName, "journalOptions");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "journal diagnostic options");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "jsonp") {
+ ASSERT_EQUALS(iterator->_singleName, "jsonp");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "allow JSONP access via http (has security implications)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noauth") {
+ ASSERT_EQUALS(iterator->_singleName, "noauth");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "run without security");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noIndexBuildRetry") {
+ ASSERT_EQUALS(iterator->_singleName, "noIndexBuildRetry");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't retry any index builds that were interrupted by shutdown");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nojournal") {
+ ASSERT_EQUALS(iterator->_singleName, "nojournal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable journaling (journaling is on by default for 64 bit)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noprealloc") {
+ ASSERT_EQUALS(iterator->_singleName, "noprealloc");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable data file preallocation - will often hurt performance");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noscripting") {
+ ASSERT_EQUALS(iterator->_singleName, "noscripting");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable scripting engine");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "notablescan") {
+ ASSERT_EQUALS(iterator->_singleName, "notablescan");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "do not allow table scans");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nssize") {
+ ASSERT_EQUALS(iterator->_singleName, "nssize");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, ".ns file size (in MB) for new databases");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(16);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "profile") {
+ ASSERT_EQUALS(iterator->_singleName, "profile");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "0=off 1=slow, 2=all");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quota") {
+ ASSERT_EQUALS(iterator->_singleName, "quota");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "limits each database to a certain number of files (8 default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quotaFiles") {
+ ASSERT_EQUALS(iterator->_singleName, "quotaFiles");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "number of files allowed per db, requires --quota");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "repair") {
+ ASSERT_EQUALS(iterator->_singleName, "repair");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "run repair on all dbs");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "repairpath") {
+ ASSERT_EQUALS(iterator->_singleName, "repairpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "root directory for repair files - defaults to dbpath");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "rest") {
+ ASSERT_EQUALS(iterator->_singleName, "rest");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "turn on simple rest api");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "slowms") {
+ ASSERT_EQUALS(iterator->_singleName, "slowms");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "value of slow for profile and console log");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(100);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "smallfiles") {
+ ASSERT_EQUALS(iterator->_singleName, "smallfiles");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use a smaller default file size");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "syncdelay") {
+ ASSERT_EQUALS(iterator->_singleName, "syncdelay");
+ ASSERT_EQUALS(iterator->_type, moe::Double);
+ ASSERT_EQUALS(iterator->_description, "seconds between disk syncs (0=never, but not recommended)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(60.0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "sysinfo") {
+ ASSERT_EQUALS(iterator->_singleName, "sysinfo");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print some diagnostic system information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "upgrade") {
+ ASSERT_EQUALS(iterator->_singleName, "upgrade");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "upgrade db if needed");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "oplogSize") {
+ ASSERT_EQUALS(iterator->_singleName, "oplogSize");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "size to use (in MB) for replication op log. default is 5% of disk space (i.e. large is good)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "master") {
+ ASSERT_EQUALS(iterator->_singleName, "master");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "master mode");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "slave") {
+ ASSERT_EQUALS(iterator->_singleName, "slave");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "slave mode");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "source") {
+ ASSERT_EQUALS(iterator->_singleName, "source");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "when slave: specify master as <server:port>");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "only") {
+ ASSERT_EQUALS(iterator->_singleName, "only");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "when slave: specify a single database to replicate");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "slavedelay") {
+ ASSERT_EQUALS(iterator->_singleName, "slavedelay");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "specify delay (in seconds) to be used when applying master ops to slave");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "autoresync") {
+ ASSERT_EQUALS(iterator->_singleName, "autoresync");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "automatically resync if slave data is stale");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "replSet") {
+ ASSERT_EQUALS(iterator->_singleName, "replSet");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "arg is <setname>[/<optionalseedhostlist>]");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "replIndexPrefetch") {
+ ASSERT_EQUALS(iterator->_singleName, "replIndexPrefetch");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "specify index prefetching behavior (if secondary) [none|_id_only|all]");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "configsvr") {
+ ASSERT_EQUALS(iterator->_singleName, "configsvr");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "declare this is a config db of a cluster; default port 27019; default dir /data/configdb");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "shardsvr") {
+ ASSERT_EQUALS(iterator->_singleName, "shardsvr");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "declare this is a shard db of a cluster; default port 27018");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noMoveParanoia") {
+ ASSERT_EQUALS(iterator->_singleName, "noMoveParanoia");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "turn off paranoid saving of data for the moveChunk command; default");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "moveParanoia") {
+ ASSERT_EQUALS(iterator->_singleName, "moveParanoia");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "turn on paranoid saving of data during the moveChunk command (used for internal system diagnostics)");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl.sslOnNormalPorts") {
+ ASSERT_EQUALS(iterator->_singleName, "sslOnNormalPorts");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use ssl on configured ports");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.mode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslMode");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "set the SSL operation mode (noSSL|acceptSSL|sendAcceptSSL|sslOnly)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM file for ssl");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM file password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.clusterFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslClusterFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Key file for internal SSL authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.clusterPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslClusterPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Internal authentication key file password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.weakCertificateValidation") {
+ ASSERT_EQUALS(iterator->_singleName, "sslWeakCertificateValidation");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "allow client to connect without presenting a certificate");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+#ifdef _WIN32
+ else if (iterator->_dottedName == "install") {
+ ASSERT_EQUALS(iterator->_singleName, "install");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "install Windows service");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "remove") {
+ ASSERT_EQUALS(iterator->_singleName, "remove");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "remove Windows service");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "reinstall") {
+ ASSERT_EQUALS(iterator->_singleName, "reinstall");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "reinstall Windows service (equivalent to --remove followed by --install)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceName") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceName");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service name");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceDisplayName") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceDisplayName");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service display name");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceDescription") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceDescription");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service description");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceUser") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceUser");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "account for service execution");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "servicePassword") {
+ ASSERT_EQUALS(iterator->_singleName, "servicePassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password used to authenticate serviceUser");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "service") {
+ ASSERT_EQUALS(iterator->_singleName, "service");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "start mongodb service");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp
index ab32f9c0c61..88a74ca6f17 100644
--- a/src/mongo/dbtests/framework_options.cpp
+++ b/src/mongo/dbtests/framework_options.cpp
@@ -25,7 +25,6 @@
#include "mongo/db/storage_options.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/password.h"
@@ -263,29 +262,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(FrameworkOptions)(InitializerContext* context) {
- return addTestFrameworkOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(FrameworkOptions)(InitializerContext* context) {
- if (handlePreValidationTestFrameworkOptions(moe::startupOptionsParsed, context->args())) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(FrameworkOptions)(InitializerContext* context) {
- Status ret = storeTestFrameworkOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/dbtests/framework_options_init.cpp b/src/mongo/dbtests/framework_options_init.cpp
new file mode 100644
index 00000000000..1198b2e81d3
--- /dev/null
+++ b/src/mongo/dbtests/framework_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2013 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/dbtests/framework_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(FrameworkOptions)(InitializerContext* context) {
+ return addTestFrameworkOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(FrameworkOptions)(InitializerContext* context) {
+ if (handlePreValidationTestFrameworkOptions(moe::startupOptionsParsed, context->args())) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(FrameworkOptions)(InitializerContext* context) {
+ Status ret = storeTestFrameworkOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/dbtests/framework_options_test.cpp b/src/mongo/dbtests/framework_options_test.cpp
new file mode 100644
index 00000000000..b599b4d3a24
--- /dev/null
+++ b/src/mongo/dbtests/framework_options_test.cpp
@@ -0,0 +1,190 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/dbtests/framework_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/dbtests/dbtests.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ // This specifies default dbpath for our testing framework
+ const std::string default_test_dbpath = "/data/db/framework_options_test";
+}
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addTestFrameworkOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help,h");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show this usage information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "db data path for this test run. NOTE: the contents of this directory will be overwritten if it already exists");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(default_test_dbpath);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "debug") {
+ ASSERT_EQUALS(iterator->_singleName, "debug");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "run tests with verbose output");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "list") {
+ ASSERT_EQUALS(iterator->_singleName, "list,l");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "list available test suites");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "bigfiles") {
+ ASSERT_EQUALS(iterator->_singleName, "bigfiles");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use big datafiles instead of smallfiles which is the default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "filter") {
+ ASSERT_EQUALS(iterator->_singleName, "filter,f");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "string substring filter on test name");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "useNewQueryFramework") {
+ ASSERT_EQUALS(iterator->_singleName, "useNewQueryFramework");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use the new query framework");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dur") {
+ ASSERT_EQUALS(iterator->_singleName, "dur");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (currently the default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nodur") {
+ ASSERT_EQUALS(iterator->_singleName, "nodur");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable journaling");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "seed") {
+ ASSERT_EQUALS(iterator->_singleName, "seed");
+ ASSERT_EQUALS(iterator->_type, moe::UnsignedLongLong);
+ ASSERT_EQUALS(iterator->_description, "random number seed");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "runs") {
+ ASSERT_EQUALS(iterator->_singleName, "runs");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "number of times to run each test");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "perfHist") {
+ ASSERT_EQUALS(iterator->_singleName, "perfHist");
+ ASSERT_EQUALS(iterator->_type, moe::Unsigned);
+ ASSERT_EQUALS(iterator->_description, "number of back runs of perf stats to display");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "suites") {
+ ASSERT_EQUALS(iterator->_singleName, "suites");
+ ASSERT_EQUALS(iterator->_type, moe::StringVector);
+ ASSERT_EQUALS(iterator->_description, "test suites to run");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nopreallocj") {
+ ASSERT_EQUALS(iterator->_singleName, "nopreallocj");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable journal prealloc");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp
index 160e601ed8b..dbab0ccc766 100644
--- a/src/mongo/s/mongos_options.cpp
+++ b/src/mongo/s/mongos_options.cpp
@@ -25,7 +25,6 @@
#include "mongo/s/chunk.h"
#include "mongo/s/version_mongos.h"
#include "mongo/util/net/ssl_options.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/startup_test.h"
#include "mongo/util/stringutils.h"
@@ -229,35 +228,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongosOptions)(InitializerContext* context) {
- return addMongosOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongosOptions)(InitializerContext* context) {
- if (handlePreValidationMongosOptions(moe::startupOptionsParsed, context->args())) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_INITIALIZER_GENERAL(MongosOptions_Store,
- ("BeginStartupOptionStorage",
- "CreateAuthorizationManager"), // Requried to call
- // getGlobalAuthorizationManager().
- ("EndStartupOptionStorage"))
- (InitializerContext* context) {
- Status ret = storeMongosOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
-
} // namespace mongo
diff --git a/src/mongo/s/mongos_options_init.cpp b/src/mongo/s/mongos_options_init.cpp
new file mode 100644
index 00000000000..2ead4f87d80
--- /dev/null
+++ b/src/mongo/s/mongos_options_init.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/s/mongos_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongosOptions)(InitializerContext* context) {
+ return addMongosOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongosOptions)(InitializerContext* context) {
+ if (handlePreValidationMongosOptions(moe::startupOptionsParsed, context->args())) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_INITIALIZER_GENERAL(MongosOptions_Store,
+ ("BeginStartupOptionStorage",
+ "CreateAuthorizationManager"), // Requried to call
+ // getGlobalAuthorizationManager().
+ ("EndStartupOptionStorage"))
+ (InitializerContext* context) {
+ Status ret = storeMongosOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+
+} // namespace mongo
diff --git a/src/mongo/s/mongos_options_test.cpp b/src/mongo/s/mongos_options_test.cpp
new file mode 100644
index 00000000000..eaf1be922e6
--- /dev/null
+++ b/src/mongo/s/mongos_options_test.cpp
@@ -0,0 +1,669 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/s/mongos_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/client/dbclientinterface.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+// Crutches to make the test link
+namespace mongo {
+ bool inShutdown() {
+ return false;
+ }
+
+ DBClientBase *createDirectClient() {
+ return 0;
+ }
+
+ bool haveLocalShardingInfo(const std::string& ns) {
+ return false;
+ }
+
+ void dbexit(ExitCode rc, const char *why) {
+ ::_exit(-1);
+ }
+}
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongosOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "noAutoSplit") {
+ ASSERT_EQUALS(iterator->_singleName, "noAutoSplit");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "do not send split commands with writes");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help,h");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show this usage information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show version information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "config") {
+ ASSERT_EQUALS(iterator->_singleName, "config,f");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "configuration file specifying additional options");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string("v"));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "quieter output");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "specify port number - 27017 by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "bind_ip") {
+ ASSERT_EQUALS(iterator->_singleName, "bind_ip");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "comma separated list of ip addresses to listen on - all local ips by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "maxConns") {
+ ASSERT_EQUALS(iterator->_singleName, "maxConns");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "max number of simultaneous connections - 20000 by default");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logpath") {
+ ASSERT_EQUALS(iterator->_singleName, "logpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "log file to send write to instead of stdout - has to be a file, not directory");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "syslogFacility") {
+ ASSERT_EQUALS(iterator->_singleName, "syslogFacility");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "syslog facility used for monogdb syslog message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logappend") {
+ ASSERT_EQUALS(iterator->_singleName, "logappend");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "append to logpath instead of over-writing");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "logTimestampFormat") {
+ ASSERT_EQUALS(iterator->_singleName, "logTimestampFormat");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Desired format for timestamps in log messages. One of ctime, iso8601-utc or iso8601-local");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "pidfilepath") {
+ ASSERT_EQUALS(iterator->_singleName, "pidfilepath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "full path to pidfile (if not set, no pidfile is created)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "keyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "keyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "private key for cluster authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "setParameter") {
+ ASSERT_EQUALS(iterator->_singleName, "setParameter");
+ ASSERT_EQUALS(iterator->_type, moe::StringVector);
+ ASSERT_EQUALS(iterator->_description, "Set a configurable parameter");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, true);
+ }
+ else if (iterator->_dottedName == "httpinterface") {
+ ASSERT_EQUALS(iterator->_singleName, "httpinterface");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable http interface");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "clusterAuthMode") {
+ ASSERT_EQUALS(iterator->_singleName, "clusterAuthMode");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Authentication mode used for cluster authentication. Alternatives are (keyfile|sendKeyfile|sendX509|x509)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nounixsocket") {
+ ASSERT_EQUALS(iterator->_singleName, "nounixsocket");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable listening on unix sockets");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "unixSocketPrefix") {
+ ASSERT_EQUALS(iterator->_singleName, "unixSocketPrefix");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "alternative directory for UNIX domain sockets (defaults to /tmp)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fork") {
+ ASSERT_EQUALS(iterator->_singleName, "fork");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "fork server process");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "syslog") {
+ ASSERT_EQUALS(iterator->_singleName, "syslog");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "log to system's syslog facility instead of file or stdout");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nohttpinterface") {
+ ASSERT_EQUALS(iterator->_singleName, "nohttpinterface");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable http interface");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "objcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "objcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "inspect client data for validity on receipt (DEFAULT)");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noobjcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "noobjcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "do NOT inspect client data for validity on receipt");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "traceExceptions") {
+ ASSERT_EQUALS(iterator->_singleName, "traceExceptions");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "log stack traces for every exception");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "enableExperimentalIndexStatsCmd") {
+ ASSERT_EQUALS(iterator->_singleName, "enableExperimentalIndexStatsCmd");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on indexes.");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "enableExperimentalStorageDetailsCmd") {
+ ASSERT_EQUALS(iterator->_singleName, "enableExperimentalStorageDetailsCmd");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "EXPERIMENTAL (UNSUPPORTED). Enable command computing aggregate statistics on storage.");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "configdb") {
+ ASSERT_EQUALS(iterator->_singleName, "configdb");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "1 or 3 comma separated config servers");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "localThreshold") {
+ ASSERT_EQUALS(iterator->_singleName, "localThreshold");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "ping time (in ms) for a node to be considered local (default 15ms)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "test") {
+ ASSERT_EQUALS(iterator->_singleName, "test");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "just run unit tests");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "upgrade") {
+ ASSERT_EQUALS(iterator->_singleName, "upgrade");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "upgrade meta data version");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "chunkSize") {
+ ASSERT_EQUALS(iterator->_singleName, "chunkSize");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "maximum amount of data per chunk");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "jsonp") {
+ ASSERT_EQUALS(iterator->_singleName, "jsonp");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "allow JSONP access via http (has security implications)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noscripting") {
+ ASSERT_EQUALS(iterator->_singleName, "noscripting");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "disable scripting engine");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl.sslOnNormalPorts") {
+ ASSERT_EQUALS(iterator->_singleName, "sslOnNormalPorts");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use ssl on configured ports");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.mode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslMode");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "set the SSL operation mode (noSSL|acceptSSL|sendAcceptSSL|sslOnly)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM file for ssl");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM file password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.clusterFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslClusterFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Key file for internal SSL authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.clusterPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslClusterPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Internal authentication key file password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.weakCertificateValidation") {
+ ASSERT_EQUALS(iterator->_singleName, "sslWeakCertificateValidation");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "allow client to connect without presenting a certificate");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+#ifdef _WIN32
+ else if (iterator->_dottedName == "install") {
+ ASSERT_EQUALS(iterator->_singleName, "install");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "install Windows service");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "remove") {
+ ASSERT_EQUALS(iterator->_singleName, "remove");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "remove Windows service");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "reinstall") {
+ ASSERT_EQUALS(iterator->_singleName, "reinstall");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "reinstall Windows service (equivalent to --remove followed by --install)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceName") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceName");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service name");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceDisplayName") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceDisplayName");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service display name");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceDescription") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceDescription");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Windows service description");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "serviceUser") {
+ ASSERT_EQUALS(iterator->_singleName, "serviceUser");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "account for service execution");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "servicePassword") {
+ ASSERT_EQUALS(iterator->_singleName, "servicePassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password used to authenticate serviceUser");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "service") {
+ ASSERT_EQUALS(iterator->_singleName, "service");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "start mongodb service");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 63bbe842d3e..a031a86b15f 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -24,7 +24,6 @@
#include "mongo/shell/shell_utils.h"
#include "mongo/util/net/sock.h"
#include "mongo/util/net/ssl_options.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/version.h"
@@ -280,29 +279,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoShellOptions)(InitializerContext* context) {
- return addMongoShellOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoShellOptions)(InitializerContext* context) {
- if (handlePreValidationMongoShellOptions(moe::startupOptionsParsed, context->args())) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoShellOptions)(InitializerContext* context) {
- Status ret = storeMongoShellOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/shell/shell_options_init.cpp b/src/mongo/shell/shell_options_init.cpp
new file mode 100644
index 00000000000..f1d7f991945
--- /dev/null
+++ b/src/mongo/shell/shell_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2013 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/shell/shell_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoShellOptions)(InitializerContext* context) {
+ return addMongoShellOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoShellOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoShellOptions(moe::startupOptionsParsed, context->args())) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoShellOptions)(InitializerContext* context) {
+ Status ret = storeMongoShellOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/shell/shell_options_test.cpp b/src/mongo/shell/shell_options_test.cpp
new file mode 100644
index 00000000000..0f61be2be7d
--- /dev/null
+++ b/src/mongo/shell/shell_options_test.cpp
@@ -0,0 +1,278 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/shell/shell_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoShellOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "shell") {
+ ASSERT_EQUALS(iterator->_singleName, "shell");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "run the shell after executing files");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nodb") {
+ ASSERT_EQUALS(iterator->_singleName, "nodb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't connect to mongod on startup - no 'db address' arg expected");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "norc") {
+ ASSERT_EQUALS(iterator->_singleName, "norc");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "will not run the \".mongorc.js\" file on start up");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be less chatty");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "port to connect to");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server to connect to");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "eval") {
+ ASSERT_EQUALS(iterator->_singleName, "eval");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "evaluate javascript");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username for authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for authentication");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help,h");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show this usage information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "show version information");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "increase verbosity");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbaddress") {
+ ASSERT_EQUALS(iterator->_singleName, "dbaddress");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "dbaddress");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "files") {
+ ASSERT_EQUALS(iterator->_singleName, "files");
+ ASSERT_EQUALS(iterator->_type, moe::StringVector);
+ ASSERT_EQUALS(iterator->_description, "files");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "nokillop") {
+ ASSERT_EQUALS(iterator->_singleName, "nokillop");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "nokillop");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "autokillop") {
+ ASSERT_EQUALS(iterator->_singleName, "autokillop");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "autokillop");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/bsondump_options.cpp b/src/mongo/tools/bsondump_options.cpp
index 73739f174cf..e2e659dd6bd 100644
--- a/src/mongo/tools/bsondump_options.cpp
+++ b/src/mongo/tools/bsondump_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/bsondump_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -96,29 +95,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(BSONDumpOptions)(InitializerContext* context) {
- return addBSONDumpOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(BSONDumpOptions)(InitializerContext* context) {
- if (handlePreValidationBSONDumpOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(BSONDumpOptions)(InitializerContext* context) {
- Status ret = storeBSONDumpOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/bsondump_options_init.cpp b/src/mongo/tools/bsondump_options_init.cpp
new file mode 100644
index 00000000000..eed5baa82bc
--- /dev/null
+++ b/src/mongo/tools/bsondump_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/bsondump_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(BSONDumpOptions)(InitializerContext* context) {
+ return addBSONDumpOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(BSONDumpOptions)(InitializerContext* context) {
+ if (handlePreValidationBSONDumpOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(BSONDumpOptions)(InitializerContext* context) {
+ Status ret = storeBSONDumpOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/bsondump_options_test.cpp b/src/mongo/tools/bsondump_options_test.cpp
new file mode 100644
index 00000000000..ff65fc012ef
--- /dev/null
+++ b/src/mongo/tools/bsondump_options_test.cpp
@@ -0,0 +1,211 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/bsondump_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addBSONDumpOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "objcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "objcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "validate object before inserting (default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noobjcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "noobjcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't validate object before inserting");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "filter") {
+ ASSERT_EQUALS(iterator->_singleName, "filter");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "filter to apply before inserting");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "type") {
+ ASSERT_EQUALS(iterator->_singleName, "type");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "type of output: json,debug");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("json"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "file") {
+ ASSERT_EQUALS(iterator->_singleName, "file");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "hidden description");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongobridge_options.cpp b/src/mongo/tools/mongobridge_options.cpp
index 180632b7a9c..862d8b6a1b3 100644
--- a/src/mongo/tools/mongobridge_options.cpp
+++ b/src/mongo/tools/mongobridge_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongobridge_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -90,30 +89,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoBridgeOptions)(InitializerContext* context) {
- return addMongoBridgeOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoBridgeOptions)(InitializerContext* context) {
- if (handlePreValidationMongoBridgeOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoBridgeOptions)(InitializerContext* context) {
- Status ret = storeMongoBridgeOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
-}
-
+} // namespace mongo
diff --git a/src/mongo/tools/mongobridge_options_init.cpp b/src/mongo/tools/mongobridge_options_init.cpp
new file mode 100644
index 00000000000..d966a27d7f5
--- /dev/null
+++ b/src/mongo/tools/mongobridge_options_init.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongobridge_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoBridgeOptions)(InitializerContext* context) {
+ return addMongoBridgeOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoBridgeOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoBridgeOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoBridgeOptions)(InitializerContext* context) {
+ Status ret = storeMongoBridgeOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
+
diff --git a/src/mongo/tools/mongobridge_options_test.cpp b/src/mongo/tools/mongobridge_options_test.cpp
new file mode 100644
index 00000000000..12bbd37cd9d
--- /dev/null
+++ b/src/mongo/tools/mongobridge_options_test.cpp
@@ -0,0 +1,85 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongobridge_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoBridgeOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "port to listen for mongo messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dest") {
+ ASSERT_EQUALS(iterator->_singleName, "dest");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "uri of remote mongod instance");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "delay") {
+ ASSERT_EQUALS(iterator->_singleName, "delay");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "transfer delay in milliseconds (default = 0)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongodump_options.cpp b/src/mongo/tools/mongodump_options.cpp
index b924fcba2d5..592400e6523 100644
--- a/src/mongo/tools/mongodump_options.cpp
+++ b/src/mongo/tools/mongodump_options.cpp
@@ -18,7 +18,6 @@
#include "mongo/base/status.h"
#include "mongo/util/log.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -137,29 +136,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoDumpOptions)(InitializerContext* context) {
- return addMongoDumpOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoDumpOptions)(InitializerContext* context) {
- if (handlePreValidationMongoDumpOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoDumpOptions)(InitializerContext* context) {
- Status ret = storeMongoDumpOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongodump_options_init.cpp b/src/mongo/tools/mongodump_options_init.cpp
new file mode 100644
index 00000000000..189a9e59a2a
--- /dev/null
+++ b/src/mongo/tools/mongodump_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongodump_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoDumpOptions)(InitializerContext* context) {
+ return addMongoDumpOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoDumpOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoDumpOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoDumpOptions)(InitializerContext* context) {
+ Status ret = storeMongoDumpOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongodump_options_test.cpp b/src/mongo/tools/mongodump_options_test.cpp
new file mode 100644
index 00000000000..173c105214c
--- /dev/null
+++ b/src/mongo/tools/mongodump_options_test.cpp
@@ -0,0 +1,378 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongodump_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoDumpOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "out") {
+ ASSERT_EQUALS(iterator->_singleName, "out,o");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "output directory or \"-\" for stdout");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("dump"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "query") {
+ ASSERT_EQUALS(iterator->_singleName, "query,q");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "json query");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "oplog") {
+ ASSERT_EQUALS(iterator->_singleName, "oplog");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "Use oplog for point-in-time snapshotting");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "repair") {
+ ASSERT_EQUALS(iterator->_singleName, "repair");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "try to recover a crashed database");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "forceTableScan") {
+ ASSERT_EQUALS(iterator->_singleName, "forceTableScan");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "force a table scan (do not use $snapshot)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongoexport_options.cpp b/src/mongo/tools/mongoexport_options.cpp
index 2b1f26e53ae..b028b5e0285 100644
--- a/src/mongo/tools/mongoexport_options.cpp
+++ b/src/mongo/tools/mongoexport_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongoexport_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -150,29 +149,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoExportOptions)(InitializerContext* context) {
- return addMongoExportOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoExportOptions)(InitializerContext* context) {
- if (handlePreValidationMongoExportOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoExportOptions)(InitializerContext* context) {
- Status ret = storeMongoExportOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongoexport_options_init.cpp b/src/mongo/tools/mongoexport_options_init.cpp
new file mode 100644
index 00000000000..d18b0771716
--- /dev/null
+++ b/src/mongo/tools/mongoexport_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongoexport_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoExportOptions)(InitializerContext* context) {
+ return addMongoExportOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoExportOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoExportOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoExportOptions)(InitializerContext* context) {
+ Status ret = storeMongoExportOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongoexport_options_test.cpp b/src/mongo/tools/mongoexport_options_test.cpp
new file mode 100644
index 00000000000..2886109b5c0
--- /dev/null
+++ b/src/mongo/tools/mongoexport_options_test.cpp
@@ -0,0 +1,425 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongoexport_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoExportOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fields") {
+ ASSERT_EQUALS(iterator->_singleName, "fields,f");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "comma separated list of field names e.g. -f name,age");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fieldFile") {
+ ASSERT_EQUALS(iterator->_singleName, "fieldFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "file with field names - 1 per line");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "query") {
+ ASSERT_EQUALS(iterator->_singleName, "query,q");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "query filter, as a JSON string");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "csv") {
+ ASSERT_EQUALS(iterator->_singleName, "csv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "export to csv instead of json");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "out") {
+ ASSERT_EQUALS(iterator->_singleName, "out,o");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "output file; if not specified, stdout is used");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "jsonArray") {
+ ASSERT_EQUALS(iterator->_singleName, "jsonArray");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "output to a json array rather than one object per line");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "slaveOk") {
+ ASSERT_EQUALS(iterator->_singleName, "slaveOk,k");
+ ASSERT_EQUALS(iterator->_type, moe::Bool);
+ ASSERT_EQUALS(iterator->_description, "use secondaries for export if available, default true");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(true);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "forceTableScan") {
+ ASSERT_EQUALS(iterator->_singleName, "forceTableScan");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "force a table scan (do not use $snapshot)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "skip") {
+ ASSERT_EQUALS(iterator->_singleName, "skip");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "documents to skip, default 0");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "limit") {
+ ASSERT_EQUALS(iterator->_singleName, "limit");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "limit the numbers of documents returned, default all");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongofiles_options.cpp b/src/mongo/tools/mongofiles_options.cpp
index da5ffead5c4..8e5c5972a43 100644
--- a/src/mongo/tools/mongofiles_options.cpp
+++ b/src/mongo/tools/mongofiles_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongofiles_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -117,29 +116,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoFilesOptions)(InitializerContext* context) {
- return addMongoFilesOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoFilesOptions)(InitializerContext* context) {
- if (handlePreValidationMongoFilesOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoFilesOptions)(InitializerContext* context) {
- Status ret = storeMongoFilesOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongofiles_options_init.cpp b/src/mongo/tools/mongofiles_options_init.cpp
new file mode 100644
index 00000000000..9b6a5f9d9d3
--- /dev/null
+++ b/src/mongo/tools/mongofiles_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongofiles_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoFilesOptions)(InitializerContext* context) {
+ return addMongoFilesOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoFilesOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoFilesOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoFilesOptions)(InitializerContext* context) {
+ Status ret = storeMongoFilesOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongofiles_options_test.cpp b/src/mongo/tools/mongofiles_options_test.cpp
new file mode 100644
index 00000000000..ba7aaf03382
--- /dev/null
+++ b/src/mongo/tools/mongofiles_options_test.cpp
@@ -0,0 +1,377 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongofiles_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoFilesOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "local") {
+ ASSERT_EQUALS(iterator->_singleName, "local,l");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "local filename for put|get (default is to use the same name as 'gridfs filename')");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "type") {
+ ASSERT_EQUALS(iterator->_singleName, "type,t");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "MIME type for put (default is to omit)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "replace") {
+ ASSERT_EQUALS(iterator->_singleName, "replace,r");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "Remove other files with same name after PUT");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "command") {
+ ASSERT_EQUALS(iterator->_singleName, "command");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "hidden description");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "file") {
+ ASSERT_EQUALS(iterator->_singleName, "file");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "hidden description");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongoimport_options.cpp b/src/mongo/tools/mongoimport_options.cpp
index 534f69e66e4..de400bf139a 100644
--- a/src/mongo/tools/mongoimport_options.cpp
+++ b/src/mongo/tools/mongoimport_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongoimport_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/text.h"
@@ -172,29 +171,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoImportOptions)(InitializerContext* context) {
- return addMongoImportOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoImportOptions)(InitializerContext* context) {
- if (handlePreValidationMongoImportOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoImportOptions)(InitializerContext* context) {
- Status ret = storeMongoImportOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongoimport_options_init.cpp b/src/mongo/tools/mongoimport_options_init.cpp
new file mode 100644
index 00000000000..054f1595c1b
--- /dev/null
+++ b/src/mongo/tools/mongoimport_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongoimport_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoImportOptions)(InitializerContext* context) {
+ return addMongoImportOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoImportOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoImportOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoImportOptions)(InitializerContext* context) {
+ Status ret = storeMongoImportOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongoimport_options_test.cpp b/src/mongo/tools/mongoimport_options_test.cpp
new file mode 100644
index 00000000000..c3dabaade50
--- /dev/null
+++ b/src/mongo/tools/mongoimport_options_test.cpp
@@ -0,0 +1,440 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongoimport_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoImportOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fields") {
+ ASSERT_EQUALS(iterator->_singleName, "fields,f");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "comma separated list of field names e.g. -f name,age");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "fieldFile") {
+ ASSERT_EQUALS(iterator->_singleName, "fieldFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "file with field names - 1 per line");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ignoreBlanks") {
+ ASSERT_EQUALS(iterator->_singleName, "ignoreBlanks");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "if given, empty fields in csv and tsv will be ignored");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "type") {
+ ASSERT_EQUALS(iterator->_singleName, "type");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "type of file to import. default: json (json,csv,tsv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "file") {
+ ASSERT_EQUALS(iterator->_singleName, "file");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "file to import from; if not specified stdin is used");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "drop") {
+ ASSERT_EQUALS(iterator->_singleName, "drop");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "drop collection first ");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "headerline") {
+ ASSERT_EQUALS(iterator->_singleName, "headerline");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "first line in input file is a header (CSV and TSV only)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "upsert") {
+ ASSERT_EQUALS(iterator->_singleName, "upsert");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "insert or update objects that already exist");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "upsertFields") {
+ ASSERT_EQUALS(iterator->_singleName, "upsertFields");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "comma-separated fields for the query part of the upsert. You should make sure this is indexed");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "stopOnError") {
+ ASSERT_EQUALS(iterator->_singleName, "stopOnError");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "stop importing at first error rather than continuing");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "jsonArray") {
+ ASSERT_EQUALS(iterator->_singleName, "jsonArray");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "load a json array, not one item per line. Currently limited to 16MB.");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noimport") {
+ ASSERT_EQUALS(iterator->_singleName, "noimport");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't actually import. useful for benchmarking parser");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongooplog_options.cpp b/src/mongo/tools/mongooplog_options.cpp
index 3292436e4b4..bfac312efcf 100644
--- a/src/mongo/tools/mongooplog_options.cpp
+++ b/src/mongo/tools/mongooplog_options.cpp
@@ -18,7 +18,6 @@
#include "mongo/base/status.h"
#include "mongo/util/log.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -101,29 +100,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoOplogOptions)(InitializerContext* context) {
- return addMongoOplogOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoOplogOptions)(InitializerContext* context) {
- if (handlePreValidationMongoOplogOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoOplogOptions)(InitializerContext* context) {
- Status ret = storeMongoOplogOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongooplog_options_init.cpp b/src/mongo/tools/mongooplog_options_init.cpp
new file mode 100644
index 00000000000..85685872ce7
--- /dev/null
+++ b/src/mongo/tools/mongooplog_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongooplog_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoOplogOptions)(InitializerContext* context) {
+ return addMongoOplogOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoOplogOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoOplogOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoOplogOptions)(InitializerContext* context) {
+ Status ret = storeMongoOplogOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongooplog_options_test.cpp b/src/mongo/tools/mongooplog_options_test.cpp
new file mode 100644
index 00000000000..bd00a7e6654
--- /dev/null
+++ b/src/mongo/tools/mongooplog_options_test.cpp
@@ -0,0 +1,360 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongooplog_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoOplogOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "seconds") {
+ ASSERT_EQUALS(iterator->_singleName, "seconds,s");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "seconds to go back default:86400");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "from") {
+ ASSERT_EQUALS(iterator->_singleName, "from");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "host to pull from");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "oplogns") {
+ ASSERT_EQUALS(iterator->_singleName, "oplogns");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "ns to pull from");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("local.oplog.rs"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongorestore_options.cpp b/src/mongo/tools/mongorestore_options.cpp
index c1ad0e791f6..dac7a25a927 100644
--- a/src/mongo/tools/mongorestore_options.cpp
+++ b/src/mongo/tools/mongorestore_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongorestore_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -156,29 +155,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoRestoreOptions)(InitializerContext* context) {
- return addMongoRestoreOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoRestoreOptions)(InitializerContext* context) {
- if (handlePreValidationMongoRestoreOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoRestoreOptions)(InitializerContext* context) {
- Status ret = storeMongoRestoreOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongorestore_options_init.cpp b/src/mongo/tools/mongorestore_options_init.cpp
new file mode 100644
index 00000000000..f03c9ea531a
--- /dev/null
+++ b/src/mongo/tools/mongorestore_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongorestore_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoRestoreOptions)(InitializerContext* context) {
+ return addMongoRestoreOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoRestoreOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoRestoreOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoRestoreOptions)(InitializerContext* context) {
+ Status ret = storeMongoRestoreOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongorestore_options_test.cpp b/src/mongo/tools/mongorestore_options_test.cpp
new file mode 100644
index 00000000000..d1b854f86c4
--- /dev/null
+++ b/src/mongo/tools/mongorestore_options_test.cpp
@@ -0,0 +1,442 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongorestore_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoRestoreOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dbpath") {
+ ASSERT_EQUALS(iterator->_singleName, "dbpath");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directly access mongod database files in the given path, instead of connecting to a mongod server - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "directoryperdb") {
+ ASSERT_EQUALS(iterator->_singleName, "directoryperdb");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "each db is in a separate directory (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "journal") {
+ ASSERT_EQUALS(iterator->_singleName, "journal");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable journaling (relevant only if dbpath specified)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "db") {
+ ASSERT_EQUALS(iterator->_singleName, "db,d");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "database to use");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "collection") {
+ ASSERT_EQUALS(iterator->_singleName, "collection,c");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "collection to use (some commands)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "objcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "objcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "validate object before inserting (default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noobjcheck") {
+ ASSERT_EQUALS(iterator->_singleName, "noobjcheck");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't validate object before inserting");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "filter") {
+ ASSERT_EQUALS(iterator->_singleName, "filter");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "filter to apply before inserting");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "drop") {
+ ASSERT_EQUALS(iterator->_singleName, "drop");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "drop each collection before import");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "oplogReplay") {
+ ASSERT_EQUALS(iterator->_singleName, "oplogReplay");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "replay oplog for point-in-time restore");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "oplogLimit") {
+ ASSERT_EQUALS(iterator->_singleName, "oplogLimit");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "include oplog entries before the provided Timestamp (seconds[:ordinal]) during the oplog replay; the ordinal value is optional");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "keepIndexVersion") {
+ ASSERT_EQUALS(iterator->_singleName, "keepIndexVersion");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't upgrade indexes to newest version");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noOptionsRestore") {
+ ASSERT_EQUALS(iterator->_singleName, "noOptionsRestore");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't restore collection options");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noIndexRestore") {
+ ASSERT_EQUALS(iterator->_singleName, "noIndexRestore");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't restore indexes");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "w") {
+ ASSERT_EQUALS(iterator->_singleName, "w");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "minimum number of replicas per write");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "dir") {
+ ASSERT_EQUALS(iterator->_singleName, "dir");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "directory to restore from");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ moe::Value defaultVal(std::string("dump"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "indexesLast") {
+ ASSERT_EQUALS(iterator->_singleName, "indexesLast");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "wait to add indexes (now default)");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongostat_options.cpp b/src/mongo/tools/mongostat_options.cpp
index b695dd6606d..89a3b11835e 100644
--- a/src/mongo/tools/mongostat_options.cpp
+++ b/src/mongo/tools/mongostat_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongostat_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -164,29 +163,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoStatOptions)(InitializerContext* context) {
- return addMongoStatOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoStatOptions)(InitializerContext* context) {
- if (handlePreValidationMongoStatOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoStatOptions)(InitializerContext* context) {
- Status ret = storeMongoStatOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongostat_options_init.cpp b/src/mongo/tools/mongostat_options_init.cpp
new file mode 100644
index 00000000000..e706f397327
--- /dev/null
+++ b/src/mongo/tools/mongostat_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongostat_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoStatOptions)(InitializerContext* context) {
+ return addMongoStatOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoStatOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoStatOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoStatOptions)(InitializerContext* context) {
+ Status ret = storeMongoStatOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongostat_options_test.cpp b/src/mongo/tools/mongostat_options_test.cpp
new file mode 100644
index 00000000000..a067162c664
--- /dev/null
+++ b/src/mongo/tools/mongostat_options_test.cpp
@@ -0,0 +1,342 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongostat_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoStatOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "noheaders") {
+ ASSERT_EQUALS(iterator->_singleName, "noheaders");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "don't output column names");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "rowcount") {
+ ASSERT_EQUALS(iterator->_singleName, "rowcount,n");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "number of stats lines to print (0 for indefinite)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(0);
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "http") {
+ ASSERT_EQUALS(iterator->_singleName, "http");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use http instead of raw db connection");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "discover") {
+ ASSERT_EQUALS(iterator->_singleName, "discover");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "discover nodes and display stats for all");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "all") {
+ ASSERT_EQUALS(iterator->_singleName, "all");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "all optional fields");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "sleep") {
+ ASSERT_EQUALS(iterator->_singleName, "sleep");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "hidden description");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace
diff --git a/src/mongo/tools/mongotop_options.cpp b/src/mongo/tools/mongotop_options.cpp
index 09af7f47b10..83b9da1320d 100644
--- a/src/mongo/tools/mongotop_options.cpp
+++ b/src/mongo/tools/mongotop_options.cpp
@@ -17,7 +17,6 @@
#include "mongo/tools/mongotop_options.h"
#include "mongo/base/status.h"
-#include "mongo/util/options_parser/startup_option_init.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
@@ -84,29 +83,4 @@ namespace mongo {
return Status::OK();
}
- MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoTopOptions)(InitializerContext* context) {
- return addMongoTopOptions(&moe::startupOptions);
- }
-
- MONGO_STARTUP_OPTIONS_VALIDATE(MongoTopOptions)(InitializerContext* context) {
- if (handlePreValidationMongoTopOptions(moe::startupOptionsParsed)) {
- ::_exit(EXIT_SUCCESS);
- }
- Status ret = moe::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
- }
-
- MONGO_STARTUP_OPTIONS_STORE(MongoTopOptions)(InitializerContext* context) {
- Status ret = storeMongoTopOptions(moe::startupOptionsParsed, context->args());
- if (!ret.isOK()) {
- std::cerr << ret.toString() << std::endl;
- std::cerr << "try '" << context->args()[0] << " --help' for more information"
- << std::endl;
- ::_exit(EXIT_BADOPTIONS);
- }
- return Status::OK();
- }
}
diff --git a/src/mongo/tools/mongotop_options_init.cpp b/src/mongo/tools/mongotop_options_init.cpp
new file mode 100644
index 00000000000..7b4c9961444
--- /dev/null
+++ b/src/mongo/tools/mongotop_options_init.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mongo/tools/mongotop_options.h"
+
+#include "mongo/util/options_parser/startup_option_init.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace mongo {
+ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(MongoTopOptions)(InitializerContext* context) {
+ return addMongoTopOptions(&moe::startupOptions);
+ }
+
+ MONGO_STARTUP_OPTIONS_VALIDATE(MongoTopOptions)(InitializerContext* context) {
+ if (handlePreValidationMongoTopOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
+ }
+ Status ret = moe::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ }
+
+ MONGO_STARTUP_OPTIONS_STORE(MongoTopOptions)(InitializerContext* context) {
+ Status ret = storeMongoTopOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
+ }
+}
diff --git a/src/mongo/tools/mongotop_options_test.cpp b/src/mongo/tools/mongotop_options_test.cpp
new file mode 100644
index 00000000000..55af3e319e5
--- /dev/null
+++ b/src/mongo/tools/mongotop_options_test.cpp
@@ -0,0 +1,305 @@
+/* Copyright 2013 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/tools/mongotop_options.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/options_parser/options_parser.h"
+#include "mongo/util/options_parser/startup_options.h"
+
+namespace {
+
+ namespace moe = ::mongo::optionenvironment;
+
+ TEST(Registration, RegisterAllOptions) {
+
+ moe::OptionSection options;
+
+ ASSERT_OK(::mongo::addMongoTopOptions(&options));
+
+ std::vector<moe::OptionDescription> options_vector;
+ ASSERT_OK(options.getAllOptions(&options_vector));
+
+ for(std::vector<moe::OptionDescription>::const_iterator iterator = options_vector.begin();
+ iterator != options_vector.end(); iterator++) {
+
+ if (iterator->_dottedName == "help") {
+ ASSERT_EQUALS(iterator->_singleName, "help");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "produce help message");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "verbose") {
+ ASSERT_EQUALS(iterator->_singleName, "verbose,v");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "be more verbose (include multiple times for more verbosity e.g. -vvvvv)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "quiet") {
+ ASSERT_EQUALS(iterator->_singleName, "quiet");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "silence all non error diagnostic messages");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "version") {
+ ASSERT_EQUALS(iterator->_singleName, "version");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "print the program's version and exit");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vv") {
+ ASSERT_EQUALS(iterator->_singleName, "vv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "vvvvvvvvvv") {
+ ASSERT_EQUALS(iterator->_singleName, "vvvvvvvvvv");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "verbose");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "host") {
+ ASSERT_EQUALS(iterator->_singleName, "host,h");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "mongo host to connect to ( <set name>/s1,s2 for sets)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "port") {
+ ASSERT_EQUALS(iterator->_singleName, "port");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "server port. Can also use --host hostname:port");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ipv6") {
+ ASSERT_EQUALS(iterator->_singleName, "ipv6");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "enable IPv6 support (disabled by default)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "username") {
+ ASSERT_EQUALS(iterator->_singleName, "username,u");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "username");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "password") {
+ ASSERT_EQUALS(iterator->_singleName, "password,p");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ moe::Value implicitVal(std::string(""));
+ ASSERT_TRUE(iterator->_implicit.equal(implicitVal));
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationDatabase") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationDatabase");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "user source (defaults to dbname)");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string(""));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "authenticationMechanism") {
+ ASSERT_EQUALS(iterator->_singleName, "authenticationMechanism");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "authentication mechanism");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ moe::Value defaultVal(std::string("MONGODB-CR"));
+ ASSERT_TRUE(iterator->_default.equal(defaultVal));
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "locks") {
+ ASSERT_EQUALS(iterator->_singleName, "locks");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use db lock info instead of top");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "sleep") {
+ ASSERT_EQUALS(iterator->_singleName, "sleep");
+ ASSERT_EQUALS(iterator->_type, moe::Int);
+ ASSERT_EQUALS(iterator->_description, "hidden description");
+ ASSERT_EQUALS(iterator->_isVisible, false);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#ifdef MONGO_SSL
+ else if (iterator->_dottedName == "ssl") {
+ ASSERT_EQUALS(iterator->_singleName, "ssl");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "use SSL for all connections");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CAFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCAFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Authority file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "PEM certificate/key file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.PEMKeyPassword") {
+ ASSERT_EQUALS(iterator->_singleName, "sslPEMKeyPassword");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "password for key in PEM file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.CRLFile") {
+ ASSERT_EQUALS(iterator->_singleName, "sslCRLFile");
+ ASSERT_EQUALS(iterator->_type, moe::String);
+ ASSERT_EQUALS(iterator->_description, "Certificate Revocation List file for SSL");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+ else if (iterator->_dottedName == "ssl.FIPSMode") {
+ ASSERT_EQUALS(iterator->_singleName, "sslFIPSMode");
+ ASSERT_EQUALS(iterator->_type, moe::Switch);
+ ASSERT_EQUALS(iterator->_description, "activate FIPS 140-2 mode at startup");
+ ASSERT_EQUALS(iterator->_isVisible, true);
+ ASSERT_TRUE(iterator->_default.isEmpty());
+ ASSERT_TRUE(iterator->_implicit.isEmpty());
+ ASSERT_EQUALS(iterator->_isComposing, false);
+ }
+#endif
+ else {
+ ::mongo::StringBuilder sb;
+ sb << "Found extra option: " << iterator->_dottedName <<
+ " which we did not register";
+ FAIL(sb.str());
+ }
+ }
+ }
+
+} // namespace