diff options
Diffstat (limited to 'jstests/noPassthrough/out_majority_read_replset.js')
-rw-r--r-- | jstests/noPassthrough/out_majority_read_replset.js | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/jstests/noPassthrough/out_majority_read_replset.js b/jstests/noPassthrough/out_majority_read_replset.js index 6452a8c93f9..222bc3a0503 100644 --- a/jstests/noPassthrough/out_majority_read_replset.js +++ b/jstests/noPassthrough/out_majority_read_replset.js @@ -1,44 +1,44 @@ // Tests the $out and read concern majority. (function() { - "use strict"; +"use strict"; - load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority. - load("jstests/libs/write_concern_util.js"); // For stopReplicationOnSecondaries. +load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority. +load("jstests/libs/write_concern_util.js"); // For stopReplicationOnSecondaries. - const rst = new ReplSetTest({nodes: 2, nodeOptions: {enableMajorityReadConcern: ""}}); +const rst = new ReplSetTest({nodes: 2, nodeOptions: {enableMajorityReadConcern: ""}}); - // Skip this test if running with --nojournal and WiredTiger. - if (jsTest.options().noJournal && - (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) { - print("Skipping test because running WiredTiger without journaling isn't a valid" + - " replica set configuration"); - return; - } +// Skip this test if running with --nojournal and WiredTiger. +if (jsTest.options().noJournal && + (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger")) { + print("Skipping test because running WiredTiger without journaling isn't a valid" + + " replica set configuration"); + return; +} - if (!startSetIfSupportsReadMajority(rst)) { - jsTestLog("Skipping test since storage engine doesn't support majority read concern."); - rst.stopSet(); - return; - } +if (!startSetIfSupportsReadMajority(rst)) { + jsTestLog("Skipping test since storage engine doesn't support majority read concern."); + rst.stopSet(); + return; +} - rst.initiate(); +rst.initiate(); - const name = "out_majority_read"; - const db = rst.getPrimary().getDB(name); +const name = "out_majority_read"; +const db = rst.getPrimary().getDB(name); - const sourceColl = db.sourceColl; +const sourceColl = db.sourceColl; - assert.commandWorked(sourceColl.insert({_id: 1, state: 'before'})); - rst.awaitLastOpCommitted(); +assert.commandWorked(sourceColl.insert({_id: 1, state: 'before'})); +rst.awaitLastOpCommitted(); - stopReplicationOnSecondaries(rst); +stopReplicationOnSecondaries(rst); - // Create the index that is not majority commited - assert.commandWorked(sourceColl.createIndex({state: 1}, {name: "secondIndex"})); +// Create the index that is not majority commited +assert.commandWorked(sourceColl.createIndex({state: 1}, {name: "secondIndex"})); - // Run the $out in the parallel shell as it will block in the metadata until the shapshot is - // advanced. - const awaitShell = startParallelShell(`{ +// Run the $out in the parallel shell as it will block in the metadata until the shapshot is +// advanced. +const awaitShell = startParallelShell(`{ const testDB = db.getSiblingDB("${name}"); const sourceColl = testDB.sourceColl; @@ -55,17 +55,17 @@ }`, db.getMongo().port); - // Wait for the $out before restarting the replication. - assert.soon(function() { - const filter = {"command.aggregate": "sourceColl"}; - return assert.commandWorked(db.currentOp(filter)).inprog.length === 1; - }); +// Wait for the $out before restarting the replication. +assert.soon(function() { + const filter = {"command.aggregate": "sourceColl"}; + return assert.commandWorked(db.currentOp(filter)).inprog.length === 1; +}); - // Restart data replicaiton and wait until the new write becomes visible. - restartReplicationOnSecondaries(rst); - rst.awaitLastOpCommitted(); +// Restart data replicaiton and wait until the new write becomes visible. +restartReplicationOnSecondaries(rst); +rst.awaitLastOpCommitted(); - awaitShell(); +awaitShell(); - rst.stopSet(); +rst.stopSet(); }()); |