summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorNathan Louie <nathan.louie@10gen.com>2018-06-22 16:46:45 -0400
committerNathan Louie <nathan.louie@10gen.com>2018-06-25 17:21:30 -0400
commita4cc866475278e943d9b840b99185667158db59d (patch)
tree958324a20735fd5a16be23f709b97e11fd2e54d2 /src/mongo
parent6e78c920ab239e415700fedba49d3c08709461e4 (diff)
downloadmongo-a4cc866475278e943d9b840b99185667158db59d.tar.gz
test formatting
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/session_test.cpp88
1 files changed, 28 insertions, 60 deletions
diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp
index 59294301ec7..248da45d091 100644
--- a/src/mongo/db/session_test.cpp
+++ b/src/mongo/db/session_test.cpp
@@ -1473,53 +1473,37 @@ TEST_F(SessionTest, TrackTotalActiveAndInactiveTransactionsWithCommit) {
opCtx()->setLogicalSessionId(sessionId);
opCtx()->setTxnNumber(txnNum);
- unsigned long long firstActiveCounter =
+ unsigned long long beforeActiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long firstInactiveCounter =
+ unsigned long long beforeInactiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
// Tests that the first unstash only increments the active counter only.
session.beginOrContinueTxn(opCtx(), txnNum, false, true, "testDB", "insert");
session.unstashTransactionResources(opCtx(), "insert");
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), firstActiveCounter + 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), firstInactiveCounter);
-
- unsigned long long secondActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long secondInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
+ beforeActiveCounter + 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
// Tests that stashing the transaction resources decrements active counter and increments
// inactive counter.
{ Lock::GlobalLock lk(opCtx(), MODE_IX, Date_t::now(), Lock::InterruptBehavior::kThrow); }
session.stashTransactionResources(opCtx());
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
- secondActiveCounter - 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), beforeActiveCounter);
ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(),
- secondInactiveCounter + 1U);
-
- unsigned long long thirdActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long thirdInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ beforeInactiveCounter + 1U);
// Tests that the second unstash increments the active counter and decrements the inactive
// counter.
session.unstashTransactionResources(opCtx(), "insert");
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), thirdActiveCounter + 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(),
- thirdInactiveCounter - 1U);
-
- unsigned long long fourthActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long fourthInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
+ beforeActiveCounter + 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
// Tests that committing a transaction decrements the active counter only.
session.commitTransaction(opCtx());
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
- fourthActiveCounter - 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), fourthInactiveCounter);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), beforeActiveCounter);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
}
TEST_F(SessionTest, TrackTotalActiveAndInactiveTransactionsWithStashedAbort) {
@@ -1531,41 +1515,30 @@ TEST_F(SessionTest, TrackTotalActiveAndInactiveTransactionsWithStashedAbort) {
opCtx()->setLogicalSessionId(sessionId);
opCtx()->setTxnNumber(txnNum);
- unsigned long long firstActiveCounter =
+ unsigned long long beforeActiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long firstInactiveCounter =
+ unsigned long long beforeInactiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
// Tests that the first unstash only increments the active counter only.
session.beginOrContinueTxn(opCtx(), txnNum, false, true, "testDB", "insert");
session.unstashTransactionResources(opCtx(), "insert");
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), firstActiveCounter + 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), firstInactiveCounter);
-
- unsigned long long secondActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long secondInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
+ beforeActiveCounter + 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
// Tests that stashing the transaction resources decrements active counter and increments
// inactive counter.
{ Lock::GlobalLock lk(opCtx(), MODE_IX, Date_t::now(), Lock::InterruptBehavior::kThrow); }
session.stashTransactionResources(opCtx());
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
- secondActiveCounter - 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), beforeActiveCounter);
ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(),
- secondInactiveCounter + 1U);
-
- unsigned long long thirdActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long thirdInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ beforeInactiveCounter + 1U);
// Tests that aborting a stashed transaction decrements the inactive counter only.
session.abortArbitraryTransaction();
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), thirdActiveCounter);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(),
- thirdInactiveCounter - 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), beforeActiveCounter);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
}
TEST_F(SessionTest, TrackTotalActiveAndInactiveTransactionsWithUnstashedAbort) {
@@ -1577,27 +1550,22 @@ TEST_F(SessionTest, TrackTotalActiveAndInactiveTransactionsWithUnstashedAbort) {
opCtx()->setLogicalSessionId(sessionId);
opCtx()->setTxnNumber(txnNum);
- unsigned long long firstActiveCounter =
+ unsigned long long beforeActiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long firstInactiveCounter =
+ unsigned long long beforeInactiveCounter =
ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
// Tests that the first unstash only increments the active counter only.
session.beginOrContinueTxn(opCtx(), txnNum, false, true, "testDB", "insert");
session.unstashTransactionResources(opCtx(), "insert");
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), firstActiveCounter + 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), firstInactiveCounter);
-
- unsigned long long secondActiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentActive();
- unsigned long long secondInactiveCounter =
- ServerTransactionsMetrics::get(opCtx())->getCurrentInactive();
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
+ beforeActiveCounter + 1U);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
// Tests that aborting a stashed transaction decrements the active counter only.
session.abortArbitraryTransaction();
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(),
- secondActiveCounter - 1U);
- ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), secondInactiveCounter);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentActive(), beforeActiveCounter);
+ ASSERT_EQ(ServerTransactionsMetrics::get(opCtx())->getCurrentInactive(), beforeInactiveCounter);
}
/**