summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-01 18:21:07 -0400
committerAaron <aaron@10gen.com>2009-04-01 18:21:07 -0400
commitaf4bf8e62b703852ce3c7c06b71959881a5369ca (patch)
treef5e3622ef0816f0d42b3e9d33689a964737ae6bc
parent1fe31cb6018c4272d027ba09fbbeead35f03388d (diff)
downloadmongo-af4bf8e62b703852ce3c7c06b71959881a5369ca.tar.gz
converted rest of repl tests
-rw-r--r--jstests/repl/pair1.js20
-rw-r--r--jstests/repl/pair2.js15
-rw-r--r--jstests/repl/repl2.js12
-rw-r--r--jstests/repl/repl3.js12
-rw-r--r--jstests/repl/repl4.js6
-rw-r--r--jstests/repl/repl5.js12
-rw-r--r--jstests/repl/repl6.js23
-rw-r--r--jstests/repl/repl7.js12
-rw-r--r--jstests/repl/replacePeer1.js19
-rw-r--r--jstests/repl/replacePeer2.js20
10 files changed, 73 insertions, 78 deletions
diff --git a/jstests/repl/pair1.js b/jstests/repl/pair1.js
index 382f57f2780..292995a771c 100644
--- a/jstests/repl/pair1.js
+++ b/jstests/repl/pair1.js
@@ -53,10 +53,12 @@ checkSlaveGuard = function( s ) {
doTest = function( signal ) {
+ ports = allocatePorts( 3 );
+
// spec small oplog for fast startup on 64bit machines
- a = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-arbiter" );
- l = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter" );
+ l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
am = ismaster( a );
@@ -74,7 +76,7 @@ doTest = function( signal ) {
checkWrite( r, l );
- stopMongod( 27020, signal );
+ stopMongod( ports[ 2 ], signal );
sleep( 2000 );
assert.soon( function() {
@@ -83,7 +85,7 @@ doTest = function( signal ) {
return ( lm == 1 );
} );
- r = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
lm = ismaster( l );
@@ -98,7 +100,7 @@ doTest = function( signal ) {
// Once this returns, the initial sync for r will have completed.
checkWrite( l, r );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
assert.soon( function() {
@@ -107,7 +109,7 @@ doTest = function( signal ) {
return ( rm == 1 );
} );
- l = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
+ l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
lm = ismaster( l );
@@ -121,10 +123,6 @@ doTest = function( signal ) {
checkWrite( r, l );
- stopMongod( 27018 );
- stopMongod( 27019 );
- stopMongod( 27020 );
-
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/pair2.js b/jstests/repl/pair2.js
index 32a8a288f25..fc0f9651a5e 100644
--- a/jstests/repl/pair2.js
+++ b/jstests/repl/pair2.js
@@ -21,11 +21,13 @@ soonCount = function( count ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 3 );
// spec small oplog for fast startup on 64bit machines
- a = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-arbiter" );
- l = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter" );
+ l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
l.setSlaveOk();
assert.soon( function() { return ( ismaster( l ) == 0 && ismaster( r ) == 1 ); } );
@@ -37,14 +39,14 @@ doTest = function( signal ) {
soonCount( 1 );
assert.eq( 0, l.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
big = new Array( 2000 ).toString();
for( i = 0; i < 1000; ++i )
rz.save( { _id: new ObjectId(), i: i, b: big } );
- l = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
+ l = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
l.setSlaveOk();
assert.soon( function() { return 1 == l.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok; } );
@@ -56,9 +58,6 @@ doTest = function( signal ) {
assert.eq( 0, l.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- stopMongod( 27018 );
- stopMongod( 27019 );
- stopMongod( 27020 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/repl2.js b/jstests/repl/repl2.js
index c3e8bc22aee..98c14dbab14 100644
--- a/jstests/repl/repl2.js
+++ b/jstests/repl/repl2.js
@@ -16,23 +16,25 @@ soonCount = function( count ) {
doTest = function( signal ) {
+ ports = allocatePorts( 2 );
+
// spec small oplog to make slave get out of sync
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
- s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
am = m.getDB( baseName ).a
am.save( { _id: new ObjectId() } );
soonCount( 1 );
assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
big = new Array( 2000 ).toString();
for( i = 0; i < 1000; ++i )
am.save( { _id: new ObjectId(), i: i, b: big } );
- s = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
assert.soon( function() { return 1 == s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok; } );
sleep( 10000 );
@@ -43,8 +45,6 @@ doTest = function( signal ) {
assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- stopMongod( 27018 );
- stopMongod( 27019 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/repl3.js b/jstests/repl/repl3.js
index 9e8cf8ddf0f..9627c14e951 100644
--- a/jstests/repl/repl3.js
+++ b/jstests/repl/repl3.js
@@ -15,23 +15,25 @@ soonCount = function( count ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 2 );
// spec small oplog to make slave get out of sync
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
- s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
am = m.getDB( baseName ).a
am.save( { _id: new ObjectId() } );
soonCount( 1 );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
big = new Array( 2000 ).toString();
for( i = 0; i < 1000; ++i )
am.save( { _id: new ObjectId(), i: i, b: big } );
- s = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018", "--autoresync" );
+ s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--autoresync" );
// after SyncException, mongod waits 10 secs.
sleep( 12000 );
@@ -47,8 +49,6 @@ doTest = function( signal ) {
assert.eq( 0, s.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok );
- stopMongod( 27018 );
- stopMongod( 27019 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/repl4.js b/jstests/repl/repl4.js
index e8c44a140eb..f9cbdf4273c 100644
--- a/jstests/repl/repl4.js
+++ b/jstests/repl/repl4.js
@@ -13,10 +13,12 @@ soonCount = function( db, coll, count ) {
}
doTest = function() {
+
+ ports = allocatePorts( 2 );
// spec small oplog for fast startup on 64bit machines
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
- s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018", "--only", "c" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--only", "c" );
cm = m.getDB( "c" ).c
bm = m.getDB( "b" ).b
diff --git a/jstests/repl/repl5.js b/jstests/repl/repl5.js
index 44bb1c62482..53346ce0d46 100644
--- a/jstests/repl/repl5.js
+++ b/jstests/repl/repl5.js
@@ -14,27 +14,27 @@ soonCountAtLeast = function( db, coll, count ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 2 );
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
ma = m.getDB( "a" ).a;
for( i = 0; i < 10000; ++i )
ma.save( { i:i } );
- s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
soonCountAtLeast( "a", "a", 1 );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
- s = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
sleep( 1000 );
ma.save( { i:-1 } );
ma.save( { i:-2 } );
soonCountAtLeast( "a", "a", 10002 );
- stopMongod( 27018 );
- stopMongod( 27019 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/repl6.js b/jstests/repl/repl6.js
index 09e0209c132..2f368042d04 100644
--- a/jstests/repl/repl6.js
+++ b/jstests/repl/repl6.js
@@ -15,11 +15,13 @@ soonCount = function( m, count ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 3 );
// spec small oplog for fast startup on 64bit machines
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
- s1 = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:27018" );
- s2 = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:27018" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ s1 = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
+ s2 = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
am = m.getDB( baseName ).a
@@ -39,22 +41,22 @@ doTest = function( signal ) {
as = s2.getDB( baseName ).a
check( as );
- stopMongod( 27019, signal );
- stopMongod( 27020, signal );
+ stopMongod( ports[ 1 ], signal );
+ stopMongod( ports[ 2 ], signal );
sleep( 2000 );
for( i = 1000; i < 1010; ++i )
am.save( { _id: new ObjectId(), i: i } );
- s1 = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:27018" );
+ s1 = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
soonCount( s1, 1010 );
as = s1.getDB( baseName ).a
assert.eq( 1, as.find( { i: 1009 } ).count() );
- stopMongod( 27018, signal );
+ stopMongod( ports[ 0 ], signal );
sleep( 2000 );
- m = startMongoProgram( "mongod", "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ m = startMongoProgram( "mongod", "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
am = m.getDB( baseName ).a
for( i = 1010; i < 1020; ++i )
@@ -63,15 +65,12 @@ doTest = function( signal ) {
soonCount( s1, 1020 );
assert.eq( 1, as.find( { i: 1019 } ).count() );
- s2 = startMongoProgram( "mongod", "--port", "27020", "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:27018" );
+ s2 = startMongoProgram( "mongod", "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
soonCount( s2, 1020 );
as = s2.getDB( baseName ).a
assert.eq( 1, as.find( { i: 1009 } ).count() );
assert.eq( 1, as.find( { i: 1019 } ).count() );
- stopMongod( 27018 );
- stopMongod( 27019 );
- stopMongod( 27020 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/repl7.js b/jstests/repl/repl7.js
index 0e503ce842f..d3bf83e0298 100644
--- a/jstests/repl/repl7.js
+++ b/jstests/repl/repl7.js
@@ -3,25 +3,27 @@
var baseName = "jstests_repl7test";
doTest = function( signal ) {
+
+ ports = allocatePorts( 2 );
// spec small oplog for fast startup on 64bit machines
- m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+ m = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
for( n = "a"; n != "aaaaa"; n += "a" ) {
m.getDB( n ).a.save( {x:1} );
}
- s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ s = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
assert.soon( function() {
return -1 != s.getDBNames().indexOf( "aa" );
} );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 4000 );
- s = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+ s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ] );
assert.soon( function() {
for( n = "a"; n != "aaaaa"; n += "a" ) {
@@ -35,8 +37,6 @@ doTest = function( signal ) {
assert.eq( 1, m.getDB( n ).a.find().count() );
}
- stopMongod( 27019 );
- stopMongod( 27018 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/replacePeer1.js b/jstests/repl/replacePeer1.js
index 84190f6edf6..c21ccd28680 100644
--- a/jstests/repl/replacePeer1.js
+++ b/jstests/repl/replacePeer1.js
@@ -33,11 +33,13 @@ checkWrite = function( m, s ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 4 );
// spec small oplog for fast startup on 64bit machines
- a = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-arbiter" );
- l = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27021", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongod( "--port", "27021", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter" );
+ l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
am = ismaster( a );
@@ -53,18 +55,18 @@ doTest = function( signal ) {
checkWrite( r, l );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
writeOne( r );
assert.eq( 1, r.getDB( "admin" ).runCommand( {replacepeer:1} ).ok );
- stopMongod( 27021, signal );
+ stopMongod( ports[ 3 ], signal );
sleep( 2000 );
- l = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27021", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongoProgram( "mongod", "--port", "27021", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
+ l = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongoProgram( "mongod", "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
am = ismaster( a );
@@ -82,9 +84,6 @@ doTest = function( signal ) {
l.setSlaveOk();
assert.eq( 3, l.getDB( baseName ).z.find().toArray().length );
- stopMongod( 27018 );
- stopMongod( 27020 );
- stopMongod( 27021 );
}
doTest( 15 ); // SIGTERM
diff --git a/jstests/repl/replacePeer2.js b/jstests/repl/replacePeer2.js
index d735f8c330f..04e5209ebcf 100644
--- a/jstests/repl/replacePeer2.js
+++ b/jstests/repl/replacePeer2.js
@@ -33,11 +33,13 @@ checkWrite = function( m, s ) {
}
doTest = function( signal ) {
+
+ ports = allocatePorts( 4 );
// spec small oplog for fast startup on 64bit machines
- a = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-arbiter" );
- l = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27021", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongod( "--port", "27021", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ a = startMongod( "--port", ports[ 0 ], "--dbpath", "/data/db/" + baseName + "-arbiter" );
+ l = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 3 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 3 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
am = ismaster( a );
@@ -60,12 +62,12 @@ doTest = function( signal ) {
// Make sure there would be enough time to save to l if we hadn't called replacepeer.
sleep( 10000 );
- stopMongod( 27021, signal );
- stopMongod( 27019, signal );
+ stopMongod( ports[ 3 ], signal );
+ stopMongod( ports[ 1 ], signal );
sleep( 2000 );
- l = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:27020", "127.0.0.1:27018", "--oplogSize", "1" );
- r = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:27019", "127.0.0.1:27018", "--oplogSize", "1" );
+ l = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--pairwith", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
+ r = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--pairwith", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], "--oplogSize", "1" );
assert.soon( function() {
am = ismaster( a );
@@ -83,10 +85,6 @@ doTest = function( signal ) {
r.setSlaveOk();
assert.eq( 2, r.getDB( baseName ).z.find().toArray().length );
- stopMongod( 27018 );
- stopMongod( 27019 );
- stopMongod( 27020 );
- stopMongod( 27021 );
}
doTest( 15 ); // SIGTERM