summaryrefslogtreecommitdiff
path: root/jstests/repl/pair1.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/repl/pair1.js')
-rw-r--r--jstests/repl/pair1.js133
1 files changed, 72 insertions, 61 deletions
diff --git a/jstests/repl/pair1.js b/jstests/repl/pair1.js
index 2a941aa7e8b..e70e8898dbb 100644
--- a/jstests/repl/pair1.js
+++ b/jstests/repl/pair1.js
@@ -31,66 +31,77 @@ checkWrite = function( m, s ) {
} );
}
-// 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" );
+doTest = function( signal ) {
-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 );
-
-stopMongod( 27020 );
-
-assert.soon( function() {
- lm = ismaster( l );
- assert( lm == 0 || lm == 1 );
- 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" );
-
-assert.soon( function() {
- lm = ismaster( l );
- rm = ismaster( r );
-
- assert( lm == 1 );
- assert( rm == -1 || rm == 0 );
-
- return ( rm == 0 );
- } );
-
-// Once this returns, the initial sync for r will have completed.
-checkWrite( l, r );
-
-stopMongod( 27019 );
-
-assert.soon( function() {
- rm = ismaster( r );
- assert( rm == 0 || rm == 1 );
- 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" );
-
-assert.soon( function() {
- lm = ismaster( l );
- rm = ismaster( r );
-
- assert( lm == -1 || lm == 0 );
- assert( rm == 1 );
-
- return ( lm == 0 && rm == 1 );
- } );
+ // 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" );
+
+ 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 );
+
+ stopMongod( 27020, signal );
+
+ assert.soon( function() {
+ lm = ismaster( l );
+ assert( lm == 0 || lm == 1 );
+ 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" );
+
+ assert.soon( function() {
+ lm = ismaster( l );
+ rm = ismaster( r );
+
+ assert( lm == 1 );
+ assert( rm == -1 || rm == 0 );
+
+ return ( rm == 0 );
+ } );
+
+ // Once this returns, the initial sync for r will have completed.
+ checkWrite( l, r );
+
+ stopMongod( 27019, signal );
+
+ assert.soon( function() {
+ rm = ismaster( r );
+ assert( rm == 0 || rm == 1 );
+ 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" );
+
+ assert.soon( function() {
+ lm = ismaster( l );
+ rm = ismaster( r );
+
+ assert( lm == -1 || lm == 0 );
+ assert( rm == 1 );
+
+ return ( lm == 0 && rm == 1 );
+ } );
+
+ checkWrite( r, l );
+
+ stopMongod( 27018 );
+ stopMongod( 27019 );
+ stopMongod( 27020 );
+
+}
-checkWrite( r, l );
+doTest( 15 ); // SIGTERM
+doTest( 9 ); // SIGKILL