diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
commit | c1a45ebbb0530e3d0201321d725527f1eb83ffce (patch) | |
tree | f523079dc5ded3052eefbdcaae424b7502df5b25 /src/mongo/db/transaction_participant_test.cpp | |
parent | c9599d8610c3da0b7c3da65667aff821063cf5b9 (diff) | |
download | mongo-c1a45ebbb0530e3d0201321d725527f1eb83ffce.tar.gz |
Apply formatting per `clang-format-7.0.1`
Diffstat (limited to 'src/mongo/db/transaction_participant_test.cpp')
-rw-r--r-- | src/mongo/db/transaction_participant_test.cpp | 187 |
1 files changed, 93 insertions, 94 deletions
diff --git a/src/mongo/db/transaction_participant_test.cpp b/src/mongo/db/transaction_participant_test.cpp index f4764ad0e8c..047310244f5 100644 --- a/src/mongo/db/transaction_participant_test.cpp +++ b/src/mongo/db/transaction_participant_test.cpp @@ -376,11 +376,11 @@ TEST_F(TxnParticipantTest, StashAndUnstashResources) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; // Perform initial unstash which sets up a WriteUnitOfWork. @@ -1154,20 +1154,19 @@ TEST_F(TxnParticipantTest, CannotStartNewTransactionWhilePreparedTransactionInPr auto guard = makeGuard([&]() { OperationContextSession::checkOut(opCtx()); }); // Try to start a new transaction while there is already a prepared transaction on the // session. This should fail with a PreparedTransactionInProgress error. - runFunctionFromDifferentOpCtx([ - lsid = *opCtx()->getLogicalSessionId(), - txnNumberToStart = *opCtx()->getTxnNumber() + 1 - ](OperationContext * newOpCtx) { - newOpCtx->setLogicalSessionId(lsid); - newOpCtx->setTxnNumber(txnNumberToStart); - - MongoDOperationContextSession ocs(newOpCtx); - auto txnParticipant = TransactionParticipant::get(newOpCtx); - ASSERT_THROWS_CODE( - txnParticipant.beginOrContinue(newOpCtx, txnNumberToStart, false, true), - AssertionException, - ErrorCodes::PreparedTransactionInProgress); - }); + runFunctionFromDifferentOpCtx( + [lsid = *opCtx()->getLogicalSessionId(), + txnNumberToStart = *opCtx()->getTxnNumber() + 1](OperationContext* newOpCtx) { + newOpCtx->setLogicalSessionId(lsid); + newOpCtx->setTxnNumber(txnNumberToStart); + + MongoDOperationContextSession ocs(newOpCtx); + auto txnParticipant = TransactionParticipant::get(newOpCtx); + ASSERT_THROWS_CODE( + txnParticipant.beginOrContinue(newOpCtx, txnNumberToStart, false, true), + AssertionException, + ErrorCodes::PreparedTransactionInProgress); + }); } ASSERT_FALSE(txnParticipant.transactionIsAborted()); @@ -1278,11 +1277,11 @@ TEST_F(TxnParticipantTest, StashInNestedSessionIsANoop) { // Set the readConcern on the OperationContext. repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; // Perform initial unstash, which sets up a WriteUnitOfWork. @@ -2672,11 +2671,11 @@ TEST_F(TransactionsMetricsTest, ReportStashedResources) { std::move(clientMetadata.getValue())); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; // Perform initial unstash which sets up a WriteUnitOfWork. @@ -2759,11 +2758,11 @@ TEST_F(TransactionsMetricsTest, ReportUnstashedResources) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; // Perform initial unstash which sets up a WriteUnitOfWork. @@ -3108,11 +3107,11 @@ TEST_F(TransactionsMetricsTest, TestTransactionInfoForLogAfterCommit) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; @@ -3148,11 +3147,11 @@ TEST_F(TransactionsMetricsTest, TestPreparedTransactionInfoForLogAfterCommit) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; @@ -3190,11 +3189,11 @@ TEST_F(TransactionsMetricsTest, TestTransactionInfoForLogAfterAbort) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3231,11 +3230,11 @@ TEST_F(TransactionsMetricsTest, TestPreparedTransactionInfoForLogAfterAbort) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; // Prepare the transaction and extend the duration in the prepared state. @@ -3269,11 +3268,11 @@ DEATH_TEST_F(TransactionsMetricsTest, TestTransactionInfoForLogWithNoLockerInfoS auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3293,11 +3292,11 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowCommit) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3331,11 +3330,11 @@ TEST_F(TransactionsMetricsTest, LogPreparedTransactionInfoAfterSlowCommit) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3368,11 +3367,11 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowAbort) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3411,11 +3410,11 @@ TEST_F(TransactionsMetricsTest, LogPreparedTransactionInfoAfterSlowAbort) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3457,11 +3456,11 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterExceptionInPrepare) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3504,11 +3503,11 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowStashedAbort) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); @@ -3589,11 +3588,11 @@ TEST_F(TxnParticipantTest, RollbackResetsInMemoryStateOfPreparedTransaction) { auto sessionCheckout = checkOutSession(); repl::ReadConcernArgs readConcernArgs; - ASSERT_OK(readConcernArgs.initialize(BSON("find" - << "test" - << repl::ReadConcernArgs::kReadConcernFieldName - << BSON(repl::ReadConcernArgs::kLevelFieldName - << "snapshot")))); + ASSERT_OK( + readConcernArgs.initialize(BSON("find" + << "test" << repl::ReadConcernArgs::kReadConcernFieldName + << BSON(repl::ReadConcernArgs::kLevelFieldName + << "snapshot")))); repl::ReadConcernArgs::get(opCtx()) = readConcernArgs; auto txnParticipant = TransactionParticipant::get(opCtx()); |