diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-11-25 11:20:43 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-12-08 13:05:00 -0500 |
commit | 3ed6635a5fb26c354046d275a1217c4526b2fe02 (patch) | |
tree | f40aa20b5e62996843ce3df0f47b82042dd683a7 /jstests/sharding/group_slaveok.js | |
parent | 4f24dc58f48cb087db8a4832421d298e9e2633a0 (diff) | |
download | mongo-3ed6635a5fb26c354046d275a1217c4526b2fe02.tar.gz |
SERVER-21050 Cleanup ReplSetTest
This is just a cleanup work to hide some of the private state of
ReplSetTest so it is easier to encapsulate and add new logic. Also enables
strict mode.
Diffstat (limited to 'jstests/sharding/group_slaveok.js')
-rw-r--r-- | jstests/sharding/group_slaveok.js | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/jstests/sharding/group_slaveok.js b/jstests/sharding/group_slaveok.js index a5c20f51ea5..f7fba0e0f88 100644 --- a/jstests/sharding/group_slaveok.js +++ b/jstests/sharding/group_slaveok.js @@ -1,63 +1,63 @@ // Tests group using slaveOk (function() { +'use strict'; var st = new ShardingTest({ name: "groupSlaveOk", shards: 1, mongos: 1, - other :{ rs : true, - rs0 : { nodes : 2 } } }); + other: { rs: true, + rs0: { nodes: 2 } } }); -var rst = st._rs[0].test +var rst = st._rs[0].test; // Insert data into replica set -var conn = new Mongo( st.s.host ) -conn.setLogLevel( 3 ) +var conn = new Mongo(st.s.host); +conn.setLogLevel(3); -var coll = conn.getCollection( "test.groupSlaveOk" ) -coll.drop() +var coll = conn.getCollection("test.groupSlaveOk"); +coll.drop(); var bulk = coll.initializeUnorderedBulkOp(); -for( var i = 0; i < 300; i++ ){ - bulk.insert( { i : i % 10 } ); +for(var i = 0; i < 300; i++) { + bulk.insert({ i: i % 10 }); } -assert.writeOK( bulk.execute() ); +assert.writeOK(bulk.execute()); -st.printShardingStatus() +st.printShardingStatus(); // Wait for client to update itself and replication to finish -rst.awaitReplication() +rst.awaitReplication(); -var primary = rst.getPrimary() -var sec = rst.getSecondary() +var primary = rst.getPrimary(); +var sec = rst.getSecondary(); // Data now inserted... stop the master, since only two in set, other will still be secondary -rst.stop(rst.getMaster()); -printjson( rst.status() ) +rst.stop(rst.getPrimary()); +printjson(rst.status()); // Wait for the mongos to recognize the slave -ReplSetTest.awaitRSClientHosts( conn, sec, { ok : true, secondary : true } ) +ReplSetTest.awaitRSClientHosts(conn, sec, { ok: true, secondary: true }); // Need to check slaveOk=true first, since slaveOk=false will destroy conn in pool when // master is down -conn.setSlaveOk() +conn.setSlaveOk(); // Should not throw exception, since slaveOk'd -assert.eq( 10, coll.group({ key : { i : true } , - reduce : function( obj, ctx ){ ctx.count += 1 } , - initial : { count : 0 } }).length ) - -try { - - conn.setSlaveOk( false ) - var res = coll.group({ key : { i : true } , - reduce : function( obj, ctx ){ ctx.count += 1 } , - initial : { count : 0 } }); - - print( "Should not reach here! Group result: " + tojson(res) ); - assert( false ); +assert.eq(10, coll.group({ key: { i: true } , + reduce: function(obj, ctx) { ctx.count += 1 }, + initial: { count: 0 } }).length) + +try { + conn.setSlaveOk(false); + var res = coll.group({ key: { i: true }, + reduce: function(obj, ctx) { ctx.count += 1 }, + initial: { count: 0 } }); + + print("Should not reach here! Group result: " + tojson(res)); + assert(false); } -catch( e ){ - print( "Non-slaveOk'd connection failed." + tojson(e) ) +catch(e){ + print("Non-slaveOk'd connection failed." + tojson(e)); } st.stop(); |