mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
6a148e1a88
@ -6,7 +6,10 @@ a = s._connections[0].getDB( "admin" );
|
||||
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).ok == 0 );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : "a" } ).ok == 0 );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 1 );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , authoritative : true } ).ok == 0 );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 0 , "should have failed b/c no auth" );
|
||||
|
||||
assert.commandWorked( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 , authoritative : true } ) , "should have worked" );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : "a" , version : 2 } ).ok == 0 );
|
||||
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 1 );
|
||||
|
@ -9,7 +9,7 @@ a = s._connections[0].getDB( "admin" );
|
||||
assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).mine.i == 0 );
|
||||
assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).global.i == 0 );
|
||||
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 1 );
|
||||
assert( a.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 , authoritative : true } ).ok == 1 );
|
||||
|
||||
assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).mine.i == 2 );
|
||||
assert( a.runCommand( { "getShardVersion" : "alleyinsider.foo" , configdb : s._configDB } ).global.i == 2 );
|
||||
|
@ -73,6 +73,11 @@ namespace mongo {
|
||||
}
|
||||
|
||||
if ( shardConfigServer.size() == 0 ){
|
||||
if ( ! cmdObj.getBoolField( "authoritative" ) ){
|
||||
result.appendBool( "need_authoritative" , true );
|
||||
errmsg = "first setShardVersion";
|
||||
return false;
|
||||
}
|
||||
shardConfigServer = configdb;
|
||||
}
|
||||
else if ( shardConfigServer != configdb ){
|
||||
@ -125,6 +130,14 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( myVersion == 0 && ! cmdObj.getBoolField( "authoritative" ) ){
|
||||
// need authoritative for first look
|
||||
result.appendBool( "need_authoritative" , true );
|
||||
result.append( "ns" , ns );
|
||||
errmsg = "first time for this ns";
|
||||
return false;
|
||||
}
|
||||
|
||||
result.appendTimestamp( "oldVersion" , oldVersion );
|
||||
oldVersion = version;
|
||||
myVersion = version;
|
||||
|
@ -47,6 +47,20 @@ assert.throws = function( func , params , msg ){
|
||||
throw "did not throw exception: " + msg ;
|
||||
}
|
||||
|
||||
assert.commandWorked = function( res , msg ){
|
||||
if ( res.ok == 1 )
|
||||
return;
|
||||
|
||||
throw "command failed: " + tojson( res ) + " : " + msg;
|
||||
}
|
||||
|
||||
assert.commandFailed = function( res , msg ){
|
||||
if ( res.ok == 0 )
|
||||
return;
|
||||
|
||||
throw "command worked when it should have failed: " + tojson( res ) + " : " + msg;
|
||||
}
|
||||
|
||||
Object.extend = function( dst , src ){
|
||||
for ( var k in src ){
|
||||
dst[k] = src[k];
|
||||
|
Loading…
Reference in New Issue
Block a user