diff options
author | Louis Williams <louis.williams@mongodb.com> | 2023-02-08 18:16:15 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-09 00:38:10 +0000 |
commit | d9886710402d1f3488ff90967992bf44d85fcdbc (patch) | |
tree | 52a90672a433a9281fa8759cf94050f0205ad0d0 /src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp | |
parent | a6181195a61db06b7b5439bf0d8bc5b2f4a1c0bb (diff) | |
download | mongo-d9886710402d1f3488ff90967992bf44d85fcdbc.tar.gz |
SERVER-73384 Fix broken Snapshot decoration tests
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp index 11513c44cb7..fb37ff83709 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp @@ -995,77 +995,64 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, AbandonSnapshotAbortMode) { ASSERT_EQ(0, strncmp(key, returnedKey, strlen(key))); } -size_t numOnOpenSnapshotCalled = 0; -size_t numOnCloseSnapshotCalled = 0; - class SnapshotTestDecoration { public: - SnapshotTestDecoration() { - numOnOpenSnapshotCalled++; + void hit() { + _hits++; } - ~SnapshotTestDecoration() { - numOnCloseSnapshotCalled++; + int getHits() { + return _hits; } + +private: + int _hits = 0; }; const RecoveryUnit::Snapshot::Decoration<SnapshotTestDecoration> getSnapshotDecoration = RecoveryUnit::Snapshot::declareDecoration<SnapshotTestDecoration>(); TEST_F(WiredTigerRecoveryUnitTestFixture, AbandonSnapshotChange) { - numOnOpenSnapshotCalled = 0; - numOnCloseSnapshotCalled = 0; - - // A snapshot is already open from when the RU was constructed. ASSERT(ru1->getSession()); - ASSERT_EQ(0, numOnOpenSnapshotCalled); - ASSERT_EQ(0, numOnCloseSnapshotCalled); + + getSnapshotDecoration(ru1->getSnapshot()).hit(); + ASSERT_EQ(1, getSnapshotDecoration(ru1->getSnapshot()).getHits()); ru1->abandonSnapshot(); - // A snapshot is opened after closing the last one. - ASSERT_EQ(1, numOnOpenSnapshotCalled); - ASSERT_EQ(1, numOnCloseSnapshotCalled); + // A snapshot is closed, reconstructing our decoration. + ASSERT_EQ(0, getSnapshotDecoration(ru1->getSnapshot()).getHits()); } TEST_F(WiredTigerRecoveryUnitTestFixture, CommitSnapshotChange) { - numOnOpenSnapshotCalled = 0; - numOnCloseSnapshotCalled = 0; - ru1->beginUnitOfWork(/*readOnly=*/false); - ASSERT_EQ(0, numOnOpenSnapshotCalled); - ASSERT_EQ(0, numOnCloseSnapshotCalled); - // A snapshot is already open from when the RU was constructed. + getSnapshotDecoration(ru1->getSnapshot()).hit(); + ASSERT_EQ(1, getSnapshotDecoration(ru1->getSnapshot()).getHits()); + ASSERT(ru1->getSession()); - ASSERT_EQ(0, numOnOpenSnapshotCalled); - ASSERT_EQ(0, numOnCloseSnapshotCalled); + + ASSERT_EQ(1, getSnapshotDecoration(ru1->getSnapshot()).getHits()); ru1->commitUnitOfWork(); - // A snapshot is opened after closing the last one. - ASSERT_EQ(1, numOnOpenSnapshotCalled); - ASSERT_EQ(1, numOnCloseSnapshotCalled); + // A snapshot is closed, reconstructing our decoration. + ASSERT_EQ(0, getSnapshotDecoration(ru1->getSnapshot()).getHits()); } TEST_F(WiredTigerRecoveryUnitTestFixture, AbortSnapshotChange) { - numOnOpenSnapshotCalled = 0; - numOnCloseSnapshotCalled = 0; - // A snapshot is already open from when the RU was constructed. ASSERT(ru1->getSession()); - ASSERT_EQ(0, numOnOpenSnapshotCalled); - ASSERT_EQ(0, numOnCloseSnapshotCalled); + getSnapshotDecoration(ru1->getSnapshot()).hit(); + ASSERT_EQ(1, getSnapshotDecoration(ru1->getSnapshot()).getHits()); ru1->beginUnitOfWork(/*readOnly=*/false); - ASSERT_EQ(0, numOnOpenSnapshotCalled); - ASSERT_EQ(0, numOnCloseSnapshotCalled); + ASSERT_EQ(1, getSnapshotDecoration(ru1->getSnapshot()).getHits()); ru1->abortUnitOfWork(); - // A snapshot is opened after closing the last one. - ASSERT_EQ(1, numOnOpenSnapshotCalled); - ASSERT_EQ(1, numOnCloseSnapshotCalled); + // A snapshot is closed, reconstructing our decoration. + ASSERT_EQ(0, getSnapshotDecoration(ru1->getSnapshot()).getHits()); } DEATH_TEST_REGEX_F(WiredTigerRecoveryUnitTestFixture, |