diff options
author | Aaron <aaron@10gen.com> | 2009-03-30 14:07:04 -0400 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-03-30 14:07:04 -0400 |
commit | e347e27606a6a749d3d04f00e7880bc489a030a0 (patch) | |
tree | af9d73f7fedd8d368d19d744e47ee9387a51a02d /jstests/repl/pair1.js | |
parent | 40eab1308ea0848e43b0015d12a10fbae5baea50 (diff) | |
download | mongo-e347e27606a6a749d3d04f00e7880bc489a030a0.tar.gz |
Better 'not master' validation
Diffstat (limited to 'jstests/repl/pair1.js')
-rw-r--r-- | jstests/repl/pair1.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/jstests/repl/pair1.js b/jstests/repl/pair1.js index d6563ed0593..f3429203f80 100644 --- a/jstests/repl/pair1.js +++ b/jstests/repl/pair1.js @@ -3,7 +3,7 @@ var baseName = "jstests_pair1test"; ismaster = function( n ) { - im = n.getDB( "admin" ).runCommand( { "ismaster" : 1 } ); + var im = n.getDB( "admin" ).runCommand( { "ismaster" : 1 } ); // print( "ismaster: " + tojson( im ) ); assert( im ); return im.ismaster; @@ -32,6 +32,25 @@ checkWrite = function( m, s ) { } ); } +// check that slave reads and writes are guarded +checkSlaveGuard = function( s ) { + var t = s.getDB( baseName + "-temp" ).temp; + assert.throws( t.find().count, {}, "not master" ); + assert.throws( t.find(), {}, "not master", "find did not assert" ); + + checkError = function() { + assert.eq( "not master", s.getDB( "admin" ).getLastError() ); + s.getDB( "admin" ).resetError(); + } + s.getDB( "admin" ).resetError(); + t.save( {x:1} ); + checkError(); + t.update( {}, {x:2}, true ); + checkError(); + t.remove( {x:0} ); + checkError(); +} + doTest = function( signal ) { // spec small oplog for fast startup on 64bit machines @@ -51,8 +70,7 @@ doTest = function( signal ) { return ( lm == 0 && rm == 1 ); } ); - // Check that reading from slave fails - assert.throws( l.getDB( baseName + "-temp" ).temp.find().count, {}, "not master" ); + checkSlaveGuard( l ); checkWrite( r, l ); |