diff options
author | Aaron <aaron@10gen.com> | 2010-03-22 14:51:37 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-03-22 14:51:37 -0700 |
commit | 8f7d5a26f5b0a53fabd8eb26c230029f1dc06b3d (patch) | |
tree | a1509b89cfb75b03b0169edd7c2ee6fe9e4e5f76 | |
parent | 4912b401063f65ec79ad585e3406ca51dfd7d501 (diff) | |
download | mongo-8f7d5a26f5b0a53fabd8eb26c230029f1dc06b3d.tar.gz |
SERVER-803 add pair test
-rw-r--r-- | jstests/repl/pair7.js | 84 | ||||
-rw-r--r-- | jstests/repl/repl11.js | 1 | ||||
-rw-r--r-- | mongo.xcodeproj/project.pbxproj | 2 |
3 files changed, 86 insertions, 1 deletions
diff --git a/jstests/repl/pair7.js b/jstests/repl/pair7.js new file mode 100644 index 00000000000..3a448c4174b --- /dev/null +++ b/jstests/repl/pair7.js @@ -0,0 +1,84 @@ +// pairing with auth + +var baseName = "jstests_pair7test"; + +setAdmin = function( n ) { + n.getDB( "admin" ).addUser( "super", "super" ); + n.getDB( "local" ).addUser( "repl", "foo" ); + n.getDB( "local" ).system.users.findOne(); +} + +auth = function( n ) { + return n.getDB( baseName ).auth( "test", "test" ); +} + +doTest = function( signal ) { + + ports = allocatePorts( 3 ); + + m = startMongod( "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-left", "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + setAdmin( m ); + stopMongod( ports[ 1 ] ); + + m = startMongod( "--port", ports[ 2 ], "--dbpath", "/data/db/" + baseName + "-right", "--nohttpinterface", "--bind_ip", "127.0.0.1" ); + setAdmin( m ); + stopMongod( ports[ 2 ] ); + + a = new MongodRunner( ports[ 0 ], "/data/db/" + baseName + "-arbiter" ); + l = new MongodRunner( ports[ 1 ], "/data/db/" + baseName + "-left", "127.0.0.1:" + ports[ 2 ], "127.0.0.1:" + ports[ 0 ], [ "--auth" ] ); + r = new MongodRunner( ports[ 2 ], "/data/db/" + baseName + "-right", "127.0.0.1:" + ports[ 1 ], "127.0.0.1:" + ports[ 0 ], [ "--auth" ] ); + + rp = new ReplPair( l, r, a ); + rp.start( true ); + rp.waitForSteadyState(); + + rp.master().getDB( "admin" ).auth( "super", "super" ); + rp.master().getDB( baseName ).addUser( "test", "test" ); + auth( rp.master() ); // reauth + assert.soon( function() { return auth( rp.slave() ); } ); + rp.slave().setSlaveOk(); + + ma = rp.master().getDB( baseName ).a; + ma.save( {} ); + sa = rp.slave().getDB( baseName ).a; + assert.soon( function() { return 1 == sa.count(); } ); + + rp.killNode( rp.slave(), signal ); + ma.save( {} ); + + rp.start( true ); + rp.waitForSteadyState(); + assert.soon( function() { return auth( rp.slave() ); } ); + rp.slave().setSlaveOk(); + sa = rp.slave().getDB( baseName ).a; + assert.soon( function() { return 2 == sa.count(); } ); + + ma.save( {a:1} ); + assert.soon( function() { return 1 == sa.count( {a:1} ); } ); + + ma.update( {a:1}, {b:2} ); + assert.soon( function() { return 1 == sa.count( {b:2} ); } ); + + ma.remove( {b:2} ); + assert.soon( function() { return 0 == sa.count( {b:2} ); } ); + + rp.killNode( rp.master(), signal ); + rp.waitForSteadyState( [ 1, null ] ); + ma = sa; + ma.save( {} ); + + rp.start( true ); + rp.waitForSteadyState(); + assert.soon( function() { return auth( rp.slave() ); } ); + rp.slave().setSlaveOk(); + sa = rp.slave().getDB( baseName ).a; + assert.soon( function() { return 3 == sa.count(); } ); + + ma.save( {} ); + assert.soon( function() { return 4 == sa.count(); } ); + + ports.forEach( function( x ) { stopMongod( x ); } ); +} + +doTest( 15 ); // SIGTERM +doTest( 9 ); // SIGKILL diff --git a/jstests/repl/repl11.js b/jstests/repl/repl11.js index 9341f4a215d..c5c63b3a308 100644 --- a/jstests/repl/repl11.js +++ b/jstests/repl/repl11.js @@ -12,7 +12,6 @@ auth = function( n ) { return n.getDB( baseName ).auth( "test", "test" ); } -// What if preexisting data on master and already set up db on slave for login? doTest = function( signal ) { rt = new ReplTest( baseName ); diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj index 268f8ac65b6..97e7e5056a9 100644 --- a/mongo.xcodeproj/project.pbxproj +++ b/mongo.xcodeproj/project.pbxproj @@ -501,6 +501,7 @@ 93BCE5A610F3FB5200FA139B /* basicPlus.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = basicPlus.js; sourceTree = "<group>"; }; 93BDCE401157E7280097FE87 /* repl10.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl10.js; sourceTree = "<group>"; }; 93BDCE411157E7280097FE87 /* repl11.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl11.js; sourceTree = "<group>"; }; + 93BDCE92115817210097FE87 /* pair7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = pair7.js; sourceTree = "<group>"; }; 93BFA0E311330A8C0045D084 /* not2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = not2.js; sourceTree = "<group>"; }; 93C38E940FA66622007D6E4A /* basictests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basictests.cpp; sourceTree = "<group>"; }; 93C8E6FE11457D9000F28017 /* master1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = master1.js; sourceTree = "<group>"; }; @@ -1060,6 +1061,7 @@ 934BEC5010DFFA9600178102 /* repl */ = { isa = PBXGroup; children = ( + 93BDCE92115817210097FE87 /* pair7.js */, 93BDCE401157E7280097FE87 /* repl10.js */, 93BDCE411157E7280097FE87 /* repl11.js */, 93C8E6FE11457D9000F28017 /* master1.js */, |