diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/replsets/index_delete.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/replsets/index_delete.js')
-rw-r--r-- | jstests/replsets/index_delete.js | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/jstests/replsets/index_delete.js b/jstests/replsets/index_delete.js index e43e1e9a55d..9013f8d4ab0 100644 --- a/jstests/replsets/index_delete.js +++ b/jstests/replsets/index_delete.js @@ -7,19 +7,19 @@ */ /** - * Starts a replica set with arbiter, build an index - * drop index once secondary starts building index, + * Starts a replica set with arbiter, build an index + * drop index once secondary starts building index, * index should not exist on secondary afterwards */ var checkOp = function(checkDB) { var curOp = checkDB.currentOp(true); - for (var i=0; i < curOp.inprog.length; i++) { + for (var i = 0; i < curOp.inprog.length; i++) { try { - if (curOp.inprog[i].query.background){ - // should throw something when string contains > 90% + if (curOp.inprog[i].query.background) { + // should throw something when string contains > 90% printjson(curOp.inprog[i].msg); - return true; + return true; } } catch (e) { // catchem if you can @@ -28,16 +28,19 @@ var checkOp = function(checkDB) { return false; }; // Set up replica set -var replTest = new ReplSetTest({ name: 'fgIndex', nodes: 3 }); +var replTest = new ReplSetTest({name: 'fgIndex', nodes: 3}); var nodes = replTest.nodeList(); // We need an arbiter to ensure that the primary doesn't step down when we restart the secondary replTest.startSet(); -replTest.initiate({"_id" : "fgIndex", - "members" : [ - {"_id" : 0, "host" : nodes[0]}, - {"_id" : 1, "host" : nodes[1]}, - {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); +replTest.initiate({ + "_id": "fgIndex", + "members": [ + {"_id": 0, "host": nodes[0]}, + {"_id": 1, "host": nodes[1]}, + {"_id": 2, "host": nodes[2], "arbiterOnly": true} + ] +}); var master = replTest.getPrimary(); var second = replTest.getSecondary(); @@ -48,30 +51,31 @@ var size = 50000; jsTest.log("creating test data " + size + " documents"); var bulk = masterDB.jstests_fgsec.initializeUnorderedBulkOp(); -for(var i = 0; i < size; ++i) { - bulk.insert({ i: i }); +for (var i = 0; i < size; ++i) { + bulk.insert({i: i}); } assert.writeOK(bulk.execute()); jsTest.log("Creating index"); -masterDB.jstests_fgsec.ensureIndex( {i:1} ); -assert.eq(2, masterDB.jstests_fgsec.getIndexes().length ); +masterDB.jstests_fgsec.ensureIndex({i: 1}); +assert.eq(2, masterDB.jstests_fgsec.getIndexes().length); // Wait for the secondary to get the index entry -assert.soon( function() { - return 2 == secondDB.jstests_fgsec.getIndexes().length; }, - "index not created on secondary", 1000*60*10, 50 ); +assert.soon(function() { + return 2 == secondDB.jstests_fgsec.getIndexes().length; +}, "index not created on secondary", 1000 * 60 * 10, 50); jsTest.log("Index created on secondary"); -masterDB.runCommand( {dropIndexes: "jstests_fgsec", index: "i_1"} ); +masterDB.runCommand({dropIndexes: "jstests_fgsec", index: "i_1"}); jsTest.log("Waiting on replication"); replTest.awaitReplication(); -assert.soon( function() {return !checkOp(secondDB);}, "index not cancelled on secondary", 30000, 50); +assert.soon(function() { + return !checkOp(secondDB); +}, "index not cancelled on secondary", 30000, 50); masterDB.jstests_fgsec.getIndexes().forEach(printjson); secondDB.jstests_fgsec.getIndexes().forEach(printjson); -assert.soon( function() { - return 1 == secondDB.jstests_fgsec.getIndexes().length; }, - "Index not dropped on secondary", 30000, 50 ); +assert.soon(function() { + return 1 == secondDB.jstests_fgsec.getIndexes().length; +}, "Index not dropped on secondary", 30000, 50); jsTest.log("index-restart-secondary.js complete"); - |