summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_change_stream_test.cpp
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-17 21:04:40 -0400
commit5eda33f9fa40a1a17f9f63f904a8c147700d648c (patch)
treecbc7fbce6ca1928f39eb61670cb7218e011362ae /src/mongo/db/pipeline/document_source_change_stream_test.cpp
parent0a9350795577342633b5d4ab5f3792851f6d5938 (diff)
downloadmongo-5eda33f9fa40a1a17f9f63f904a8c147700d648c.tar.gz
SERVER-41583 Refactor the registration and de-registration of collection and catalog entry
Diffstat (limited to 'src/mongo/db/pipeline/document_source_change_stream_test.cpp')
-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 40a55a2c2f8..cc1a9916609 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);