summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-16 11:17:55 -0400
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-21 11:56:14 -0400
commit8f269656dc3365d4db69d5e127279ac23b82f498 (patch)
tree1dcb6f76110ddd75d831906e2af6dcc8168ba5fc /src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
parent561169684e8160d2f738ba94b404f14c9115dcd1 (diff)
downloadmongo-8f269656dc3365d4db69d5e127279ac23b82f498.tar.gz
SERVER-42834: Register an onRollback handler when adding a drop pending namespace.
Diffstat (limited to 'src/mongo/db/repl/drop_pending_collection_reaper_test.cpp')
-rw-r--r--src/mongo/db/repl/drop_pending_collection_reaper_test.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp b/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
index 43fb891728f..0ac9f2071e6 100644
--- a/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
+++ b/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
@@ -118,7 +118,7 @@ TEST_F(DropPendingCollectionReaperTest, AddDropPendingNamespaceAcceptsNullDropOp
OpTime nullDropOpTime;
auto dpns = NamespaceString("test.foo").makeDropPendingNamespace(nullDropOpTime);
DropPendingCollectionReaper reaper(_storageInterface.get());
- reaper.addDropPendingNamespace(nullDropOpTime, dpns);
+ reaper.addDropPendingNamespace(makeOpCtx().get(), nullDropOpTime, dpns);
ASSERT_EQUALS(nullDropOpTime, *reaper.getEarliestDropOpTime());
}
@@ -134,12 +134,12 @@ TEST_F(DropPendingCollectionReaperTest,
OpTime opTime({Seconds(100), 0}, 1LL);
auto dpns = NamespaceString("test.foo").makeDropPendingNamespace(opTime);
- reaper.addDropPendingNamespace(opTime, dpns);
- reaper.addDropPendingNamespace(opTime,
- NamespaceString("test.bar").makeDropPendingNamespace(opTime));
+ auto opCtx = makeOpCtx();
+ reaper.addDropPendingNamespace(opCtx.get(), opTime, dpns);
+ reaper.addDropPendingNamespace(
+ opCtx.get(), opTime, NamespaceString("test.bar").makeDropPendingNamespace(opTime));
// Drop all collections managed by reaper and confirm number of drops.
- auto opCtx = makeOpCtx();
reaper.dropCollectionsOlderThan(opCtx.get(), opTime);
ASSERT_EQUALS(2U, numCollectionsDropped);
}
@@ -150,8 +150,9 @@ DEATH_TEST_F(DropPendingCollectionReaperTest,
OpTime opTime({Seconds(100), 0}, 1LL);
auto dpns = NamespaceString("test.foo").makeDropPendingNamespace(opTime);
DropPendingCollectionReaper reaper(_storageInterface.get());
- reaper.addDropPendingNamespace(opTime, dpns);
- reaper.addDropPendingNamespace(opTime, dpns);
+ auto opCtx = makeOpCtx();
+ reaper.addDropPendingNamespace(opCtx.get(), opTime, dpns);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime, dpns);
}
TEST_F(DropPendingCollectionReaperTest,
@@ -176,11 +177,11 @@ TEST_F(DropPendingCollectionReaperTest,
// getEarliestDropOpTime() returns earliest optime.
DropPendingCollectionReaper reaper(_storageInterface.get());
ASSERT_FALSE(reaper.getEarliestDropOpTime());
- reaper.addDropPendingNamespace(opTime[1], dpns[1]);
- reaper.addDropPendingNamespace(opTime[0], dpns[0]);
- reaper.addDropPendingNamespace(opTime[2], dpns[2]);
- reaper.addDropPendingNamespace(opTime[3], dpns[3]);
- reaper.addDropPendingNamespace(opTime[4], dpns[4]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[1], dpns[1]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[0], dpns[0]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[2], dpns[2]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[3], dpns[3]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[4], dpns[4]);
ASSERT_EQUALS(opTime[0], *reaper.getEarliestDropOpTime());
// Committed optime before first drop optime has no effect.
@@ -215,9 +216,9 @@ TEST_F(DropPendingCollectionReaperTest, DropCollectionsOlderThanHasNoEffectIfCol
auto dpns = ns.makeDropPendingNamespace(optime);
DropPendingCollectionReaper reaper(_storageInterface.get());
- reaper.addDropPendingNamespace(optime, dpns);
auto opCtx = makeOpCtx();
+ reaper.addDropPendingNamespace(opCtx.get(), optime, dpns);
reaper.dropCollectionsOlderThan(opCtx.get(), optime);
}
@@ -230,9 +231,9 @@ TEST_F(DropPendingCollectionReaperTest, DropCollectionsOlderThanLogsDropCollecti
StorageInterfaceMock storageInterfaceMock;
DropPendingCollectionReaper reaper(&storageInterfaceMock);
- reaper.addDropPendingNamespace(optime, dpns);
-
auto opCtx = makeOpCtx();
+
+ reaper.addDropPendingNamespace(opCtx.get(), optime, dpns);
startCapturingLogMessages();
reaper.dropCollectionsOlderThan(opCtx.get(), optime);
stopCapturingLogMessages();
@@ -259,9 +260,9 @@ TEST_F(DropPendingCollectionReaperTest,
};
DropPendingCollectionReaper reaper(&storageInterfaceMock);
- reaper.addDropPendingNamespace(optime, dpns);
auto opCtx = makeOpCtx();
+ reaper.addDropPendingNamespace(opCtx.get(), optime, dpns);
reaper.dropCollectionsOlderThan(opCtx.get(), optime);
ASSERT_EQUALS(dpns, droppedNss);
@@ -286,9 +287,9 @@ TEST_F(DropPendingCollectionReaperTest, RollBackDropPendingCollection) {
}
DropPendingCollectionReaper reaper(_storageInterface.get());
- reaper.addDropPendingNamespace(opTime[0], dpns[0]);
- reaper.addDropPendingNamespace(opTime[1], dpns[1]);
- reaper.addDropPendingNamespace(opTime[2], dpns[2]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[0], dpns[0]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[1], dpns[1]);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[2], dpns[2]);
// Rolling back at an optime not in the list returns false.
ASSERT_FALSE(
@@ -318,7 +319,7 @@ TEST_F(DropPendingCollectionReaperTest, RollBackDropPendingCollection) {
NamespaceString ns4 = NamespaceString("test", "coll4");
NamespaceString dpns4 = ns4.makeDropPendingNamespace(opTime[1]);
ASSERT_OK(_storageInterface->createCollection(opCtx.get(), dpns4, generateOptionsWithUuid()));
- reaper.addDropPendingNamespace(opTime[1], dpns4);
+ reaper.addDropPendingNamespace(opCtx.get(), opTime[1], dpns4);
ASSERT_TRUE(reaper.rollBackDropPendingCollection(opCtx.get(), opTime[1], ns[1]));
ASSERT_EQUALS(opTime[1], *reaper.getEarliestDropOpTime());
ASSERT_TRUE(collectionExists(opCtx.get(), dpns[0]));