diff options
author | Spencer T Brody <spencer@mongodb.com> | 2015-08-03 18:39:53 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2015-08-08 11:18:44 -0400 |
commit | 19c2f0a0dce35cb9b0f1c1b49e7f2132297900c1 (patch) | |
tree | d799dcf262dd7dccfcfc9a1d879f8cda12c3d55e /jstests/replsets/config_server_checks.js | |
parent | 2ea42e3cdf2a57f0f3b69715e77cb59d7760c7a5 (diff) | |
download | mongo-19c2f0a0dce35cb9b0f1c1b49e7f2132297900c1.tar.gz |
SERVER-19524 SERVER-19739 Additional validation and behavior for replica set configs for config servers
Diffstat (limited to 'jstests/replsets/config_server_checks.js')
-rw-r--r-- | jstests/replsets/config_server_checks.js | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/jstests/replsets/config_server_checks.js b/jstests/replsets/config_server_checks.js new file mode 100644 index 00000000000..358e9eca38a --- /dev/null +++ b/jstests/replsets/config_server_checks.js @@ -0,0 +1,116 @@ +/* + * Tests various combinations of the configServer field in replica set configurations and the + * command line options that control whether a node can function as a member of a CSRS. + */ + +function expectState(rst, state) { + assert.soon(function() { + var status = rst.status(); + if (status.myState != state) { + print("Waiting for state " + state + + " in replSetGetStatus output: " + tojson(status)); + } + return status.myState == state; + }); +} + +(function() { +"use strict"; + +(function() { +// Test that node without --configsvr cmd line but with configServer in replset config goes +// into REMOVED state +jsTestLog("configServer in rs config, no --configsvr cmd line") +var rst = new ReplSetTest({name: "configrs1", + nodes: 1, + nodeOptions: {storageEngine: "wiredTiger"}}); + +rst.startSet(); +var conf = rst.getReplSetConfig(); +conf.configServer = true; +try { + rst.nodes[0].adminCommand({replSetInitiate: conf}); +} catch (e) { + // expected since we close all connections after going into REMOVED +} +expectState(rst, 10 /*REMOVED*/); +rst.stopSet(); +})(); + + +(function() { +// Test that node with --configsvr cmd line but without configServer in replset config goes +// into REMOVED state +jsTestLog("no configServer in rs config but --configsvr cmd line"); +var rst = new ReplSetTest({name: "configrs2", + nodes: 1, + nodeOptions: {configsvr: "", storageEngine: "wiredTiger"}}); + +rst.startSet(); +var conf = rst.getReplSetConfig(); +try { + rst.nodes[0].adminCommand({replSetInitiate: conf}); +} catch (e) { + // expected since we close all connections after going into REMOVED +} +expectState(rst, 10 /*REMOVED*/); +rst.stopSet(); +})(); + +(function() { +// Test that node with --configsvr cmd line and configServer in replset config goes +// into REMOVED state if storage engine is not WiredTiger +jsTestLog("configServer in rs config and --configsvr cmd line, but mmapv1"); +var rst = new ReplSetTest({name: "configrs3", nodes: 1, nodeOptions: {configsvr: "", + storageEngine: "mmapv1"}}); + +rst.startSet(); +var conf = rst.getReplSetConfig(); +conf.configServer = true; +try { + rst.nodes[0].adminCommand({replSetInitiate: conf}); +} catch (e) { + // expected since we close all connections after going into REMOVED +} +expectState(rst, 10 /*REMOVED*/); +rst.stopSet(); +})(); + +(function() { +// Test that node with --configsvr cmd line and configServer in replset config does NOT go +// into REMOVED state if storage engine is not WiredTiger but we're running in SCC mode +jsTestLog("configServer in rs config and --configsvr cmd line, but mmapv1 with configSvrMode=scc"); +var rst = new ReplSetTest({name: "configrs4", nodes: 1, nodeOptions: {configsvr: "", + storageEngine: "mmapv1", + configsvrMode: "scc"}}); + +rst.startSet(); +var conf = rst.getReplSetConfig(); +conf.configServer = true; +assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); + +rst.getMaster(); +expectState(rst, 1 /*PRIMARY*/); +rst.stopSet(); +})(); + +(function() { +// Test that node with --configsvr cmd line and configServer in replset config and using wiredTiger +// does NOT go into REMOVED state. +jsTestLog("configServer in rs config and --configsvr cmd line, normal case"); +var rst = new ReplSetTest({name: "configrs5", + nodes: 1, + nodeOptions: {configsvr: "", storageEngine: "wiredTiger"}}); + +rst.startSet(); +var conf = rst.getReplSetConfig(); +conf.configServer = true; +assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); + +rst.getMaster(); +expectState(rst, 1 /*PRIMARY*/); +rst.stopSet(); +})(); + + +})(); |