diff options
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r-- | src/mongo/db/pipeline/document_source_change_stream_test.cpp | 45 |
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); |