diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2020-01-08 15:35:46 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-08 15:35:46 +0000 |
commit | e3dd9e80e38f3528bc50c3e1115c46a0687885fa (patch) | |
tree | f8a9a724ed170e45ecf1f0cc73c086ad82c45c0e /src/mongo/db/read_write_concern_defaults_test.cpp | |
parent | d401d80a2c89d89db26750956cb3b3261e595a34 (diff) | |
download | mongo-e3dd9e80e38f3528bc50c3e1115c46a0687885fa.tar.gz |
SERVER-45282 Unify how mongos and mongod default RWC caches handle deleted defaults document
Diffstat (limited to 'src/mongo/db/read_write_concern_defaults_test.cpp')
-rw-r--r-- | src/mongo/db/read_write_concern_defaults_test.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/db/read_write_concern_defaults_test.cpp b/src/mongo/db/read_write_concern_defaults_test.cpp index 56e98f0cd6c..13532a03325 100644 --- a/src/mongo/db/read_write_concern_defaults_test.cpp +++ b/src/mongo/db/read_write_concern_defaults_test.cpp @@ -480,5 +480,29 @@ TEST_F(ReadWriteConcernDefaultsTestWithClusterTime, ASSERT_LT(*oldDefaults.getLocalSetTime(), *newDefaults.getLocalSetTime()); } +TEST_F(ReadWriteConcernDefaultsTestWithClusterTime, TestRefreshDefaultsWithDeletedDefaults) { + RWConcernDefault origDefaults; + origDefaults.setEpoch(Timestamp(10, 20)); + origDefaults.setSetTime(Date_t::fromMillisSinceEpoch(1234)); + _lookupMock.setLookupCallReturnValue(std::move(origDefaults)); + + auto origCachedDefaults = _rwcd.getDefault(operationContext()); + ASSERT_EQ(Timestamp(10, 20), *origCachedDefaults.getEpoch()); + ASSERT_EQ(Date_t::fromMillisSinceEpoch(1234), *origCachedDefaults.getSetTime()); + + getClock()->reserveTicks(1); + getMockClockSource()->advance(Milliseconds(1)); + + _lookupMock.setLookupCallReturnValue(RWConcernDefault()); + + _rwcd.refreshIfNecessary(operationContext()); + + // The cache should now contain default constructed defaults. + auto newCachedDefaults = _rwcd.getDefault(operationContext()); + ASSERT(!newCachedDefaults.getEpoch()); + ASSERT(!newCachedDefaults.getSetTime()); + ASSERT_LT(*origCachedDefaults.getLocalSetTime(), *newCachedDefaults.getLocalSetTime()); +} + } // namespace } // namespace mongo |