diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js')
-rw-r--r-- | jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js b/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js index be5f67f2e2d..101c12252a0 100644 --- a/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js +++ b/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js @@ -6,74 +6,74 @@ */ (function() { - "use strict"; - load("jstests/core/txns/libs/prepare_helpers.js"); +"use strict"; +load("jstests/core/txns/libs/prepare_helpers.js"); - const name = "prepared_transaction_commands_fail_on_secondaries"; - const rst = new ReplSetTest({ - nodes: [ - {}, - {rsConfig: {priority: 0}}, - ], - }); - const nodes = rst.startSet(); - rst.initiate(); +const name = "prepared_transaction_commands_fail_on_secondaries"; +const rst = new ReplSetTest({ + nodes: [ + {}, + {rsConfig: {priority: 0}}, + ], +}); +const nodes = rst.startSet(); +rst.initiate(); - const dbName = "test"; - const collName = name; +const dbName = "test"; +const collName = name; - const primary = rst.getPrimary(); - const secondary = rst.getSecondary(); - const testDB = primary.getDB(dbName); +const primary = rst.getPrimary(); +const secondary = rst.getSecondary(); +const testDB = primary.getDB(dbName); - assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); +assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); - const priSession = primary.startSession({causalConsistency: false}); - const priSessionDB = priSession.getDatabase(dbName); - const priSessionColl = priSessionDB.getCollection(collName); +const priSession = primary.startSession({causalConsistency: false}); +const priSessionDB = priSession.getDatabase(dbName); +const priSessionColl = priSessionDB.getCollection(collName); - const secSession = PrepareHelpers.createSessionWithGivenId( - secondary, priSession.getSessionId(), {causalConsistency: false}); +const secSession = PrepareHelpers.createSessionWithGivenId( + secondary, priSession.getSessionId(), {causalConsistency: false}); - priSession.startTransaction(); - const doc = {_id: 1}; - assert.commandWorked(priSessionColl.insert(doc)); - rst.awaitReplication(); +priSession.startTransaction(); +const doc = { + _id: 1 +}; +assert.commandWorked(priSessionColl.insert(doc)); +rst.awaitReplication(); - jsTestLog("Test that prepare fails on a secondary"); - const txnNumber = NumberLong(priSession.getTxnNumber_forTesting()); - assert.commandFailedWithCode( - secSession.getDatabase('admin').adminCommand( - {prepareTransaction: 1, txnNumber: txnNumber, autocommit: false}), - ErrorCodes.NotMaster); +jsTestLog("Test that prepare fails on a secondary"); +const txnNumber = NumberLong(priSession.getTxnNumber_forTesting()); +assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand( + {prepareTransaction: 1, txnNumber: txnNumber, autocommit: false}), + ErrorCodes.NotMaster); - const prepareTimestamp = PrepareHelpers.prepareTransaction(priSession); - rst.awaitReplication(); +const prepareTimestamp = PrepareHelpers.prepareTransaction(priSession); +rst.awaitReplication(); - jsTestLog("Test that prepared commit fails on a secondary"); - // Add 1 to the increment so that the commitTimestamp is "after" the prepareTimestamp. - const commitTimestamp = Timestamp(prepareTimestamp.getTime(), prepareTimestamp.getInc() + 1); - assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand({ - commitTransaction: 1, - commitTimestamp: commitTimestamp, - txnNumber: txnNumber, - autocommit: false - }), - ErrorCodes.NotMaster); +jsTestLog("Test that prepared commit fails on a secondary"); +// Add 1 to the increment so that the commitTimestamp is "after" the prepareTimestamp. +const commitTimestamp = Timestamp(prepareTimestamp.getTime(), prepareTimestamp.getInc() + 1); +assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand({ + commitTransaction: 1, + commitTimestamp: commitTimestamp, + txnNumber: txnNumber, + autocommit: false +}), + ErrorCodes.NotMaster); - jsTestLog("Test that prepared abort fails on a secondary"); - assert.commandFailedWithCode( - secSession.getDatabase('admin').adminCommand( - {abortTransaction: 1, txnNumber: txnNumber, autocommit: false}), - ErrorCodes.NotMaster); +jsTestLog("Test that prepared abort fails on a secondary"); +assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand( + {abortTransaction: 1, txnNumber: txnNumber, autocommit: false}), + ErrorCodes.NotMaster); - jsTestLog("Test that we can still commit the transaction"); - assert.commandWorked(PrepareHelpers.commitTransaction(priSession, commitTimestamp)); - rst.awaitReplication(); - assert.docEq(doc, testDB[collName].findOne()); - assert.eq(1, testDB[collName].find().itcount()); - assert.docEq(doc, secondary.getDB(dbName)[collName].findOne()); - assert.eq(1, secondary.getDB(dbName)[collName].find().itcount()); +jsTestLog("Test that we can still commit the transaction"); +assert.commandWorked(PrepareHelpers.commitTransaction(priSession, commitTimestamp)); +rst.awaitReplication(); +assert.docEq(doc, testDB[collName].findOne()); +assert.eq(1, testDB[collName].find().itcount()); +assert.docEq(doc, secondary.getDB(dbName)[collName].findOne()); +assert.eq(1, secondary.getDB(dbName)[collName].find().itcount()); - rst.stopSet(); +rst.stopSet(); })(); |