diff options
author | Kristina <kristina@10gen.com> | 2012-11-06 17:33:04 -0500 |
---|---|---|
committer | Kristina <kristina@10gen.com> | 2012-11-06 17:33:04 -0500 |
commit | d7fe5dc2d8f0cf6a95064bfe1ec457e8c4f66a9f (patch) | |
tree | e8251939c20ec2d3a5f167225551eb85993428d4 /jstests | |
parent | e1cb581da6c5c218286b02757fa3ea8969b9eadd (diff) | |
download | mongo-d7fe5dc2d8f0cf6a95064bfe1ec457e8c4f66a9f.tar.gz |
SERVER-7498 chainingAllowed option for replication
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/no_chaining.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/jstests/replsets/no_chaining.js b/jstests/replsets/no_chaining.js new file mode 100644 index 00000000000..c937dbed1eb --- /dev/null +++ b/jstests/replsets/no_chaining.js @@ -0,0 +1,68 @@ + +function myprint( x ) { + print( "chaining output: " + x ); +} + +var replTest = new ReplSetTest({name: 'testSet', nodes: 3}); +var nodes = replTest.startSet(); +var hostnames = replTest.nodeList(); +replTest.initiate( + { + "_id" : "testSet", + "members" : [ + {"_id" : 0, "host" : hostnames[0], "priority" : 2}, + {"_id" : 1, "host" : hostnames[1]}, + {"_id" : 2, "host" : hostnames[2]} + ], + "settings" : { + "chainingAllowed" : false + } + } +); + +var master = replTest.getMaster(); +replTest.awaitReplication(); + + +var breakNetwork = function() { + replTest.bridge(); + replTest.partition(0, 2); + master = replTest.getMaster(); +}; + +var checkNoChaining = function() { + master.getDB("test").foo.insert({x:1}); + + assert.soon( + function() { + return nodes[1].getDB("test").foo.findOne() != null; + } + ); + + var endTime = (new Date()).getTime()+10; + while ((new Date()).getTime() < endTime) { + assert(nodes[2].getDB("test").foo.findOne() == null, + 'Check that 2 does not catch up'); + } +}; + +var forceSync = function() { + assert.soon( + function() { + nodes[2].getDB("admin").runCommand({replSetSyncFrom : hostnames[1]}); + return nodes[2].getDB("test").foo.findOne() != null; + }, + 'Check force sync still works' + ); +}; + +if (!_isWindows()) { + print("break the network so that node 2 cannot replicate"); + breakNetwork(); + + print("make sure chaining is not happening"); + checkNoChaining(); + + print("check that forcing sync target still works"); + forceSync(); +} |