summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
authorXiangyu Yao <xiangyu.yao@mongodb.com>2019-06-17 21:04:19 -0400
committerXiangyu Yao <xiangyu.yao@mongodb.com>2019-06-20 20:16:54 -0400
commitf736289e83bf517fb8bac3155f2955e11ee5ae67 (patch)
tree8385c762615c2c1d8c7577160bd67ed8c2b9e16b /src/mongo/db/pipeline
parentd7703787784e8d7ad0980e18cbb6800022c58c97 (diff)
downloadmongo-f736289e83bf517fb8bac3155f2955e11ee5ae67.tar.gz
SERVER-41583 Refactor the registration and de-registration of collection and catalog entry
(cherry picked from commit 5eda33f9fa40a1a17f9f63f904a8c147700d648c)
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 016d7132283..2bf1da5aed6 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -418,9 +418,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtOperationTimeAndResumeAfter
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
CollectionCatalog::get(getExpCtx()->opCtx)
- .registerCatalogEntry(testUuid(), std::move(catalogEntry));
- CollectionCatalog::get(expCtx->opCtx)
- .onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ .registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
ASSERT_THROWS_CODE(
DSChangeStream::createFromBson(
@@ -443,8 +441,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAfterAndResumeAfterOptions) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
auto& catalog = CollectionCatalog::get(opCtx);
- catalog.registerCatalogEntry(testUuid(), std::move(catalogEntry));
- catalog.onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ catalog.registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
ASSERT_THROWS_CODE(
DSChangeStream::createFromBson(
@@ -467,8 +464,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtOperationTimeAndStartAfterO
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
auto& catalog = CollectionCatalog::get(opCtx);
- catalog.registerCatalogEntry(testUuid(), std::move(catalogEntry));
- catalog.onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ catalog.registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
ASSERT_THROWS_CODE(
DSChangeStream::createFromBson(
@@ -491,8 +487,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectResumeAfterWithResumeTokenMissingUUID)
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
auto& catalog = CollectionCatalog::get(opCtx);
- catalog.registerCatalogEntry(testUuid(), std::move(catalogEntry));
- catalog.onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ catalog.registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
ASSERT_THROWS_CODE(
DSChangeStream::createFromBson(
@@ -1520,9 +1515,8 @@ TEST_F(ChangeStreamStageTest, DocumentKeyShouldIncludeShardKeyFromResumeToken) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
BSONObj o2 = BSON("_id" << 1 << "shardKey" << 2);
auto resumeToken = makeResumeToken(ts, uuid, o2);
@@ -1568,9 +1562,8 @@ TEST_F(ChangeStreamStageTest, DocumentKeyShouldNotIncludeShardKeyFieldsIfNotPres
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
BSONObj o2 = BSON("_id" << 1 << "shardKey" << 2);
auto resumeToken = makeResumeToken(ts, uuid, o2);
@@ -1613,9 +1606,8 @@ TEST_F(ChangeStreamStageTest, ResumeAfterFailsIfResumeTokenDoesNotContainUUID) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
// Create a resume token from only the timestamp.
auto resumeToken = makeResumeToken(ts);
@@ -1670,9 +1662,7 @@ TEST_F(ChangeStreamStageTest, ResumeAfterWithTokenFromInvalidateShouldFail) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
CollectionCatalog::get(getExpCtx()->opCtx)
- .registerCatalogEntry(testUuid(), std::move(catalogEntry));
- CollectionCatalog::get(expCtx->opCtx)
- .onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ .registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
const auto resumeTokenInvalidate =
makeResumeToken(kDefaultTs,
@@ -2108,9 +2098,8 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldIncludeShardKeyFromResumeToken)
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
BSONObj o2 = BSON("_id" << 1 << "shardKey" << 2);
auto resumeToken = makeResumeToken(ts, uuid, o2);
@@ -2147,9 +2136,8 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldNotIncludeShardKeyFieldsIfNotPr
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
BSONObj o2 = BSON("_id" << 1 << "shardKey" << 2);
auto resumeToken = makeResumeToken(ts, uuid, o2);
@@ -2187,9 +2175,8 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldNotIncludeShardKeyIfResumeToken
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
// Create a resume token from only the timestamp.
auto resumeToken = makeResumeToken(ts);
@@ -2227,9 +2214,7 @@ TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromInvalidateShouldFail) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
CollectionCatalog::get(getExpCtx()->opCtx)
- .registerCatalogEntry(testUuid(), std::move(catalogEntry));
- CollectionCatalog::get(expCtx->opCtx)
- .onCreateCollection(expCtx->opCtx, std::move(collection), testUuid());
+ .registerCollection(testUuid(), std::move(catalogEntry), std::move(collection));
const auto resumeTokenInvalidate =
makeResumeToken(kDefaultTs,
@@ -2251,9 +2236,8 @@ TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromDropDatabase) {
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
// Create a resume token from only the timestamp, similar to a 'dropDatabase' entry.
auto resumeToken = makeResumeToken(
@@ -2283,9 +2267,8 @@ TEST_F(ChangeStreamStageDBTest, StartAfterSucceedsEvenIfResumeTokenDoesNotContai
auto collection = std::make_unique<CollectionMock>(nss);
auto catalogEntry = std::make_unique<CollectionCatalogEntryMock>(nss.ns());
- CollectionCatalog::get(getExpCtx()->opCtx).registerCatalogEntry(uuid, std::move(catalogEntry));
CollectionCatalog::get(getExpCtx()->opCtx)
- .onCreateCollection(getExpCtx()->opCtx, std::move(collection), uuid);
+ .registerCollection(uuid, std::move(catalogEntry), std::move(collection));
// Create a resume token from only the timestamp, similar to a 'dropDatabase' entry.
auto resumeToken = makeResumeToken(kDefaultTs);