diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2016-06-22 18:28:27 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2016-06-23 13:15:19 -0400 |
commit | 8f45c2c60ff72c5b6e46a26b72a3b144ccee0bf0 (patch) | |
tree | 7c408c47d70fd34395c1eba0b1e0665538e641e2 /jstests/sharding/repl_monitor_refresh.js | |
parent | 17a143c17686a8103e26f833976c2d8fe91724a1 (diff) | |
download | mongo-8f45c2c60ff72c5b6e46a26b72a3b144ccee0bf0.tar.gz |
SERVER-24740 Print less to the logs during sharding/repl_monitor_refresh.js
Printing in every iteration of assert.soon() is an anti-pattern that can cause
slow or I/O bound test machines to fail to reach the goal state before the
assert.soon() timeout expires. This patch adjusts
sharding/repl_monitor_refresh.js to only print when assert.soon() fails.
Diffstat (limited to 'jstests/sharding/repl_monitor_refresh.js')
-rw-r--r-- | jstests/sharding/repl_monitor_refresh.js | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/jstests/sharding/repl_monitor_refresh.js b/jstests/sharding/repl_monitor_refresh.js index 28e86ec8d32..6098c3b96ff 100644 --- a/jstests/sharding/repl_monitor_refresh.js +++ b/jstests/sharding/repl_monitor_refresh.js @@ -1,3 +1,5 @@ +load("jstests/replsets/rslib.js"); + /** * Test for making sure that the replica seed list in the config server does not * become invalid when a replica set reconfig happens. @@ -35,11 +37,7 @@ jsTest.log('Changing conf to ' + tojson(confDoc)); - try { - priConn.getDB('admin').adminCommand({replSetReconfig: confDoc}); - } catch (x) { - print('Expected exception because of reconfig' + x); - } + reconfig(replTest, confDoc); ReplSetTest.awaitRSClientHosts(mongos, {host: targetHostName}, {ok: true, ismaster: true}); @@ -47,27 +45,33 @@ confDoc.members.shift(); confDoc.version++; - try { - replTest.getPrimary().getDB('admin').adminCommand({replSetReconfig: confDoc}); - } catch (x) { - print('Expected exception because of reconfig: ' + x); - } - - assert.soon(function() { - var connPoolStats = mongos.getDB('admin').runCommand('connPoolStats'); - var replView = connPoolStats.replicaSets[replTest.name].hosts; - jsTest.log('current replView: ' + tojson(replView)); - - return replView.length == NODE_COUNT - 1; - }); - - assert.soon(function() { - shardDoc = mongos.getDB('config').shards.findOne(); - jsTest.log('shardDoc: ' + tojson(shardDoc)); - // seed list should contain one less node - return shardDoc.host.split(',').length == NODE_COUNT - 1; - }); + reconfig(replTest, confDoc); + + jsTest.log("Waiting for mongos to reflect change in shard replica set membership."); + var replView; + assert.soon( + function() { + var connPoolStats = mongos.getDB('admin').runCommand('connPoolStats'); + replView = connPoolStats.replicaSets[replTest.name].hosts; + return replView.length == confDoc.members.length; + }, + function() { + return ("Expected to find " + confDoc.members.length + " nodes but found " + + replView.length + " in " + tojson(replView)); + }); + + jsTest.log("Waiting for config.shards to reflect change in shard replica set membership."); + assert.soon( + function() { + shardDoc = mongos.getDB('config').shards.findOne(); + // seed list should contain one less node + return shardDoc.host.split(',').length == confDoc.members.length; + }, + function() { + return ("Expected to find " + confDoc.members.length + " nodes but found " + + shardDoc.host.split(',').length + " in " + shardDoc.host); + }); st.stop(); -}());
\ No newline at end of file +}()); |