mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-85 converted repl tests to use new frameworks and small files-
This commit is contained in:
parent
79febf1616
commit
378e3ee276
@ -12,11 +12,10 @@ soonCount = function( count ) {
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl1tests" );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
s = rt.start( false );
|
||||
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
@ -28,19 +27,19 @@ doTest = function( signal ) {
|
||||
assert.eq( 1, as.find( { i: 0 } ).count() );
|
||||
assert.eq( 1, as.find( { i: 999 } ).count() );
|
||||
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
rt.stop( false, signal );
|
||||
|
||||
for( i = 1000; i < 1010; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i } );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = rt.start( false, null, true );
|
||||
soonCount( 1010 );
|
||||
as = s.getDB( baseName ).a
|
||||
assert.eq( 1, as.find( { i: 1009 } ).count() );
|
||||
|
||||
stopMongod( ports[ 0 ], signal );
|
||||
rt.stop( true, signal );
|
||||
|
||||
m = startMongoProgram( "mongod", "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true, null, true );
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
for( i = 1010; i < 1020; ++i )
|
||||
@ -49,7 +48,7 @@ doTest = function( signal ) {
|
||||
assert.soon( function() { return as.find().count() == 1020; } );
|
||||
assert.eq( 1, as.find( { i: 1019 } ).count() );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
rt.stop();
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
|
@ -12,8 +12,8 @@ doTest = function( signal ) {
|
||||
|
||||
var rt = new ReplTest( "repl2tests" );
|
||||
|
||||
// spec small oplog to make slave get out of sync
|
||||
m = rt.start( true , { oplogSize : "1" } );
|
||||
// implicit small oplog makes slave get out of sync
|
||||
m = rt.start( true );
|
||||
s = rt.start( false );
|
||||
|
||||
am = m.getDB("foo").a
|
||||
|
@ -5,30 +5,29 @@ var baseName = "jstests_repl3test";
|
||||
soonCount = function( count ) {
|
||||
assert.soon( function() {
|
||||
// print( "check count" );
|
||||
// print( "count: " + s.getDB( baseName ).z.find().count() );
|
||||
// print( "count: " + s.getDB( baseName ).z.find().count() + ", expected: " + count );
|
||||
return s.getDB( baseName ).a.find().count() == count;
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl3tests" );
|
||||
|
||||
// spec small oplog to make slave get out of sync
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
s = rt.start( false );
|
||||
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
am.save( { _id: new ObjectId() } );
|
||||
soonCount( 1 );
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
rt.stop( false, signal );
|
||||
|
||||
big = new Array( 2000 ).toString();
|
||||
for( i = 0; i < 1000; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i, b: big } );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--autoresync", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
|
||||
s = rt.start( false, { autoresync: null }, true );
|
||||
|
||||
// after SyncException, mongod waits 10 secs.
|
||||
sleep( 15000 );
|
||||
@ -39,10 +38,9 @@ doTest = function( signal ) {
|
||||
assert.eq( 1, as.find( { i: 0 } ).count() );
|
||||
assert.eq( 1, as.find( { i: 999 } ).count() );
|
||||
|
||||
assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
assert.commandFailed( s.getDB( "admin" ).runCommand( { "resync" : 1 } ) );
|
||||
|
||||
rt.stop();
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Test replication 'only' mode
|
||||
|
||||
var baseName = "jstests_repl4test";
|
||||
|
||||
soonCount = function( db, coll, count ) {
|
||||
assert.soon( function() {
|
||||
return s.getDB( db )[ coll ].find().count() == count;
|
||||
@ -10,11 +8,10 @@ soonCount = function( db, coll, count ) {
|
||||
|
||||
doTest = function() {
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl4tests" );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--only", "c", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
s = rt.start( false, { only: "c" } );
|
||||
|
||||
cm = m.getDB( "c" ).c
|
||||
bm = m.getDB( "b" ).b
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Test auto reclone after failed initial clone
|
||||
|
||||
var baseName = "jstests_repl5test";
|
||||
|
||||
soonCountAtLeast = function( db, coll, count ) {
|
||||
assert.soon( function() {
|
||||
// print( "count: " + s.getDB( db )[ coll ].find().count() );
|
||||
@ -11,24 +9,23 @@ soonCountAtLeast = function( db, coll, count ) {
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl5tests" );
|
||||
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
|
||||
ma = m.getDB( "a" ).a;
|
||||
for( i = 0; i < 10000; ++i )
|
||||
ma.save( { i:i } );
|
||||
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = rt.start( false );
|
||||
soonCountAtLeast( "a", "a", 1 );
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
rt.stop( false, signal );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = rt.start( false, null, true );
|
||||
sleep( 1000 );
|
||||
soonCountAtLeast( "a", "a", 10000 );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
|
||||
rt.stop();
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
|
@ -10,12 +10,12 @@ soonCount = function( m, count ) {
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 3 );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s1 = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s2 = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
ms1 = new ReplTest( "repl6tests-1" );
|
||||
ms2 = new ReplTest( "repl6tests-2", ms1.ports[ 0 ] );
|
||||
|
||||
m = ms1.start( true );
|
||||
s1 = ms1.start( false );
|
||||
s2 = ms2.start( false );
|
||||
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
@ -35,20 +35,20 @@ doTest = function( signal ) {
|
||||
as = s2.getDB( baseName ).a
|
||||
check( as );
|
||||
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
stopMongod( ports[ 2 ], signal );
|
||||
ms1.stop( false, signal );
|
||||
ms2.stop( false, signal );
|
||||
|
||||
for( i = 1000; i < 1010; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i } );
|
||||
|
||||
s1 = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
|
||||
s1 = ms1.start( false, null, true );
|
||||
soonCount( s1, 1010 );
|
||||
as = s1.getDB( baseName ).a
|
||||
assert.eq( 1, as.find( { i: 1009 } ).count() );
|
||||
|
||||
stopMongod( ports[ 0 ], signal );
|
||||
|
||||
m = startMongoProgram( "mongod", "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
|
||||
ms1.stop( true, signal );
|
||||
|
||||
m = ms1.start( true, null, true );
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
for( i = 1010; i < 1020; ++i )
|
||||
@ -57,14 +57,14 @@ doTest = function( signal ) {
|
||||
soonCount( s1, 1020 );
|
||||
assert.eq( 1, as.find( { i: 1019 } ).count() );
|
||||
|
||||
s2 = startMongoProgram( "mongod", "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s2 = ms2.start( false, null, true );
|
||||
soonCount( s2, 1020 );
|
||||
as = s2.getDB( baseName ).a
|
||||
assert.eq( 1, as.find( { i: 1009 } ).count() );
|
||||
assert.eq( 1, as.find( { i: 1019 } ).count() );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
|
||||
ms1.stop();
|
||||
ms2.stop( false );
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
|
@ -1,27 +1,24 @@
|
||||
// Test persistence of list of dbs to add.
|
||||
|
||||
var baseName = "jstests_repl7test";
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl7tests" );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
|
||||
for( n = "a"; n != "aaaaa"; n += "a" ) {
|
||||
m.getDB( n ).a.save( {x:1} );
|
||||
}
|
||||
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = rt.start( false );
|
||||
|
||||
assert.soon( function() {
|
||||
return -1 != s.getDBNames().indexOf( "aa" );
|
||||
}, "aa timeout", 60000, 1000 );
|
||||
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
rt.stop( false, signal );
|
||||
|
||||
s = rt.start( false, null, signal );
|
||||
|
||||
assert.soon( function() {
|
||||
for( n = "a"; n != "aaaaa"; n += "a" ) {
|
||||
@ -41,8 +38,7 @@ doTest = function( signal ) {
|
||||
|
||||
sleep( 300 );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
|
||||
rt.stop();
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
baseName = "jstests_repl_repl8";
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl8tests" );
|
||||
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
|
||||
m.getDB( baseName ).createCollection( "first", {capped:true,size:1000} );
|
||||
assert( m.getDB( baseName ).getCollection( "first" ).isCapped() );
|
||||
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = rt.start( false );
|
||||
|
||||
assert.soon( function() { return s.getDB( baseName ).getCollection( "first" ).isCapped(); } );
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
baseName = "jstests_repl_repl9";
|
||||
|
||||
ports = allocatePorts( 2 );
|
||||
rt = new ReplTest( "repl9tests" );
|
||||
|
||||
m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
m = rt.start( true );
|
||||
s = rt.start( false );
|
||||
|
||||
admin = m.getDB( "admin" );
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// test replace peer
|
||||
// test replace peer on master
|
||||
|
||||
var baseName = "jstests_replacepeer1test";
|
||||
|
||||
@ -32,51 +32,36 @@ doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 4 );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
r = startMongod( "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
a = new MongodRunner( ports[ 0 ], "/data/db/" + baseName + "-arbiter" );
|
||||
l = new MongodRunner( ports[ 1 ], "/data/db/" + baseName + "-left", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
r = new MongodRunner( ports[ 3 ], "/data/db/" + baseName + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
|
||||
assert.soon( function() {
|
||||
am = ismaster( a );
|
||||
lm = ismaster( l );
|
||||
rm = ismaster( r );
|
||||
rp = new ReplPair( l, r, a );
|
||||
rp.start();
|
||||
rp.waitForSteadyState( [ 1, 0 ], rp.right().host );
|
||||
|
||||
checkWrite( rp.master(), rp.slave() );
|
||||
|
||||
assert( am == 1 );
|
||||
assert( lm == -1 || lm == 0 );
|
||||
assert( rm == -1 || rm == 0 || rm == 1 );
|
||||
rp.killNode( rp.slave(), signal );
|
||||
|
||||
return ( lm == 0 && rm == 1 );
|
||||
} );
|
||||
writeOne( rp.master() );
|
||||
|
||||
checkWrite( r, l );
|
||||
assert.commandWorked( rp.master().getDB( "admin" ).runCommand( {replacepeer:1} ) );
|
||||
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
rp.killNode( rp.master(), signal );
|
||||
rp.killNode( rp.arbiter(), signal );
|
||||
|
||||
o = new MongodRunner( ports[ 2 ], "/data/db/" + baseName + "-left", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
r = new MongodRunner( ports[ 3 ], "/data/db/" + baseName + "-right", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
|
||||
writeOne( r );
|
||||
rp = new ReplPair( o, r, a );
|
||||
resetDbpath( "/data/db/" + baseName + "-left" );
|
||||
rp.start( true );
|
||||
rp.waitForSteadyState( [ 1, 0 ], rp.right().host );
|
||||
|
||||
assert.eq( 1, r.getDB( "admin" ).runCommand( {replacepeer:1} ).ok );
|
||||
|
||||
stopMongod( ports[ 3 ], signal );
|
||||
|
||||
l = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
r = startMongoProgram( "mongod", "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 2 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
|
||||
assert.soon( function() {
|
||||
am = ismaster( a );
|
||||
lm = ismaster( l );
|
||||
rm = ismaster( r );
|
||||
|
||||
assert( am == 1 );
|
||||
assert( lm == -1 || lm == 0 );
|
||||
assert( rm == -1 || rm == 0 || rm == 1 );
|
||||
|
||||
return ( lm == 0 && rm == 1 );
|
||||
} );
|
||||
|
||||
checkWrite( r, l );
|
||||
l.setSlaveOk();
|
||||
assert.eq( 3, l.getDB( baseName ).z.find().toArray().length );
|
||||
checkWrite( rp.master(), rp.slave() );
|
||||
rp.slave().setSlaveOk();
|
||||
assert.eq( 3, rp.slave().getDB( baseName ).z.find().toArray().length );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// test replace peer
|
||||
// test replace peer on slave
|
||||
|
||||
var baseName = "jstests_replacepeer2test";
|
||||
|
||||
@ -32,54 +32,37 @@ doTest = function( signal ) {
|
||||
|
||||
ports = allocatePorts( 4 );
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
r = startMongod( "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
a = new MongodRunner( ports[ 0 ], "/data/db/" + baseName + "-arbiter" );
|
||||
l = new MongodRunner( ports[ 1 ], "/data/db/" + baseName + "-left", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
r = new MongodRunner( ports[ 3 ], "/data/db/" + baseName + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
|
||||
rp = new ReplPair( l, r, a );
|
||||
rp.start();
|
||||
rp.waitForSteadyState( [ 1, 0 ], rp.right().host );
|
||||
|
||||
assert.soon( function() {
|
||||
am = ismaster( a );
|
||||
lm = ismaster( l );
|
||||
rm = ismaster( r );
|
||||
|
||||
assert( am == 1 );
|
||||
assert( lm == -1 || lm == 0 );
|
||||
assert( rm == -1 || rm == 0 || rm == 1 );
|
||||
|
||||
return ( lm == 0 && rm == 1 );
|
||||
} );
|
||||
|
||||
checkWrite( r, l );
|
||||
checkWrite( rp.master(), rp.slave() );
|
||||
|
||||
// allow slave to finish initial sync
|
||||
assert.soon( function() { return 1 == l.getDB( "admin" ).runCommand( {replacepeer:1} ).ok; } );
|
||||
assert.soon( function() { return 1 == rp.slave().getDB( "admin" ).runCommand( {replacepeer:1} ).ok; } );
|
||||
|
||||
// Should not be saved to l.
|
||||
writeOne( r );
|
||||
// Should not be saved to slave.
|
||||
writeOne( rp.master() );
|
||||
// Make sure there would be enough time to save to l if we hadn't called replacepeer.
|
||||
sleep( 10000 );
|
||||
|
||||
stopMongod( ports[ 3 ], signal );
|
||||
stopMongod( ports[ 1 ], signal );
|
||||
ports.forEach( function( x ) { stopMongod( x, signal ); } );
|
||||
|
||||
l = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
r = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "--arbiter", "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
l = new MongodRunner( ports[ 1 ], "/data/db/" + baseName + "-left", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
o = new MongodRunner( ports[ 2 ], "/data/db/" + baseName + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ] );
|
||||
|
||||
assert.soon( function() {
|
||||
am = ismaster( a );
|
||||
lm = ismaster( l );
|
||||
rm = ismaster( r );
|
||||
|
||||
assert( am == 1 );
|
||||
assert( lm == -1 || lm == 0 || lm == 1 );
|
||||
assert( rm == -1 || rm == 0 );
|
||||
|
||||
return ( lm == 1 && rm == 0 );
|
||||
} );
|
||||
|
||||
checkWrite( l, r );
|
||||
r.setSlaveOk();
|
||||
assert.eq( 2, r.getDB( baseName ).z.find().toArray().length );
|
||||
rp = new ReplPair( l, o, a );
|
||||
resetDbpath( "/data/db/" + baseName + "-right" );
|
||||
rp.start( true );
|
||||
rp.waitForSteadyState( [ 1, 0 ], rp.left().host );
|
||||
|
||||
checkWrite( rp.master(), rp.slave() );
|
||||
rp.slave().setSlaveOk();
|
||||
assert.eq( 2, rp.slave().getDB( baseName ).z.find().toArray().length );
|
||||
|
||||
ports.forEach( function( x ) { stopMongod( x ); } );
|
||||
|
||||
|
@ -10,15 +10,9 @@
|
||||
9302D9930F30AB8C00DFA4EF /* collection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = collection.js; sourceTree = "<group>"; };
|
||||
9302D9940F30AB8C00DFA4EF /* db.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = db.js; sourceTree = "<group>"; };
|
||||
9302D9950F30AB8C00DFA4EF /* dbshell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dbshell.cpp; sourceTree = "<group>"; };
|
||||
9302D9970F30AB8C00DFA4EF /* md5.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = md5.js; sourceTree = "<group>"; };
|
||||
9302D9980F30AB8C00DFA4EF /* mongo.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = mongo.js; sourceTree = "<group>"; };
|
||||
9302D9990F30AB8C00DFA4EF /* mongo.jsall */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mongo.jsall; sourceTree = "<group>"; };
|
||||
9302D99A0F30AB8C00DFA4EF /* mongo.jsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mongo.jsh; sourceTree = "<group>"; };
|
||||
9302D99B0F30AB8C00DFA4EF /* MongoJS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MongoJS.cpp; sourceTree = "<group>"; };
|
||||
9302D99C0F30AB8C00DFA4EF /* MongoJS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MongoJS.h; sourceTree = "<group>"; };
|
||||
9302D99E0F30AB8C00DFA4EF /* query.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = query.js; sourceTree = "<group>"; };
|
||||
9302D99F0F30AB8C00DFA4EF /* ShellUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShellUtils.cpp; sourceTree = "<group>"; };
|
||||
9302D9A00F30AB8C00DFA4EF /* ShellUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShellUtils.h; sourceTree = "<group>"; };
|
||||
9302D9A20F30AB8C00DFA4EF /* utils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = utils.js; sourceTree = "<group>"; };
|
||||
930B844D0FA10D1C00F22B4B /* optime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = optime.h; sourceTree = "<group>"; };
|
||||
931183420F8277FD00A6DC44 /* repl7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl7.js; sourceTree = "<group>"; };
|
||||
@ -209,6 +203,7 @@
|
||||
93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = "<group>"; };
|
||||
93A6E10F0F24CFEA00DA4EBF /* security_commands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = security_commands.cpp; sourceTree = "<group>"; };
|
||||
93A71D2D10D04D15003C9E90 /* auth2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth2.js; sourceTree = "<group>"; };
|
||||
93A71DB610D06CAD003C9E90 /* mr.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = mr.js; sourceTree = "<group>"; };
|
||||
93A8CD170F33B78D00C92B85 /* mmap_mm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_mm.cpp; path = util/mmap_mm.cpp; sourceTree = SOURCE_ROOT; };
|
||||
93A8CD180F33B7A000C92B85 /* mmap_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_posix.cpp; path = util/mmap_posix.cpp; sourceTree = SOURCE_ROOT; };
|
||||
93A8CD190F33B7AF00C92B85 /* mmap_win.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_win.cpp; path = util/mmap_win.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -350,20 +345,15 @@
|
||||
9302D9920F30AB8C00DFA4EF /* shell */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
93A71DB610D06CAD003C9E90 /* mr.js */,
|
||||
931979800FBC67FB001FE537 /* mongo_vstudio.cpp */,
|
||||
931979810FBC67FB001FE537 /* utils.cpp */,
|
||||
9302D9930F30AB8C00DFA4EF /* collection.js */,
|
||||
9302D9940F30AB8C00DFA4EF /* db.js */,
|
||||
9302D9950F30AB8C00DFA4EF /* dbshell.cpp */,
|
||||
9302D9970F30AB8C00DFA4EF /* md5.js */,
|
||||
9302D9980F30AB8C00DFA4EF /* mongo.js */,
|
||||
9302D9990F30AB8C00DFA4EF /* mongo.jsall */,
|
||||
9302D99A0F30AB8C00DFA4EF /* mongo.jsh */,
|
||||
9302D99B0F30AB8C00DFA4EF /* MongoJS.cpp */,
|
||||
9302D99C0F30AB8C00DFA4EF /* MongoJS.h */,
|
||||
9302D99E0F30AB8C00DFA4EF /* query.js */,
|
||||
9302D99F0F30AB8C00DFA4EF /* ShellUtils.cpp */,
|
||||
9302D9A00F30AB8C00DFA4EF /* ShellUtils.h */,
|
||||
9302D9A20F30AB8C00DFA4EF /* utils.js */,
|
||||
);
|
||||
path = shell;
|
||||
|
@ -439,6 +439,7 @@ ReplPair.prototype.master = function() { return this.master_; }
|
||||
ReplPair.prototype.slave = function() { return this.slave_; }
|
||||
ReplPair.prototype.right = function() { return this.rightC_; }
|
||||
ReplPair.prototype.left = function() { return this.leftC_; }
|
||||
ReplPair.prototype.arbiter = function() { return this.arbiterC_; }
|
||||
|
||||
ReplPair.prototype.killNode = function( mongo, signal ) {
|
||||
signal = signal || 15;
|
||||
@ -450,6 +451,10 @@ ReplPair.prototype.killNode = function( mongo, signal ) {
|
||||
stopMongod( this.right_.port_ );
|
||||
this.rightC_ = null;
|
||||
}
|
||||
if ( this.arbiterC_ != null && this.arbiterC_.host == mongo.host ) {
|
||||
stopMongod( this.arbiter_.port_ );
|
||||
this.arbiterC_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
ReplPair.prototype._annotatedNode = function( mongo ) {
|
||||
@ -525,9 +530,13 @@ ToolTest.prototype.runTool = function(){
|
||||
}
|
||||
|
||||
|
||||
ReplTest = function( name ){
|
||||
ReplTest = function( name, masterPort ){
|
||||
this.name = name;
|
||||
this.ports = allocatePorts( 2 );
|
||||
if ( masterPort ) {
|
||||
this.ports = [ masterPort, allocatePorts( 1 )[ 0 ] ]
|
||||
} else {
|
||||
this.ports = allocatePorts( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
ReplTest.prototype.getPort = function( master ){
|
||||
@ -552,7 +561,7 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
|
||||
extra = {};
|
||||
|
||||
if ( ! extra.oplogSize )
|
||||
extra.oplogSize = 10;
|
||||
extra.oplogSize = "1";
|
||||
|
||||
var a = []
|
||||
if ( putBinaryFirst )
|
||||
|
Loading…
Reference in New Issue
Block a user