summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert.bosch@mongodb.com>2019-09-12 22:56:09 +0000
committerevergreen <evergreen@mongodb.com>2019-09-12 22:56:09 +0000
commit268ab18867527611aac1b515dbc90e6f588879e0 (patch)
treeeca35a7d4d27a3dcdc6b7464516766b773ceb67a
parent6922691bee2575455d666b5d6d13ff73fc315c53 (diff)
downloadmongo-268ab18867527611aac1b515dbc90e6f588879e0.tar.gz
SERVER-43238 Tolerate clock jitter on Windows for d_concurrency_test
-rw-r--r--src/mongo/db/concurrency/d_concurrency_test.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp
index ebe288562c9..0677491d314 100644
--- a/src/mongo/db/concurrency/d_concurrency_test.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_test.cpp
@@ -57,6 +57,11 @@ namespace mongo {
namespace {
const int kMaxStressThreads = 32; // max number of threads to use for lock stress
+#ifdef _WIN32
+const auto kMaxClockJitterMillis = Milliseconds(100); // max backward jumps to tolerate
+#else
+const auto kMaxClockJitterMillis = Milliseconds(0);
+#endif
/**
* A RAII object that instantiates a TicketHolder that limits number of allowed global lock
@@ -1435,7 +1440,7 @@ TEST_F(DConcurrencyTestFixture, Throttling) {
Date_t t2 = Date_t::now();
// Test that the timeout did result in at least the requested wait.
- ASSERT_GTE(t2 - t1, timeoutMillis);
+ ASSERT_GTE(t2 - t1 + kMaxClockJitterMillis, timeoutMillis);
// Timeouts should be reasonably immediate. In maxTries attempts at least one test should be
// able to complete within a second, as the theoretical test duration is less than 50 ms.
@@ -1719,7 +1724,7 @@ TEST_F(DConcurrencyTestFixture, DBLockTimeout) {
AssertionException,
ErrorCodes::LockTimeout);
Date_t t2 = Date_t::now();
- ASSERT_GTE(t2 - t1, Milliseconds(timeoutMillis));
+ ASSERT_GTE(t2 - t1 + kMaxClockJitterMillis, Milliseconds(timeoutMillis));
}
TEST_F(DConcurrencyTestFixture, DBLockTimeoutDueToGlobalLock) {
@@ -1737,7 +1742,7 @@ TEST_F(DConcurrencyTestFixture, DBLockTimeoutDueToGlobalLock) {
AssertionException,
ErrorCodes::LockTimeout);
Date_t t2 = Date_t::now();
- ASSERT_GTE(t2 - t1, Milliseconds(timeoutMillis));
+ ASSERT_GTE(t2 - t1 + kMaxClockJitterMillis, Milliseconds(timeoutMillis));
}
TEST_F(DConcurrencyTestFixture, CollectionLockInInterruptedContextThrowsEvenWhenUncontested) {
@@ -1806,8 +1811,7 @@ TEST_F(DConcurrencyTestFixture, CollectionLockTimeout) {
AssertionException,
ErrorCodes::LockTimeout);
Date_t t2 = Date_t::now();
- // 2 terms both can have .9ms rounded away, so we adjust by + 1.
- ASSERT_GTE(t2 - t1 + Milliseconds(1), Milliseconds(timeoutMillis));
+ ASSERT_GTE(t2 - t1 + kMaxClockJitterMillis, Milliseconds(timeoutMillis));
}
TEST_F(DConcurrencyTestFixture, CompatibleFirstWithSXIS) {