diff options
Diffstat (limited to 'src/mongo/db/session_test.cpp')
| -rw-r--r-- | src/mongo/db/session_test.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp index 5e8424db7c3..e16f0a74663 100644 --- a/src/mongo/db/session_test.cpp +++ b/src/mongo/db/session_test.cpp @@ -698,12 +698,9 @@ TEST_F(SessionTest, StashAndUnstashResources) { } TEST_F(SessionTest, ReportStashedResources) { - Date_t startTime = Date_t::now(); - - // Sleep a bit after recording the startTime but before starting the transaction to account for - // any clock discrepancy between the Date_t clock and the clock used to track the transaction - // stats start time. - mongo::sleepmillis(10); + // The transaction participant uses the precise clock source for timing, + // so ensure we use the same clock source for testing. + Date_t startTime = opCtx()->getServiceContext()->getPreciseClockSource()->now(); const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; @@ -803,12 +800,9 @@ TEST_F(SessionTest, ReportStashedResources) { } TEST_F(SessionTest, ReportUnstashedResources) { - Date_t startTime = Date_t::now(); - - // Sleep a bit after recording the startTime but before starting the transaction to account for - // any clock discrepancy between the Date_t clock and the clock used to track the transaction - // stats start time. - mongo::sleepmillis(10); + // The transaction participant uses the precise clock source for timing, + // so ensure we use the same clock source for testing. + Date_t startTime = opCtx()->getServiceContext()->getPreciseClockSource()->now(); const auto sessionId = makeLogicalSessionIdForTest(); const TxnNumber txnNum = 20; |
