diff options
Diffstat (limited to 'jstests/sharding/all_config_hosts_down.js')
-rw-r--r-- | jstests/sharding/all_config_hosts_down.js | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/jstests/sharding/all_config_hosts_down.js b/jstests/sharding/all_config_hosts_down.js index 5827480dca4..3abd0d14feb 100644 --- a/jstests/sharding/all_config_hosts_down.js +++ b/jstests/sharding/all_config_hosts_down.js @@ -3,43 +3,42 @@ // Should fail sanely // (function() { -"use strict"; + "use strict"; -var st = new ShardingTest({ shards : 1, mongos : 1 }); + var st = new ShardingTest({shards: 1, mongos: 1}); -var mongos = st.s; -var coll = mongos.getCollection( "foo.bar" ); + var mongos = st.s; + var coll = mongos.getCollection("foo.bar"); -jsTestLog( "Stopping config servers" ); -for (var i = 0; i < st._configServers.length; i++) { - MongoRunner.stopMongod(st._configServers[i]); -} - -// Make sure mongos has no database info currently loaded -mongos.getDB( "admin" ).runCommand({ flushRouterConfig : 1 }); - -jsTestLog( "Config flushed and config servers down!" ); - -// Throws transport error first and subsequent times when loading config data, not no primary -for( var i = 0; i < 2; i++ ){ - try { - coll.findOne(); - // Should always throw - assert( false ); + jsTestLog("Stopping config servers"); + for (var i = 0; i < st._configServers.length; i++) { + MongoRunner.stopMongod(st._configServers[i]); } - catch( e ) { - printjson( e ); - - // Make sure we get a transport error, and not a no-primary error - assert(e.code == 8002 || // SCCC config down, for v3.0 compatibility. - e.code == 10276 || // Transport error - e.code == 13328 || // Connect error - e.code == ErrorCodes.HostUnreachable || - e.code == ErrorCodes.FailedToSatisfyReadPreference || - e.code == ErrorCodes.ReplicaSetNotFound); + + // Make sure mongos has no database info currently loaded + mongos.getDB("admin").runCommand({flushRouterConfig: 1}); + + jsTestLog("Config flushed and config servers down!"); + + // Throws transport error first and subsequent times when loading config data, not no primary + for (var i = 0; i < 2; i++) { + try { + coll.findOne(); + // Should always throw + assert(false); + } catch (e) { + printjson(e); + + // Make sure we get a transport error, and not a no-primary error + assert(e.code == 8002 || // SCCC config down, for v3.0 compatibility. + e.code == 10276 || // Transport error + e.code == 13328 || // Connect error + e.code == ErrorCodes.HostUnreachable || + e.code == ErrorCodes.FailedToSatisfyReadPreference || + e.code == ErrorCodes.ReplicaSetNotFound); + } } -} -st.stop(); + st.stop(); }()); |