diff options
author | Spencer T Brody <spencer@10gen.com> | 2012-12-10 19:11:19 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2012-12-14 13:05:54 -0500 |
commit | 12bab3dae57f9ba716f3bdcc059518d50dd80004 (patch) | |
tree | f2478b47d16f0911b36172f476813be57880270c | |
parent | 1c4fb029c1c60459d423f4ad56a1e0841cacdc83 (diff) | |
download | mongo-12bab3dae57f9ba716f3bdcc059518d50dd80004.tar.gz |
SERVER-7122 Put failPoint command behind --enableTestCommands flag instead of --enableFaultInjection flag
-rw-r--r-- | jstests/fail_point/fail_point.js | 21 | ||||
-rw-r--r-- | src/mongo/db/cmdline.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/fail_point_cmd.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/commands/fail_point_cmd.h | 24 | ||||
-rw-r--r-- | src/mongo/db/db.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/server.cpp | 5 |
6 files changed, 7 insertions, 64 deletions
diff --git a/jstests/fail_point/fail_point.js b/jstests/fail_point/fail_point.js index 380fb51d345..42e7b1ebd9c 100644 --- a/jstests/fail_point/fail_point.js +++ b/jstests/fail_point/fail_point.js @@ -60,33 +60,12 @@ var runTest = function(adminDB) { }; var conn = MongoRunner.runMongod({ port: 29000 }); - -// configureFailPoint is only available if run with --enableFaultInjection -assert.commandFailed(conn.getDB('admin').runCommand({ configureFailPoint: 'dummy' })); - -MongoRunner.stopMongod(conn.port); -conn = MongoRunner.runMongod({ enableFaultInjection: '', port: conn.port, verbose: 6 }); - runTest(conn.getDB('admin')); - MongoRunner.stopMongod(conn.port); /////////////////////////////////////////////////////////// // Test mongos var st = new ShardingTest({ shards: 1 }); - -adminDB = st.s.getDB('admin'); - -// configureFailPoint is only available if run with --enableFaultInjection -// Note: mongos asserts when command is not found, unlike mongod -assert.throws(function() { - adminDB.runCommand({ configureFailPoint: 'dummy' }); -}); - -st.stop(); - -st = new ShardingTest({ shards: 1, other: { mongosOptions: { enableFaultInjection: '' }}}); runTest(st.s.getDB('admin')); - st.stop(); diff --git a/src/mongo/db/cmdline.cpp b/src/mongo/db/cmdline.cpp index 9e037975f9d..92c6d8c6f4d 100644 --- a/src/mongo/db/cmdline.cpp +++ b/src/mongo/db/cmdline.cpp @@ -84,8 +84,6 @@ namespace { ("logappend" , "append to logpath instead of over-writing" ) ("pidfilepath", po::value<string>(), "full path to pidfile (if not set, no pidfile is created)") ("keyFile", po::value<string>(), "private key for cluster authentication") - ("enableFaultInjection", "enable the fault injection framework, for debugging." - " DO NOT USE IN PRODUCTION") ("setParameter", po::value< std::vector<std::string> >()->composing(), "Set a configurable parameter") #ifndef _WIN32 diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp index 53d8f57db4b..c4d653747e8 100644 --- a/src/mongo/db/commands/fail_point_cmd.cpp +++ b/src/mongo/db/commands/fail_point_cmd.cpp @@ -14,10 +14,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "mongo/db/commands/fail_point_cmd.h" - #include <vector> +#include "mongo/base/init.h" #include "mongo/db/auth/action_set.h" #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/privilege.h" @@ -153,10 +152,11 @@ namespace mongo { return true; } }; - - scoped_ptr<FaultInjectCmd> _faultInjectCmd(NULL); - - void enableFailPointCmd() { - _faultInjectCmd.reset(new FaultInjectCmd); + MONGO_INITIALIZER(RegisterFaultInjectCmd)(InitializerContext* context) { + if (Command::testCommandsEnabled) { + // Leaked intentionally: a Command registers itself when constructed. + new FaultInjectCmd(); + } + return Status::OK(); } } diff --git a/src/mongo/db/commands/fail_point_cmd.h b/src/mongo/db/commands/fail_point_cmd.h deleted file mode 100644 index e485da10608..00000000000 --- a/src/mongo/db/commands/fail_point_cmd.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2012 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/>. - */ - -namespace mongo { - /** - * Installs the injectFault command. - * - * Note: not thread-safe - */ - void enableFailPointCmd(); -} diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 4e90e9a1964..b1008e21b22 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -27,7 +27,6 @@ #include "mongo/db/clientcursor.h" #include "mongo/db/cmdline.h" #include "mongo/db/commands/server_status.h" -#include "mongo/db/commands/fail_point_cmd.h" #include "mongo/db/d_concurrency.h" #include "mongo/db/d_globals.h" #include "mongo/db/db.h" @@ -1188,10 +1187,6 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) { log() << endl; } - if (params.count("enableFaultInjection")) { - enableFailPointCmd(); - } - Module::configAll(params); #ifdef _WIN32 diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index 265a97682c8..f15c87f3eb4 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -21,7 +21,6 @@ #include <boost/thread/thread.hpp> #include "mongo/base/initializer.h" -#include "mongo/db/commands/fail_point_cmd.h" #include "mongo/db/initialize_server_global_state.h" #include "../util/net/message.h" #include "../util/startup_test.h" @@ -429,10 +428,6 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) { warning() << "running with 1 config server should be done only for testing purposes and is not recommended for production" << endl; } - if (params.count("enableFaultInjection")) { - enableFailPointCmd(); - } - _isUpgradeSwitchSet = params.count("upgrade"); #if defined(_WIN32) |