summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-07-29 09:32:44 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-07-29 12:25:04 -0400
commite6da060a704bd7c7eb62444ec47572c76a7b5e75 (patch)
treea181854ffbb22d5b2b18ff57ef9a6844766a55fc
parent474a1fa5589c345bdc426ac08b08c89e6305b6fb (diff)
downloadmongo-e6da060a704bd7c7eb62444ec47572c76a7b5e75.tar.gz
SERVER-42468 Always wait for the TransactionCoordinator to complete in the Metrics unit-tests
(cherry picked from commit 25242cc39477596e23ae0ab4d4fd21b63a2f3ed6)
-rw-r--r--src/mongo/db/s/transaction_coordinator_test.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/mongo/db/s/transaction_coordinator_test.cpp b/src/mongo/db/s/transaction_coordinator_test.cpp
index ad4554b406b..566f9453a20 100644
--- a/src/mongo/db/s/transaction_coordinator_test.cpp
+++ b/src/mongo/db/s/transaction_coordinator_test.cpp
@@ -1162,11 +1162,8 @@ public:
assertCommitSentAndRespondWithSuccess();
assertCommitSentAndRespondWithSuccess();
+ coordinator.onCompletion().get();
stopCapturingLogMessages();
-
- // Properly wait for the coordinator to finish all asynchronous tasks.
- auto future = coordinator.onCompletion();
- future.getNoThrow().ignore();
}
};
@@ -1605,8 +1602,9 @@ TEST_F(TransactionCoordinatorMetricsTest, SimpleTwoPhaseCommitRealCoordinator) {
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is logged since the coordination completed successfully.
stopCapturingLogMessages();
+
+ // Slow log line is logged since the coordination completed successfully.
ASSERT_EQUALS(1, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1648,8 +1646,9 @@ TEST_F(TransactionCoordinatorMetricsTest, CoordinatorIsCanceledWhileInactive) {
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1689,8 +1688,9 @@ TEST_F(TransactionCoordinatorMetricsTest, CoordinatorsAWSIsShutDownWhileCoordina
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1748,8 +1748,9 @@ TEST_F(TransactionCoordinatorMetricsTest,
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1810,8 +1811,9 @@ TEST_F(TransactionCoordinatorMetricsTest,
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1874,8 +1876,9 @@ TEST_F(TransactionCoordinatorMetricsTest,
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -1944,8 +1947,9 @@ TEST_F(TransactionCoordinatorMetricsTest,
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -2020,8 +2024,9 @@ TEST_F(TransactionCoordinatorMetricsTest, CoordinatorsAWSIsShutDownWhileCoordina
checkStats(stats, expectedStats);
checkMetrics(expectedMetrics);
- // Slow log line is not logged since the coordination did not complete successfully.
stopCapturingLogMessages();
+
+ // Slow log line is not logged since the coordination did not complete successfully.
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -2063,7 +2068,9 @@ TEST_F(TransactionCoordinatorMetricsTest, DoesNotLogTransactionsUnderSlowMSThres
assertCommitSentAndRespondWithSuccess();
assertCommitSentAndRespondWithSuccess();
+ coordinator.onCompletion().get();
stopCapturingLogMessages();
+
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -2093,7 +2100,9 @@ TEST_F(
assertCommitSentAndRespondWithSuccess();
assertCommitSentAndRespondWithSuccess();
+ coordinator.onCompletion().get();
stopCapturingLogMessages();
+
ASSERT_EQUALS(0, countLogLinesContaining("two-phase commit parameters:"));
}
@@ -2121,6 +2130,7 @@ TEST_F(TransactionCoordinatorMetricsTest, LogsTransactionsOverSlowMSThreshold) {
assertCommitSentAndRespondWithSuccess();
assertCommitSentAndRespondWithSuccess();
+ coordinator.onCompletion().get();
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("two-phase commit parameters:"));
@@ -2160,6 +2170,7 @@ TEST_F(TransactionCoordinatorMetricsTest, SlowLogLineIncludesTerminationCauseFor
assertAbortSentAndRespondWithSuccess();
assertAbortSentAndRespondWithSuccess();
+ coordinator.onCompletion().get();
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("terminationCause:aborted"));