diff options
Diffstat (limited to 'src/mongo/db/storage/recovery_unit_test_harness.cpp')
-rw-r--r-- | src/mongo/db/storage/recovery_unit_test_harness.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mongo/db/storage/recovery_unit_test_harness.cpp b/src/mongo/db/storage/recovery_unit_test_harness.cpp index 86382c10785..198dfc0c657 100644 --- a/src/mongo/db/storage/recovery_unit_test_harness.cpp +++ b/src/mongo/db/storage/recovery_unit_test_harness.cpp @@ -139,6 +139,38 @@ TEST_F(RecoveryUnitTestHarness, CheckInActiveTxnWithAbort) { ASSERT_FALSE(ru->inActiveTxn()); } +TEST_F(RecoveryUnitTestHarness, BeginningUnitOfWorkDoesNotIncrementSnapshotId) { + auto snapshotIdBefore = ru->getSnapshotId(); + ru->beginUnitOfWork(opCtx.get()); + ASSERT_EQ(snapshotIdBefore, ru->getSnapshotId()); + ru->abortUnitOfWork(); +} + +TEST_F(RecoveryUnitTestHarness, NewlyAllocatedRecoveryUnitHasNewSnapshotId) { + auto newRu = harnessHelper->newRecoveryUnit(); + ASSERT_NE(newRu->getSnapshotId(), ru->getSnapshotId()); +} + +TEST_F(RecoveryUnitTestHarness, AbandonSnapshotIncrementsSnapshotId) { + auto snapshotIdBefore = ru->getSnapshotId(); + ru->abandonSnapshot(); + ASSERT_NE(snapshotIdBefore, ru->getSnapshotId()); +} + +TEST_F(RecoveryUnitTestHarness, CommitUnitOfWorkIncrementsSnapshotId) { + auto snapshotIdBefore = ru->getSnapshotId(); + ru->beginUnitOfWork(opCtx.get()); + ru->commitUnitOfWork(); + ASSERT_NE(snapshotIdBefore, ru->getSnapshotId()); +} + +TEST_F(RecoveryUnitTestHarness, AbortUnitOfWorkIncrementsSnapshotId) { + auto snapshotIdBefore = ru->getSnapshotId(); + ru->beginUnitOfWork(opCtx.get()); + ru->abortUnitOfWork(); + ASSERT_NE(snapshotIdBefore, ru->getSnapshotId()); +} + DEATH_TEST_F(RecoveryUnitTestHarness, RegisterChangeMustBeInUnitOfWork, "invariant") { int count = 0; opCtx->recoveryUnit()->registerChange(std::make_unique<TestChange>(&count)); |