diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/replica_set_shard_version.js')
-rw-r--r-- | jstests/noPassthroughWithMongod/replica_set_shard_version.js | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/jstests/noPassthroughWithMongod/replica_set_shard_version.js b/jstests/noPassthroughWithMongod/replica_set_shard_version.js index f853c74603e..b8fe681cc06 100644 --- a/jstests/noPassthroughWithMongod/replica_set_shard_version.js +++ b/jstests/noPassthroughWithMongod/replica_set_shard_version.js @@ -1,8 +1,8 @@ // Tests whether a Replica Set in a mongos cluster can cause versioning problems -jsTestLog( "Starting sharded cluster..." ); +jsTestLog("Starting sharded cluster..."); -var st = new ShardingTest( { shards : 1, mongos : 2, other : { rs : true } } ); +var st = new ShardingTest({shards: 1, mongos: 2, other: {rs: true}}); // Uncomment to stop the balancer, since the balancer usually initializes the shard automatically // SERVER-4921 is otherwise hard to manifest @@ -12,48 +12,50 @@ var mongosA = st.s0; var mongosB = st.s1; var shard = st.shard0; -coll = mongosA.getCollection( jsTestName() + ".coll" ); +coll = mongosA.getCollection(jsTestName() + ".coll"); // Wait for primary and then initialize shard SERVER-5130 st.rs0.getPrimary(); coll.findOne(); -var sadmin = shard.getDB( "admin" ); -assert.throws(function() { sadmin.runCommand({ replSetStepDown : 3000, force : true }); }); +var sadmin = shard.getDB("admin"); +assert.throws(function() { + sadmin.runCommand({replSetStepDown: 3000, force: true}); +}); st.rs0.getPrimary(); -mongosA.getDB("admin").runCommand({ setParameter : 1, traceExceptions : true }); +mongosA.getDB("admin").runCommand({setParameter: 1, traceExceptions: true}); -try{ - // This _almost_ always fails, unless the new primary is already detected. If if fails, it should +try { + // This _almost_ always fails, unless the new primary is already detected. If if fails, it + // should // mark the master as bad, so mongos will reload the replica set master next request // TODO: Can we just retry and succeed here? coll.findOne(); -} -catch( e ){ - print( "This error is expected : " ); - printjson( e ); +} catch (e) { + print("This error is expected : "); + printjson(e); } -jsTest.log( "Running query which should succeed..." ); +jsTest.log("Running query which should succeed..."); // This should always succeed without throwing an error coll.findOne(); -mongosA.getDB("admin").runCommand({ setParameter : 1, traceExceptions : false }); +mongosA.getDB("admin").runCommand({setParameter: 1, traceExceptions: false}); // now check secondary -assert.throws(function() { sadmin.runCommand({ replSetStepDown : 3000, force : true }); }); +assert.throws(function() { + sadmin.runCommand({replSetStepDown: 3000, force: true}); +}); // Can't use the mongosB - SERVER-5128 -other = new Mongo( mongosA.host ); -other.setSlaveOk( true ); -other = other.getCollection( jsTestName() + ".coll" ); - -print( "eliot: " + tojson( other.findOne() ) ); - +other = new Mongo(mongosA.host); +other.setSlaveOk(true); +other = other.getCollection(jsTestName() + ".coll"); +print("eliot: " + tojson(other.findOne())); st.stop(); |