summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-02-12 20:37:10 +0000
committerSara Golemon <sara.golemon@mongodb.com>2019-02-14 19:29:22 +0000
commit68f0de6d122b4f70e8eb2be584b1f448d07f2945 (patch)
treeeb84e107eae1dd5fc5bcab7f800312164136027b /src
parent7f3cdb660bb93d6824e00ca5d05b47f2b6ac3ee2 (diff)
downloadmongo-68f0de6d122b4f70e8eb2be584b1f448d07f2945.tar.gz
SERVER-38574 Allow declaring IDL based configs without auto-registering
Diffstat (limited to 'src')
-rw-r--r--src/mongo/idl/SConscript1
-rw-r--r--src/mongo/idl/config_option_no_init_test.idl44
-rw-r--r--src/mongo/idl/config_option_test.cpp17
-rw-r--r--src/mongo/idl/config_option_test.idl2
-rw-r--r--src/mongo/util/net/ssl_options_server.idl2
5 files changed, 64 insertions, 2 deletions
diff --git a/src/mongo/idl/SConscript b/src/mongo/idl/SConscript
index 81625467b21..f320ffdff3c 100644
--- a/src/mongo/idl/SConscript
+++ b/src/mongo/idl/SConscript
@@ -61,6 +61,7 @@ env.CppUnitTest(
target='idl_config_option_test',
source=[
'config_option_test.cpp',
+ env.Idlc('config_option_no_init_test.idl')[0],
env.Idlc('config_option_test.idl')[0],
],
LIBDEPS=[
diff --git a/src/mongo/idl/config_option_no_init_test.idl b/src/mongo/idl/config_option_no_init_test.idl
new file mode 100644
index 00000000000..5e922ed654c
--- /dev/null
+++ b/src/mongo/idl/config_option_no_init_test.idl
@@ -0,0 +1,44 @@
+# Copyright (C) 2018-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# 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
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# 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 Server Side 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.
+#
+
+global:
+ cpp_namespace: "mongo::test"
+ configs:
+ source: [ cli, ini, yaml ]
+ initializer:
+ register: addIDLTestConfigs
+ store: storeIDLTestConfigs
+
+configs:
+ "test.config.noInit.opt1":
+ description: "Basic option using explicit call register/store"
+ short_name: testConfigNoInitOpt1
+ arg_vartype: String
+ cpp_vartype: std::string
+ cpp_varname: gTestConfigNoInitOpt1
+
diff --git a/src/mongo/idl/config_option_test.cpp b/src/mongo/idl/config_option_test.cpp
index 640bf1b6ef3..9e94434da85 100644
--- a/src/mongo/idl/config_option_test.cpp
+++ b/src/mongo/idl/config_option_test.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
+#include "mongo/idl/config_option_no_init_test_gen.h"
#include "mongo/idl/config_option_test_gen.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/cmdline_utils/censor_cmdline_test.h"
@@ -614,6 +615,22 @@ TEST(ConfigOption, Opt17) {
ASSERT_OPTION_SET<std::int32_t>(okParse, "test.config.opt17", kTestConfigOpt17Minimum);
}
+TEST(ConfigOptionNoInit, Opt1) {
+ moe::OptionSection options("Options");
+ ASSERT_OK(addIDLTestConfigs(&options));
+
+ const std::vector<std::string> argv({
+ "mongod", "--testConfigNoInitOpt1", "Hello",
+ });
+ moe::Environment parsed;
+ ASSERT_OK(moe::OptionsParser().run(options, argv, {}, &parsed));
+ ASSERT_OK(parsed.validate());
+ ASSERT_OK(storeIDLTestConfigs(parsed));
+
+ ASSERT_OPTION_SET<std::string>(parsed, "test.config.noInit.opt1", "Hello");
+ ASSERT_EQ(gTestConfigNoInitOpt1, "Hello");
+}
+
} // namespace
} // namespace test
} // namespace mongo
diff --git a/src/mongo/idl/config_option_test.idl b/src/mongo/idl/config_option_test.idl
index d5eaf220195..325f5eec321 100644
--- a/src/mongo/idl/config_option_test.idl
+++ b/src/mongo/idl/config_option_test.idl
@@ -32,7 +32,7 @@ global:
- "mongo/idl/server_parameter_with_storage_test.h"
- "mongo/idl/config_option_test.h"
configs:
- initializer_name: TestConfigs
+ initializer: TestConfigs
configs:
"test.config.opt1":
diff --git a/src/mongo/util/net/ssl_options_server.idl b/src/mongo/util/net/ssl_options_server.idl
index 6045db806fe..1b38966a0b1 100644
--- a/src/mongo/util/net/ssl_options_server.idl
+++ b/src/mongo/util/net/ssl_options_server.idl
@@ -35,7 +35,7 @@ global:
section: "TLS Options"
source: [ yaml, cli, ini ]
# Name these initializers so they can be invoked from ssl_options_test.cpp
- initializer_name: SSLServerOptionsIDL
+ initializer: SSLServerOptionsIDL
imports:
- "mongo/idl/basic_types.idl"