summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-12-02 19:34:07 +0000
committerevergreen <evergreen@mongodb.com>2019-12-02 19:34:07 +0000
commit139481dc1a1336b5711e0f4903107008b13d5ff3 (patch)
tree7cbb18ed15cadc12d1b016f2a04a80ec7afd5371
parent74ed36565b863574489ea05fe22ee7d5ec78ab8d (diff)
downloadmongo-139481dc1a1336b5711e0f4903107008b13d5ff3.tar.gz
SERVER-44630 Attach logging init and options to integration tests
-rw-r--r--src/mongo/db/server_options_base.idl6
-rw-r--r--src/mongo/db/server_options_general.idl6
-rw-r--r--src/mongo/embedded/mongoed_main.cpp2
-rw-r--r--src/mongo/unittest/SConscript3
-rw-r--r--src/mongo/unittest/integration_test_main.cpp36
5 files changed, 44 insertions, 9 deletions
diff --git a/src/mongo/db/server_options_base.idl b/src/mongo/db/server_options_base.idl
index db78d3a725b..aa150ec5d08 100644
--- a/src/mongo/db/server_options_base.idl
+++ b/src/mongo/db/server_options_base.idl
@@ -90,12 +90,6 @@ configs:
description: 'Quieter output'
short_name: quiet
arg_vartype: Switch
- 'net.port':
- description:
- expr: 'ServerGlobalParams::getPortSettingHelpText()'
- is_constexpr: false
- short_name: port
- arg_vartype: Int
logpath:
# Cannot roll into systemLog.path because canonicalization also sets systemLog.destination.
description: 'Log file to send write to instead of stdout - has to be a file, not directory'
diff --git a/src/mongo/db/server_options_general.idl b/src/mongo/db/server_options_general.idl
index 2761bb62a94..6aecd07c366 100644
--- a/src/mongo/db/server_options_general.idl
+++ b/src/mongo/db/server_options_general.idl
@@ -69,6 +69,12 @@ configs:
hidden: true
default: 30
+ 'net.port':
+ description:
+ expr: 'ServerGlobalParams::getPortSettingHelpText()'
+ is_constexpr: false
+ short_name: port
+ arg_vartype: Int
'net.ipv6':
description: 'Enable IPv6 support (disabled by default)'
short_name: ipv6
diff --git a/src/mongo/embedded/mongoed_main.cpp b/src/mongo/embedded/mongoed_main.cpp
index c767273a908..0c31a224374 100644
--- a/src/mongo/embedded/mongoed_main.cpp
+++ b/src/mongo/embedded/mongoed_main.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/mongod_options.h"
#include "mongo/db/mongod_options_general_gen.h"
#include "mongo/db/mongod_options_replication_gen.h"
+#include "mongo/db/server_options_general_gen.h"
#include "mongo/db/service_context.h"
#include "mongo/embedded/embedded.h"
#include "mongo/embedded/embedded_options.h"
@@ -110,6 +111,7 @@ int mongoedMain(int argc, char* argv[], char** envp) {
// Adding all options mongod we don't have to maintain a separate set for this executable,
// some will be unused but that's fine as this is just an executable for testing purposes
// anyway.
+ uassertStatusOK(addGeneralServerOptionDefinitions(&startupOptions));
uassertStatusOK(addMongodGeneralOptions(&startupOptions));
uassertStatusOK(addMongodReplicationOptions(&startupOptions));
uassertStatusOK(embedded::addOptions(&startupOptions));
diff --git a/src/mongo/unittest/SConscript b/src/mongo/unittest/SConscript
index e85e031da38..d472bd49bcc 100644
--- a/src/mongo/unittest/SConscript
+++ b/src/mongo/unittest/SConscript
@@ -50,6 +50,9 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/client/connection_string',
+ '$BUILD_DIR/mongo/db/serverinit',
+ '$BUILD_DIR/mongo/db/server_options',
+ '$BUILD_DIR/mongo/db/server_options_base',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/options_parser/options_parser',
'$BUILD_DIR/mongo/util/options_parser/options_parser_init',
diff --git a/src/mongo/unittest/integration_test_main.cpp b/src/mongo/unittest/integration_test_main.cpp
index c446d793414..4c310ce78bf 100644
--- a/src/mongo/unittest/integration_test_main.cpp
+++ b/src/mongo/unittest/integration_test_main.cpp
@@ -37,7 +37,10 @@
#include "mongo/base/initializer.h"
#include "mongo/client/connection_string.h"
+#include "mongo/db/server_options_base.h"
+#include "mongo/db/server_options_helpers.h"
#include "mongo/db/service_context.h"
+#include "mongo/logger/logger.h"
#include "mongo/transport/transport_layer_asio.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
@@ -74,15 +77,32 @@ int main(int argc, char** argv, char** envp) {
quickExit(unittest::Suite::run(std::vector<std::string>(), "", 1));
}
+namespace {
+
namespace moe = mongo::optionenvironment;
+MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default"))
+(InitializerContext* context) {
+ // Integration tests do not fork, however the init graph requires a deliberate initializer that
+ // _could_ fork and here choses not to do so.
+ return Status::OK();
+}
+
+MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(IntegrationTestOptions)(InitializerContext*) {
+ uassertStatusOK(addBaseServerOptions(&moe::startupOptions));
+
+ return Status::OK();
+}
+
MONGO_STARTUP_OPTIONS_VALIDATE(IntegrationTestOptions)(InitializerContext*) {
auto& env = moe::startupOptionsParsed;
auto& opts = moe::startupOptions;
- auto ret = env.validate();
+ if (auto ret = env.validate(); !ret.isOK()) {
+ return ret;
+ }
- if (!ret.isOK()) {
+ if (auto ret = validateBaseOptions(env); !ret.isOK()) {
return ret;
}
@@ -95,7 +115,15 @@ MONGO_STARTUP_OPTIONS_VALIDATE(IntegrationTestOptions)(InitializerContext*) {
}
MONGO_STARTUP_OPTIONS_STORE(IntegrationTestOptions)(InitializerContext*) {
- const auto& env = moe::startupOptionsParsed;
+ auto& env = moe::startupOptionsParsed;
+
+ if (auto ret = canonicalizeBaseOptions(&env); !ret.isOK()) {
+ return ret;
+ }
+
+ if (auto ret = storeBaseOptions(env); !ret.isOK()) {
+ return ret;
+ }
std::string connectionString = env["connectionString"].as<std::string>();
@@ -110,3 +138,5 @@ MONGO_STARTUP_OPTIONS_STORE(IntegrationTestOptions)(InitializerContext*) {
return Status::OK();
}
+
+} // namespace