diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2014-11-25 09:11:46 -0500 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2014-12-01 04:25:29 -0500 |
commit | 977abaaba51aeda3b4c6f0774aeb66b41aaa2274 (patch) | |
tree | 5e0bba5856e57d8a527bc0248fed15d7d1c5b26f /jstests/replsets/chaining_removal.js | |
parent | ed023a2b488a74807334e8c0d3db57cf9552cf2c (diff) | |
download | mongo-977abaaba51aeda3b4c6f0774aeb66b41aaa2274.tar.gz |
SERVER-15849 add test for removing a chained member
Diffstat (limited to 'jstests/replsets/chaining_removal.js')
-rw-r--r-- | jstests/replsets/chaining_removal.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/jstests/replsets/chaining_removal.js b/jstests/replsets/chaining_removal.js new file mode 100644 index 00000000000..c3c23c59d38 --- /dev/null +++ b/jstests/replsets/chaining_removal.js @@ -0,0 +1,53 @@ +// ensure removing a chained node does not break reporting of replication progress (SERVER-15849) + +(function() { + "use strict"; + var numNodes = 5; + var host = getHostName(); + var name = "chaining_removal"; + + var replTest = new ReplSetTest({name: name, nodes: numNodes}); + var nodes = replTest.startSet(); + var port = replTest.ports; + replTest.initiate({_id: name, members: + [ + {_id: 0, host: nodes[0].host, priority: 3}, + {_id: 1, host: nodes[1].host}, + {_id: 2, host: nodes[2].host}, + {_id: 3, host: nodes[3].host}, + {_id: 4, host: nodes[4].host}, + ], + }); + var primary = replTest.getPrimary(); + // force node 4 to chain through node 1 + assert.commandWorked(nodes[4].getDB("admin").runCommand({"replSetSyncFrom": nodes[1].host})); + var res; + assert.soon(function() { + res = nodes[4].getDB("admin").runCommand({"replSetGetStatus": 1}); + return res.syncingTo === nodes[1].host; + }, "node 4 failed to start chaining: "+ tojson(res)); + + // write that should reach all nodes + var timeout = 15 * 1000; + var options = {writeConcern: {w: numNodes, wtimeout: timeout}}; + assert.writeOK(primary.getDB(name).foo.insert({x: 1}, options)); + + var config = primary.getDB("local").system.replset.findOne(); + config.members.pop(); + config.version++; + // remove node 4 + replTest.stop(4); + try { + primary.adminCommand({replSetReconfig:config}); + } + catch (e) { + print("error: "+e); + } + + // ensure writing to all four nodes still works + primary = replTest.getPrimary(); + options.writeConcern.w = 4; + assert.writeOK(primary.getDB(name).foo.insert({x: 2}, options)); + + replTest.stopSet(); +}()); |