summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
diff options
context:
space:
mode:
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.cpp24
1 files changed, 21 insertions, 3 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 8f733d8ca6e..024771ec949 100644
--- a/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
+++ b/src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
@@ -30,8 +30,10 @@
#include <memory>
+#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/op_observer_registry.h"
#include "mongo/db/repl/drop_pending_collection_reaper.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
@@ -60,6 +62,14 @@ protected:
*/
bool collectionExists(OperationContext* opCtx, const NamespaceString& nss);
+ /**
+ * Generates a default CollectionOptions object with a UUID. These options should be used
+ * when creating a collection in this test because otherwise, collections will not be created
+ * with UUIDs. All collections are expected to have UUIDs.
+ * TODO(SERVER-31540) Remove once UUID is no longer a boost::optional in CollectionOptions.
+ */
+ CollectionOptions generateOptionsWithUuid();
+
std::unique_ptr<StorageInterface> _storageInterface;
};
@@ -80,6 +90,12 @@ bool DropPendingCollectionReaperTest::collectionExists(OperationContext* opCtx,
return _storageInterface->getCollectionCount(opCtx, nss).isOK();
}
+CollectionOptions DropPendingCollectionReaperTest::generateOptionsWithUuid() {
+ CollectionOptions options;
+ options.uuid = UUID::gen();
+ return options;
+}
+
ServiceContext::UniqueOperationContext makeOpCtx() {
return cc().makeOperationContext();
}
@@ -153,7 +169,8 @@ TEST_F(DropPendingCollectionReaperTest,
opTime[i] = OpTime({Seconds((i + 1) * 10), 0}, 1LL);
ns[i] = NamespaceString("test", str::stream() << "coll" << i);
dpns[i] = ns[i].makeDropPendingNamespace(opTime[i]);
- _storageInterface->createCollection(opCtx.get(), dpns[i], {}).transitional_ignore();
+ _storageInterface->createCollection(opCtx.get(), dpns[i], generateOptionsWithUuid())
+ .transitional_ignore();
}
// Add drop-pending namespaces with drop optimes out of order and check that
@@ -265,7 +282,8 @@ TEST_F(DropPendingCollectionReaperTest, RollBackDropPendingCollection) {
opTime[i] = OpTime({Seconds((i + 1) * 10), 0}, 1LL);
ns[i] = NamespaceString("test", str::stream() << "coll" << i);
dpns[i] = ns[i].makeDropPendingNamespace(opTime[i]);
- ASSERT_OK(_storageInterface->createCollection(opCtx.get(), dpns[i], {}));
+ ASSERT_OK(
+ _storageInterface->createCollection(opCtx.get(), dpns[i], generateOptionsWithUuid()));
}
DropPendingCollectionReaper reaper(_storageInterface.get());
@@ -300,7 +318,7 @@ TEST_F(DropPendingCollectionReaperTest, RollBackDropPendingCollection) {
// only removes a single collection from the list of drop-pending namespaces
NamespaceString ns4 = NamespaceString("test", "coll4");
NamespaceString dpns4 = ns4.makeDropPendingNamespace(opTime[1]);
- ASSERT_OK(_storageInterface->createCollection(opCtx.get(), dpns4, {}));
+ ASSERT_OK(_storageInterface->createCollection(opCtx.get(), dpns4, generateOptionsWithUuid()));
reaper.addDropPendingNamespace(opTime[1], dpns4);
ASSERT_TRUE(reaper.rollBackDropPendingCollection(opCtx.get(), opTime[1], ns[1]));
ASSERT_EQUALS(opTime[1], *reaper.getEarliestDropOpTime());