diff options
author | Aaron <aaron@10gen.com> | 2010-02-22 12:45:58 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-02-22 12:45:58 -0800 |
commit | 3dfbf854dafd3b656c430339eac37db754827b73 (patch) | |
tree | f40cb32112ed1d6c798518cf9b9742eabd6c85e7 /shell | |
parent | cd1dfe32b0efe7b0faa1db0c8ecc5d9528eac177 (diff) | |
download | mongo-3dfbf854dafd3b656c430339eac37db754827b73.tar.gz |
SERVER-643 prevent test failures involving mongobridge, be more careful about potentially reused uris
Diffstat (limited to 'shell')
-rw-r--r-- | shell/dbshell.cpp | 13 | ||||
-rw-r--r-- | shell/utils.cpp | 11 | ||||
-rw-r--r-- | shell/utils.h | 3 |
3 files changed, 22 insertions, 5 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index 0013974a0bd..767c4d2ae91 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -80,7 +80,12 @@ void intr( int sig ){ #if !defined(_WIN32) void killOps() { - mongo::BSONObj spec = BSON( "" << mongo::shellUtils::_allMyUris ); + if ( mongo::shellUtils::_nokillop ) + return; + vector< string > uris; + for( map< const void*, string >::iterator i = mongo::shellUtils::_allMyUris.begin(); i != mongo::shellUtils::_allMyUris.end(); ++i ) + uris.push_back( i->second ); + mongo::BSONObj spec = BSON( "" << uris ); auto_ptr< mongo::Scope > scope( mongo::globalScriptEngine->newScope() ); scope->invoke( "function( x ) { killWithUris( x ); }", spec ); } @@ -313,6 +318,7 @@ int _main(int argc, char* argv[]) { hidden_options.add_options() ("dbaddress", po::value<string>(), "dbaddress") ("files", po::value< vector<string> >(), "files") + ("nokillop", "nokillop") // for testing, kill op will also be disabled automatically if the tests starts a mongo program ; positional_options.add("dbaddress", 1); @@ -360,7 +366,10 @@ int _main(int argc, char* argv[]) { if (params.count("quiet")) { mongo::cmdLine.quiet = true; } - + if (params.count("nokillop")) { + mongo::shellUtils::_nokillop = true; + } + /* This is a bit confusing, here are the rules: * * if nodb is set then all positional parameters are files diff --git a/shell/utils.cpp b/shell/utils.cpp index ef614e30a10..38d3b620860 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -431,6 +431,7 @@ namespace mongo { #endif } BSONObj StartMongoProgram( const BSONObj &a ) { + _nokillop = true; ProgramRunner r( a ); r.start(); boost::thread t( r ); @@ -689,11 +690,17 @@ namespace mongo { } } - vector< string > _allMyUris; + map< const void*, string > _allMyUris; + bool _nokillop = false; void onConnect( DBClientWithCommands &c ) { + if ( _nokillop ) { + return; + } BSONObj info; uassert( 13010, "whatsmyuri failed", c.runCommand( "admin", BSON( "whatsmyuri" << 1 ), info ) ); - _allMyUris.push_back( info[ "you" ].str() ); + // There's no way to explicitly disconnect a DBClientConnection, but we might allocate + // a new uri on automatic reconnect. So just store one uri per connection. + _allMyUris[ &c ] = info[ "you" ].str(); } } } diff --git a/shell/utils.h b/shell/utils.h index b4fea4226ba..a2d420d1518 100644 --- a/shell/utils.h +++ b/shell/utils.h @@ -26,7 +26,8 @@ namespace mongo { extern std::string _dbConnect; extern std::string _dbAuth; - extern vector< string > _allMyUris; + extern map< const void*, string > _allMyUris; + extern bool _nokillop; void RecordMyLocation( const char *_argv0 ); void installShellUtils( Scope& scope ); |