0
0
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:
Eliot Horowitz 2009-04-03 14:28:33 -04:00
commit df3daad26f
2 changed files with 91 additions and 1 deletions

View File

@ -325,7 +325,7 @@ namespace mongo {
int was = cmdObj.getIntField("i_was");
string myname = cmdObj.getStringField("your_name");
if ( myname.empty() || was < -1 ) {
if ( myname.empty() || was < -3 ) {
errmsg = "your_name/i_was not specified";
return false;
}

90
jstests/repl/pair3.js Normal file
View File

@ -0,0 +1,90 @@
// test arbitration
var baseName = "jstests_pair3test";
ismaster = function( n ) {
var im = n.getDB( "admin" ).runCommand( { "ismaster" : 1 } );
print( "ismaster: " + tojson( im ) );
assert( im, "command ismaster failed" );
return im.ismaster;
}
connect = function() {
startMongoProgram( "mongobridge", "--port", alPort, "--dest", "localhost:" + aPort );
startMongoProgram( "mongobridge", "--port", arPort, "--dest", "localhost:" + aPort );
startMongoProgram( "mongobridge", "--port", lpPort, "--dest", "localhost:" + lPort );
startMongoProgram( "mongobridge", "--port", rpPort, "--dest", "localhost:" + rPort );
}
doTest = function() {
ports = allocatePorts( 7 );
aPort = ports[ 0 ];
alPort = ports[ 1 ];
arPort = ports[ 2 ];
lPort = ports[ 3 ];
lpPort = ports[ 4 ];
rPort = ports[ 5 ];
rpPort = ports[ 6 ];
connect();
a = startMongod( "--port", aPort, "--dbpath", "/data/db/" + baseName + "-arbiter", "--nohttpinterface" );
l = startMongod( "--port", lPort, "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + rpPort, "127.0.0.1:" + alPort, "--oplogSize", "1", "--nohttpinterface" );
r = startMongod( "--port", rPort, "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + lpPort, "127.0.0.1:" + arPort, "--oplogSize", "1", "--nohttpinterface" );
// normal startup
assert.soon( function() {
am = ismaster( a );
lm = ismaster( l );
rm = ismaster( r );
assert( am == 1, "am value invalid" );
assert( lm == -1 || lm == 0, "lm value invalid" );
assert( rm == -1 || rm == 0 || rm == 1, "rm value invalid" );
return ( lm == 0 && rm == 1 );
} );
// disconnect l (slave)
stopMongoProgram( alPort );
stopMongoProgram( lpPort );
stopMongoProgram( rpPort );
assert.soon( function() {
lm = ismaster( l );
rm = ismaster( r );
assert( lm == 0 || lm == -3, "lm value invalid" );
assert( rm == 1, "rm value invalid" );
return ( lm == -3 );
} );
// disconnect r ( master )
stopMongoProgram( arPort );
assert.soon( function() {
rm = ismaster( r );
assert( rm == 1 || rm == -3, "rm value invalid" );
return ( rm == -3 );
} );
// reconnect
connect();
assert.soon( function() {
lm = ismaster( l );
rm = ismaster( r );
assert( lm == -3 || lm == 0, "lm value invalid" );
assert( rm == -3 || rm == 1, "rm value invalid" );
return ( lm == 0 && rm == 1 );
} );
}
doTest();