diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2020-01-24 12:47:49 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-01-27 16:21:10 +0000 |
commit | 678eadde4a2640a33cd288a565f74366433fb44f (patch) | |
tree | 115727bf635909991a196ed2b1d8489cc6b3f383 | |
parent | f55f71d54e0ef0fd22fc4a6a30fdcd4934405415 (diff) | |
download | mongo-678eadde4a2640a33cd288a565f74366433fb44f.tar.gz |
SERVER-45761 Use same clock for test and working code in session_test [v4.0]
-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; |