mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-29 16:47:28 +01:00
SERVER-643 prevent test failures involving mongobridge, be more careful about potentially reused uris
This commit is contained in:
parent
cd1dfe32b0
commit
3dfbf854da
@ -80,7 +80,12 @@ void intr( int sig ){
|
|||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
void killOps() {
|
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() );
|
auto_ptr< mongo::Scope > scope( mongo::globalScriptEngine->newScope() );
|
||||||
scope->invoke( "function( x ) { killWithUris( x ); }", spec );
|
scope->invoke( "function( x ) { killWithUris( x ); }", spec );
|
||||||
}
|
}
|
||||||
@ -313,6 +318,7 @@ int _main(int argc, char* argv[]) {
|
|||||||
hidden_options.add_options()
|
hidden_options.add_options()
|
||||||
("dbaddress", po::value<string>(), "dbaddress")
|
("dbaddress", po::value<string>(), "dbaddress")
|
||||||
("files", po::value< vector<string> >(), "files")
|
("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);
|
positional_options.add("dbaddress", 1);
|
||||||
@ -360,6 +366,9 @@ int _main(int argc, char* argv[]) {
|
|||||||
if (params.count("quiet")) {
|
if (params.count("quiet")) {
|
||||||
mongo::cmdLine.quiet = true;
|
mongo::cmdLine.quiet = true;
|
||||||
}
|
}
|
||||||
|
if (params.count("nokillop")) {
|
||||||
|
mongo::shellUtils::_nokillop = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* This is a bit confusing, here are the rules:
|
/* This is a bit confusing, here are the rules:
|
||||||
*
|
*
|
||||||
|
@ -431,6 +431,7 @@ namespace mongo {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
BSONObj StartMongoProgram( const BSONObj &a ) {
|
BSONObj StartMongoProgram( const BSONObj &a ) {
|
||||||
|
_nokillop = true;
|
||||||
ProgramRunner r( a );
|
ProgramRunner r( a );
|
||||||
r.start();
|
r.start();
|
||||||
boost::thread t( r );
|
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 ) {
|
void onConnect( DBClientWithCommands &c ) {
|
||||||
|
if ( _nokillop ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
BSONObj info;
|
BSONObj info;
|
||||||
uassert( 13010, "whatsmyuri failed", c.runCommand( "admin", BSON( "whatsmyuri" << 1 ), 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ namespace mongo {
|
|||||||
|
|
||||||
extern std::string _dbConnect;
|
extern std::string _dbConnect;
|
||||||
extern std::string _dbAuth;
|
extern std::string _dbAuth;
|
||||||
extern vector< string > _allMyUris;
|
extern map< const void*, string > _allMyUris;
|
||||||
|
extern bool _nokillop;
|
||||||
|
|
||||||
void RecordMyLocation( const char *_argv0 );
|
void RecordMyLocation( const char *_argv0 );
|
||||||
void installShellUtils( Scope& scope );
|
void installShellUtils( Scope& scope );
|
||||||
|
Loading…
Reference in New Issue
Block a user