diff options
Diffstat (limited to 'src/mongo/db/pipeline/pipeline_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/pipeline_test.cpp | 193 |
1 files changed, 95 insertions, 98 deletions
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp index 4139cd1cd5a..912d96fe49f 100644 --- a/src/mongo/db/pipeline/pipeline_test.cpp +++ b/src/mongo/db/pipeline/pipeline_test.cpp @@ -116,7 +116,7 @@ void assertPipelineOptimizesAndSerializesTo(std::string inputPipeJson, ctx->setResolvedNamespace(lookupCollNs, {lookupCollNs, std::vector<BSONObj>{}}); ctx->setResolvedNamespace(unionCollNs, {unionCollNs, std::vector<BSONObj>{}}); - auto outputPipe = uassertStatusOK(Pipeline::parse(request.getPipeline(), ctx)); + auto outputPipe = Pipeline::parse(request.getPipeline(), ctx); outputPipe->optimizePipeline(); ASSERT_VALUE_EQ(Value(outputPipe->writeExplainOps(ExplainOptions::Verbosity::kQueryPlanner)), @@ -1679,7 +1679,7 @@ TEST(PipelineOptimizationTest, ChangeStreamLookupSwapsWithIndependentMatch) { auto matchPredicate = BSON("extra" << "predicate"); stages.push_back(DocumentSourceMatch::create(matchPredicate, expCtx)); - auto pipeline = uassertStatusOK(Pipeline::create(stages, expCtx)); + auto pipeline = Pipeline::create(stages, expCtx); pipeline->optimizePipeline(); // Make sure the $match stage has swapped before the change look up. @@ -1704,7 +1704,7 @@ TEST(PipelineOptimizationTest, ChangeStreamLookupDoesNotSwapWithMatchOnPostImage stages.push_back(DocumentSourceMatch::create( BSON(DocumentSourceLookupChangePostImage::kFullDocumentFieldName << BSONNULL), expCtx)); - auto pipeline = uassertStatusOK(Pipeline::create(stages, expCtx)); + auto pipeline = Pipeline::create(stages, expCtx); pipeline->optimizePipeline(); // Make sure the $match stage stays at the end. @@ -1730,7 +1730,7 @@ TEST(PipelineOptimizationTest, FullDocumentBeforeChangeLookupSwapsWithIndependen auto matchPredicate = BSON("extra" << "predicate"); stages.push_back(DocumentSourceMatch::create(matchPredicate, expCtx)); - auto pipeline = uassertStatusOK(Pipeline::create(stages, expCtx)); + auto pipeline = Pipeline::create(stages, expCtx); pipeline->optimizePipeline(); // Make sure the $match stage has swapped before the change look up. @@ -1756,7 +1756,7 @@ TEST(PipelineOptimizationTest, FullDocumentBeforeChangeDoesNotSwapWithMatchOnPre stages.push_back(DocumentSourceMatch::create( BSON(DocumentSourceLookupChangePreImage::kFullDocumentBeforeChangeFieldName << BSONNULL), expCtx)); - auto pipeline = uassertStatusOK(Pipeline::create(stages, expCtx)); + auto pipeline = Pipeline::create(stages, expCtx); pipeline->optimizePipeline(); // Make sure the $match stage stays at the end. @@ -2095,7 +2095,7 @@ public: ctx->setResolvedNamespace(lookupCollNs, {lookupCollNs, std::vector<BSONObj>{}}); // Test that we can both split the pipeline and reassemble it into its original form. - mergePipe = uassertStatusOK(Pipeline::parse(request.getPipeline(), ctx)); + mergePipe = Pipeline::parse(request.getPipeline(), ctx); mergePipe->optimizePipeline(); auto splitPipeline = sharded_agg_helpers::splitPipeline(std::move(mergePipe)); @@ -2690,7 +2690,7 @@ TEST_F(PipelineMustRunOnMongoSTest, UnsplittablePipelineMustRunOnMongoS) { auto match = DocumentSourceMatch::create(fromjson("{x: 5}"), expCtx); auto runOnMongoS = DocumentSourceMustRunOnMongoS::create(); - auto pipeline = uassertStatusOK(Pipeline::create({match, runOnMongoS}, expCtx)); + auto pipeline = Pipeline::create({match, runOnMongoS}, expCtx); ASSERT_TRUE(pipeline->requiredToRunOnMongos()); pipeline->optimizePipeline(); @@ -2707,7 +2707,7 @@ TEST_F(PipelineMustRunOnMongoSTest, UnsplittableMongoSPipelineAssertsIfDisallowe auto runOnMongoS = DocumentSourceMustRunOnMongoS::create(); auto sort = DocumentSourceSort::create(expCtx, fromjson("{x: 1}")); - auto pipeline = uassertStatusOK(Pipeline::create({match, runOnMongoS, sort}, expCtx)); + auto pipeline = Pipeline::create({match, runOnMongoS, sort}, expCtx); pipeline->optimizePipeline(); // The entire pipeline must run on mongoS, but $sort cannot do so when 'allowDiskUse' is true. @@ -2725,7 +2725,7 @@ DEATH_TEST_F(PipelineMustRunOnMongoSTest, auto split = DocumentSourceInternalSplitPipeline::create(expCtx, HostTypeRequirement::kNone); auto runOnMongoS = DocumentSourceMustRunOnMongoS::create(); - auto pipeline = uassertStatusOK(Pipeline::create({match, split, runOnMongoS}, expCtx)); + auto pipeline = Pipeline::create({match, split, runOnMongoS}, expCtx); // We don't need to run the entire pipeline on mongoS because we can split at // $_internalSplitPipeline. @@ -2766,7 +2766,7 @@ TEST_F(PipelineMustRunOnMongoSTest, SplitMongoSMergePipelineAssertsIfShardStageP auto outSpec = fromjson("{$out: 'outcoll'}"); auto out = DocumentSourceOut::createFromBson(outSpec["$out"], expCtx); - auto pipeline = uassertStatusOK(Pipeline::create({match, split, runOnMongoS, out}, expCtx)); + auto pipeline = Pipeline::create({match, split, runOnMongoS, out}, expCtx); // We don't need to run the entire pipeline on mongoS because we can split at // $_internalSplitPipeline. @@ -2789,7 +2789,7 @@ TEST_F(PipelineMustRunOnMongoSTest, SplittablePipelineAssertsIfMongoSStageOnShar auto split = DocumentSourceInternalSplitPipeline::create(expCtx, HostTypeRequirement::kAnyShard); - auto pipeline = uassertStatusOK(Pipeline::create({match, runOnMongoS, split}, expCtx)); + auto pipeline = Pipeline::create({match, runOnMongoS, split}, expCtx); pipeline->optimizePipeline(); // The 'runOnMongoS' stage comes before any splitpoint, so this entire pipeline must run on @@ -2808,7 +2808,7 @@ TEST_F(PipelineMustRunOnMongoSTest, SplittablePipelineRunsUnsplitOnMongoSIfSplit auto runOnMongoS = DocumentSourceMustRunOnMongoS::create(); auto split = DocumentSourceInternalSplitPipeline::create(expCtx, HostTypeRequirement::kNone); - auto pipeline = uassertStatusOK(Pipeline::create({match, runOnMongoS, split}, expCtx)); + auto pipeline = Pipeline::create({match, runOnMongoS, split}, expCtx); pipeline->optimizePipeline(); // The 'runOnMongoS' stage is before the splitpoint, so this entire pipeline must run on mongoS. @@ -2827,7 +2827,7 @@ TEST(PipelineInitialSource, GeoNearInitialQuery) { fromjson("{$geoNear: {distanceField: 'd', near: [0, 0], query: {a: 1}}}")}; intrusive_ptr<ExpressionContextForTest> ctx = new ExpressionContextForTest( &_opCtx, AggregationRequest(NamespaceString("a.collection"), rawPipeline)); - auto pipe = uassertStatusOK(Pipeline::parse(rawPipeline, ctx)); + auto pipe = Pipeline::parse(rawPipeline, ctx); ASSERT_BSONOBJ_EQ(pipe->getInitialQuery(), BSON("a" << 1)); } @@ -2837,7 +2837,7 @@ TEST(PipelineInitialSource, MatchInitialQuery) { intrusive_ptr<ExpressionContextForTest> ctx = new ExpressionContextForTest( &_opCtx, AggregationRequest(NamespaceString("a.collection"), rawPipeline)); - auto pipe = uassertStatusOK(Pipeline::parse(rawPipeline, ctx)); + auto pipe = Pipeline::parse(rawPipeline, ctx); ASSERT_BSONOBJ_EQ(pipe->getInitialQuery(), BSON("a" << 4)); } @@ -2875,7 +2875,8 @@ TEST_F(PipelineValidateTest, AggregateOneNSNotValidForEmptyPipeline) { ctx->ns = NamespaceString::makeCollectionlessAggregateNSS("a"); - ASSERT_NOT_OK(Pipeline::parse(rawPipeline, ctx).getStatus()); + ASSERT_THROWS_CODE( + Pipeline::parse(rawPipeline, ctx), AssertionException, ErrorCodes::InvalidNamespace); } TEST_F(PipelineValidateTest, AggregateOneNSNotValidIfInitialStageRequiresCollection) { @@ -2884,7 +2885,8 @@ TEST_F(PipelineValidateTest, AggregateOneNSNotValidIfInitialStageRequiresCollect ctx->ns = NamespaceString::makeCollectionlessAggregateNSS("a"); - ASSERT_NOT_OK(Pipeline::parse(rawPipeline, ctx).getStatus()); + ASSERT_THROWS_CODE( + Pipeline::parse(rawPipeline, ctx), AssertionException, ErrorCodes::InvalidNamespace); } TEST_F(PipelineValidateTest, AggregateOneNSValidIfInitialStageIsCollectionless) { @@ -2893,7 +2895,7 @@ TEST_F(PipelineValidateTest, AggregateOneNSValidIfInitialStageIsCollectionless) ctx->ns = NamespaceString::makeCollectionlessAggregateNSS("a"); - ASSERT_OK(Pipeline::create({collectionlessSource}, ctx).getStatus()); + Pipeline::create({collectionlessSource}, ctx); } TEST_F(PipelineValidateTest, CollectionNSNotValidIfInitialStageIsCollectionless) { @@ -2902,16 +2904,20 @@ TEST_F(PipelineValidateTest, CollectionNSNotValidIfInitialStageIsCollectionless) ctx->ns = kTestNss; - ASSERT_NOT_OK(Pipeline::create({collectionlessSource}, ctx).getStatus()); + ASSERT_THROWS_CODE(Pipeline::parse({fromjson("{$listLocalSessions: {}}")}, + ctx), // Pipeline::create({collectionlessSource}, ctx), + AssertionException, + ErrorCodes::InvalidNamespace); } TEST_F(PipelineValidateTest, AggregateOneNSValidForFacetPipelineRegardlessOfInitialStage) { - const std::vector<BSONObj> rawPipeline = {fromjson("{$match: {}}")}; + const std::vector<BSONObj> rawPipeline = {fromjson("{$facet: {subPipe: [{$match: {}}]}}")}; auto ctx = getExpCtx(); ctx->ns = NamespaceString::makeCollectionlessAggregateNSS("unittests"); - ASSERT_OK(Pipeline::parseFacetPipeline(rawPipeline, ctx).getStatus()); + ASSERT_THROWS_CODE( + Pipeline::parse(rawPipeline, ctx), AssertionException, ErrorCodes::InvalidNamespace); } TEST_F(PipelineValidateTest, ChangeStreamIsValidAsFirstStage) { @@ -2919,7 +2925,7 @@ TEST_F(PipelineValidateTest, ChangeStreamIsValidAsFirstStage) { auto ctx = getExpCtx(); setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); - ASSERT_OK(Pipeline::parse(rawPipeline, ctx).getStatus()); + Pipeline::parse(rawPipeline, ctx); } TEST_F(PipelineValidateTest, ChangeStreamIsNotValidIfNotFirstStage) { @@ -2928,19 +2934,17 @@ TEST_F(PipelineValidateTest, ChangeStreamIsNotValidIfNotFirstStage) { auto ctx = getExpCtx(); setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); - auto parseStatus = Pipeline::parse(rawPipeline, ctx).getStatus(); - ASSERT_EQ(parseStatus, ErrorCodes::duplicateCodeForTest(40602)); + ASSERT_THROWS_CODE(Pipeline::parse(rawPipeline, ctx), AssertionException, 40602); } TEST_F(PipelineValidateTest, ChangeStreamIsNotValidIfNotFirstStageInFacet) { - const std::vector<BSONObj> rawPipeline = {fromjson("{$match: {custom: 'filter'}}"), - fromjson("{$changeStream: {}}")}; + const std::vector<BSONObj> rawPipeline = { + fromjson("{$facet: {subPipe: [{$match: {}}, {$changeStream: {}}]}}")}; + auto ctx = getExpCtx(); setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); - auto parseStatus = Pipeline::parseFacetPipeline(rawPipeline, ctx).getStatus(); - ASSERT_EQ(parseStatus, ErrorCodes::duplicateCodeForTest(40600)); - ASSERT(std::string::npos != parseStatus.reason().find("$changeStream")); + ASSERT_THROWS_CODE(Pipeline::parse(rawPipeline, ctx), AssertionException, 40600); } class DocumentSourceDisallowedInTransactions : public DocumentSourceMock { @@ -2964,8 +2968,6 @@ public: }; TEST_F(PipelineValidateTest, TopLevelPipelineValidatedForStagesIllegalInTransactions) { - BSONObj readConcernSnapshot = BSON("readConcern" << BSON("level" - << "snapshot")); auto ctx = getExpCtx(); ctx->inMultiDocumentTransaction = true; @@ -2973,24 +2975,20 @@ TEST_F(PipelineValidateTest, TopLevelPipelineValidatedForStagesIllegalInTransact // creation fails with the expected error code. auto matchStage = DocumentSourceMatch::create(BSON("_id" << 3), ctx); auto illegalStage = DocumentSourceDisallowedInTransactions::create(); - auto pipeline = Pipeline::create({matchStage, illegalStage}, ctx); - ASSERT_NOT_OK(pipeline.getStatus()); - ASSERT_EQ(pipeline.getStatus(), ErrorCodes::OperationNotSupportedInTransaction); + ASSERT_THROWS_CODE(Pipeline::create({matchStage, illegalStage}, ctx), + AssertionException, + ErrorCodes::OperationNotSupportedInTransaction); } TEST_F(PipelineValidateTest, FacetPipelineValidatedForStagesIllegalInTransactions) { - BSONObj readConcernSnapshot = BSON("readConcern" << BSON("level" - << "snapshot")); auto ctx = getExpCtx(); ctx->inMultiDocumentTransaction = true; - // Make a pipeline with a legal $match, and then an illegal mock stage, and verify that pipeline - // creation fails with the expected error code. - auto matchStage = DocumentSourceMatch::create(BSON("_id" << 3), ctx); - auto illegalStage = DocumentSourceDisallowedInTransactions::create(); - auto pipeline = Pipeline::createFacetPipeline({matchStage, illegalStage}, ctx); - ASSERT_NOT_OK(pipeline.getStatus()); - ASSERT_EQ(pipeline.getStatus(), ErrorCodes::OperationNotSupportedInTransaction); + const std::vector<BSONObj> rawPipeline = { + fromjson("{$facet: {subPipe: [{$match: {}}, {$out: 'outColl'}]}}")}; + ASSERT_THROWS_CODE(Pipeline::parse(rawPipeline, ctx), + AssertionException, + ErrorCodes::OperationNotSupportedInTransaction); } } // namespace pipeline_validate @@ -3000,7 +2998,7 @@ namespace Dependencies { using PipelineDependenciesTest = AggregationContextFixture; TEST_F(PipelineDependenciesTest, EmptyPipelineShouldRequireWholeDocument) { - auto pipeline = unittest::assertGet(Pipeline::create({}, getExpCtx())); + auto pipeline = Pipeline::create({}, getExpCtx()); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata); ASSERT_TRUE(depsTracker.needWholeDocument); @@ -3096,7 +3094,7 @@ TEST_F(PipelineDependenciesTest, ShouldRequireWholeDocumentIfAnyStageDoesNotSupp auto ctx = getExpCtx(); auto needsASeeNext = DocumentSourceNeedsASeeNext::create(); auto notSupported = DocumentSourceDependenciesNotSupported::create(); - auto pipeline = unittest::assertGet(Pipeline::create({needsASeeNext, notSupported}, ctx)); + auto pipeline = Pipeline::create({needsASeeNext, notSupported}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata); ASSERT_TRUE(depsTracker.needWholeDocument); @@ -3104,7 +3102,7 @@ TEST_F(PipelineDependenciesTest, ShouldRequireWholeDocumentIfAnyStageDoesNotSupp ASSERT_FALSE(depsTracker.getNeedsMetadata(DocumentMetadataFields::kTextScore)); // Now in the other order. - pipeline = unittest::assertGet(Pipeline::create({notSupported, needsASeeNext}, ctx)); + pipeline = Pipeline::create({notSupported, needsASeeNext}, ctx); depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata); ASSERT_TRUE(depsTracker.needWholeDocument); @@ -3113,7 +3111,7 @@ TEST_F(PipelineDependenciesTest, ShouldRequireWholeDocumentIfAnyStageDoesNotSupp TEST_F(PipelineDependenciesTest, ShouldRequireWholeDocumentIfNoStageReturnsExhaustiveFields) { auto ctx = getExpCtx(); auto needsASeeNext = DocumentSourceNeedsASeeNext::create(); - auto pipeline = unittest::assertGet(Pipeline::create({needsASeeNext}, ctx)); + auto pipeline = Pipeline::create({needsASeeNext}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kNoMetadata); ASSERT_TRUE(depsTracker.needWholeDocument); @@ -3123,7 +3121,7 @@ TEST_F(PipelineDependenciesTest, ShouldNotRequireWholeDocumentIfAnyStageReturnsE auto ctx = getExpCtx(); auto needsASeeNext = DocumentSourceNeedsASeeNext::create(); auto needsOnlyB = DocumentSourceNeedsOnlyB::create(); - auto pipeline = unittest::assertGet(Pipeline::create({needsASeeNext, needsOnlyB}, ctx)); + auto pipeline = Pipeline::create({needsASeeNext, needsOnlyB}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kNoMetadata); ASSERT_FALSE(depsTracker.needWholeDocument); @@ -3136,7 +3134,7 @@ TEST_F(PipelineDependenciesTest, ShouldNotAddAnyRequiredFieldsAfterFirstStageWit auto ctx = getExpCtx(); auto needsOnlyB = DocumentSourceNeedsOnlyB::create(); auto needsASeeNext = DocumentSourceNeedsASeeNext::create(); - auto pipeline = unittest::assertGet(Pipeline::create({needsOnlyB, needsASeeNext}, ctx)); + auto pipeline = Pipeline::create({needsOnlyB, needsASeeNext}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata); ASSERT_FALSE(depsTracker.needWholeDocument); @@ -3150,7 +3148,7 @@ TEST_F(PipelineDependenciesTest, ShouldNotAddAnyRequiredFieldsAfterFirstStageWit TEST_F(PipelineDependenciesTest, ShouldNotRequireTextScoreIfThereIsNoScoreAvailable) { auto ctx = getExpCtx(); - auto pipeline = unittest::assertGet(Pipeline::create({}, ctx)); + auto pipeline = Pipeline::create({}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata); ASSERT_FALSE(depsTracker.getNeedsMetadata(DocumentMetadataFields::kTextScore)); @@ -3159,21 +3157,21 @@ TEST_F(PipelineDependenciesTest, ShouldNotRequireTextScoreIfThereIsNoScoreAvaila TEST_F(PipelineDependenciesTest, ShouldThrowIfTextScoreIsNeededButNotPresent) { auto ctx = getExpCtx(); auto needsText = DocumentSourceNeedsOnlyTextScore::create(); - auto pipeline = unittest::assertGet(Pipeline::create({needsText}, ctx)); + auto pipeline = Pipeline::create({needsText}, ctx); ASSERT_THROWS(pipeline->getDependencies(DepsTracker::kAllMetadata), AssertionException); } TEST_F(PipelineDependenciesTest, ShouldRequireTextScoreIfAvailableAndNoStageReturnsExhaustiveMeta) { auto ctx = getExpCtx(); - auto pipeline = unittest::assertGet(Pipeline::create({}, ctx)); + auto pipeline = Pipeline::create({}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata & ~DepsTracker::kOnlyTextScore); ASSERT_TRUE(depsTracker.getNeedsMetadata(DocumentMetadataFields::kTextScore)); auto needsASeeNext = DocumentSourceNeedsASeeNext::create(); - pipeline = unittest::assertGet(Pipeline::create({needsASeeNext}, ctx)); + pipeline = Pipeline::create({needsASeeNext}, ctx); depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata & ~DepsTracker::kOnlyTextScore); ASSERT_TRUE(depsTracker.getNeedsMetadata(DocumentMetadataFields::kTextScore)); @@ -3183,7 +3181,7 @@ TEST_F(PipelineDependenciesTest, ShouldNotRequireTextScoreIfAvailableButDefinite auto ctx = getExpCtx(); auto stripsTextScore = DocumentSourceStripsTextScore::create(); auto needsText = DocumentSourceNeedsOnlyTextScore::create(); - auto pipeline = unittest::assertGet(Pipeline::create({stripsTextScore, needsText}, ctx)); + auto pipeline = Pipeline::create({stripsTextScore, needsText}, ctx); auto depsTracker = pipeline->getDependencies(DepsTracker::kAllMetadata & ~DepsTracker::kOnlyTextScore); @@ -3198,8 +3196,7 @@ TEST_F(PipelineDependenciesTest, ShouldNotRequireTextScoreIfAvailableButDefinite namespace { TEST(PipelineRenameTracking, ReportsIdentityMapWhenEmpty) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); - auto pipeline = - unittest::assertGet(Pipeline::create({DocumentSourceMock::createForTest()}, expCtx)); + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest()}, expCtx); { // Tracking renames backwards. auto renames = semantic_analysis::renamedPaths( @@ -3243,8 +3240,8 @@ TEST(PipelineRenameTracking, ReportsIdentityWhenNoStageModifiesAnything) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); { // Tracking renames backwards. - auto pipeline = unittest::assertGet(Pipeline::create( - {DocumentSourceMock::createForTest(), NoModifications::create()}, expCtx)); + auto pipeline = Pipeline::create( + {DocumentSourceMock::createForTest(), NoModifications::create()}, expCtx); auto renames = semantic_analysis::renamedPaths( pipeline->getSources().crbegin(), pipeline->getSources().crend(), {"a", "b", "c.d"}); ASSERT(static_cast<bool>(renames)); @@ -3256,8 +3253,8 @@ TEST(PipelineRenameTracking, ReportsIdentityWhenNoStageModifiesAnything) { } { // Tracking renames forwards. - auto pipeline = unittest::assertGet(Pipeline::create( - {DocumentSourceMock::createForTest(), NoModifications::create()}, expCtx)); + auto pipeline = Pipeline::create( + {DocumentSourceMock::createForTest(), NoModifications::create()}, expCtx); auto renames = semantic_analysis::renamedPaths( pipeline->getSources().cbegin(), pipeline->getSources().cend(), {"a", "b", "c.d"}); ASSERT(static_cast<bool>(renames)); @@ -3269,11 +3266,11 @@ TEST(PipelineRenameTracking, ReportsIdentityWhenNoStageModifiesAnything) { } { // Tracking renames backwards. - auto pipeline = unittest::assertGet(Pipeline::create({DocumentSourceMock::createForTest(), - NoModifications::create(), - NoModifications::create(), - NoModifications::create()}, - expCtx)); + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), + NoModifications::create(), + NoModifications::create(), + NoModifications::create()}, + expCtx); auto renames = semantic_analysis::renamedPaths( pipeline->getSources().crbegin(), pipeline->getSources().crend(), {"a", "b", "c.d"}); auto nameMap = *renames; @@ -3284,11 +3281,11 @@ TEST(PipelineRenameTracking, ReportsIdentityWhenNoStageModifiesAnything) { } { // Tracking renames forwards. - auto pipeline = unittest::assertGet(Pipeline::create({DocumentSourceMock::createForTest(), - NoModifications::create(), - NoModifications::create(), - NoModifications::create()}, - expCtx)); + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), + NoModifications::create(), + NoModifications::create(), + NoModifications::create()}, + expCtx); auto renames = semantic_analysis::renamedPaths( pipeline->getSources().cbegin(), pipeline->getSources().cend(), {"a", "b", "c.d"}); auto nameMap = *renames; @@ -3316,11 +3313,11 @@ public: TEST(PipelineRenameTracking, DoesNotReportRenamesIfAStageDoesNotSupportTrackingThem) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); - auto pipeline = unittest::assertGet(Pipeline::create({DocumentSourceMock::createForTest(), - NoModifications::create(), - NotSupported::create(), - NoModifications::create()}, - expCtx)); + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), + NoModifications::create(), + NotSupported::create(), + NoModifications::create()}, + expCtx); // Backwards case. ASSERT_FALSE(static_cast<bool>(semantic_analysis::renamedPaths( pipeline->getSources().crbegin(), pipeline->getSources().crend(), {"a"}))); @@ -3350,8 +3347,8 @@ public: TEST(PipelineRenameTracking, ReportsNewNamesWhenSingleStageRenames) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); - auto pipeline = unittest::assertGet( - Pipeline::create({DocumentSourceMock::createForTest(), RenamesAToB::create()}, expCtx)); + auto pipeline = + Pipeline::create({DocumentSourceMock::createForTest(), RenamesAToB::create()}, expCtx); { // Tracking backwards. auto renames = semantic_analysis::renamedPaths( @@ -3416,8 +3413,8 @@ TEST(PipelineRenameTracking, ReportsNewNamesWhenSingleStageRenames) { TEST(PipelineRenameTracking, ReportsIdentityMapWhenGivenEmptyIteratorRange) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); - auto pipeline = unittest::assertGet( - Pipeline::create({DocumentSourceMock::createForTest(), RenamesAToB::create()}, expCtx)); + auto pipeline = + Pipeline::create({DocumentSourceMock::createForTest(), RenamesAToB::create()}, expCtx); { // Tracking backwards. auto renames = semantic_analysis::renamedPaths( @@ -3474,9 +3471,9 @@ TEST(PipelineRenameTracking, ReportsNewNameAcrossMultipleRenames) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); { // Tracking backwards. - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), RenamesAToB::create(), RenamesBToC::create()}, - expCtx)); + expCtx); auto stages = pipeline->getSources(); auto renames = semantic_analysis::renamedPaths(stages.crbegin(), stages.crend(), {"c"}); ASSERT(static_cast<bool>(renames)); @@ -3486,9 +3483,9 @@ TEST(PipelineRenameTracking, ReportsNewNameAcrossMultipleRenames) { } { // Tracking forwards. - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), RenamesAToB::create(), RenamesBToC::create()}, - expCtx)); + expCtx); auto stages = pipeline->getSources(); auto renames = semantic_analysis::renamedPaths(stages.cbegin(), stages.cend(), {"a"}); ASSERT(static_cast<bool>(renames)); @@ -3513,9 +3510,9 @@ TEST(PipelineRenameTracking, CanHandleBackAndForthRename) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); { // Tracking backwards. - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), RenamesAToB::create(), RenamesBToA::create()}, - expCtx)); + expCtx); auto stages = pipeline->getSources(); auto renames = semantic_analysis::renamedPaths(stages.crbegin(), stages.crend(), {"a"}); ASSERT(static_cast<bool>(renames)); @@ -3525,9 +3522,9 @@ TEST(PipelineRenameTracking, CanHandleBackAndForthRename) { } { // Tracking forwards. - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), RenamesAToB::create(), RenamesBToA::create()}, - expCtx)); + expCtx); auto stages = pipeline->getSources(); auto renames = semantic_analysis::renamedPaths(stages.cbegin(), stages.cend(), {"a"}); ASSERT(static_cast<bool>(renames)); @@ -3539,12 +3536,12 @@ TEST(PipelineRenameTracking, CanHandleBackAndForthRename) { TEST(InvolvedNamespacesTest, NoInvolvedNamespacesForMatchSortProject) { boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest()); - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), DocumentSourceMatch::create(BSON("x" << 1), expCtx), DocumentSourceSort::create(expCtx, BSON("y" << -1)), DocumentSourceProject::create(BSON("x" << 1 << "y" << 1), expCtx, "$project"_sd)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT(involvedNssSet.empty()); } @@ -3556,10 +3553,10 @@ TEST(InvolvedNamespacesTest, IncludesLookupNamespace) { expCtx->setResolvedNamespace(lookupNss, {resolvedNss, vector<BSONObj>{}}); auto lookupSpec = fromjson("{$lookup: {from: 'foo', as: 'x', localField: 'foo_id', foreignField: '_id'}}"); - auto pipeline = unittest::assertGet( + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), DocumentSourceLookUp::createFromBson(lookupSpec.firstElement(), expCtx)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT_EQ(involvedNssSet.size(), 1UL); @@ -3579,10 +3576,10 @@ TEST(InvolvedNamespacesTest, IncludesGraphLookupNamespace) { " connectToField: 'y'," " startWith: '$start'" "}}"); - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), DocumentSourceGraphLookUp::createFromBson(graphLookupSpec.firstElement(), expCtx)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT_EQ(involvedNssSet.size(), 1UL); @@ -3603,10 +3600,10 @@ TEST(InvolvedNamespacesTest, IncludesLookupSubpipelineNamespaces) { " as: 'x', " " pipeline: [{$lookup: {from: 'foo_inner', as: 'y', pipeline: []}}]" "}}"); - auto pipeline = unittest::assertGet( + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), DocumentSourceLookUp::createFromBson(lookupSpec.firstElement(), expCtx)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT_EQ(involvedNssSet.size(), 2UL); @@ -3634,10 +3631,10 @@ TEST(InvolvedNamespacesTest, IncludesGraphLookupSubPipeline) { " connectToField: 'y'," " startWith: '$start'" "}}"); - auto pipeline = unittest::assertGet(Pipeline::create( + auto pipeline = Pipeline::create( {DocumentSourceMock::createForTest(), DocumentSourceGraphLookUp::createFromBson(graphLookupSpec.firstElement(), expCtx)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT_EQ(involvedNssSet.size(), 2UL); @@ -3677,10 +3674,10 @@ TEST(InvolvedNamespacesTest, IncludesAllCollectionsWhenResolvingViews) { " }}" " ]" "}}"); - auto pipeline = unittest::assertGet( + auto pipeline = Pipeline::create({DocumentSourceMock::createForTest(), DocumentSourceFacet::createFromBson(facetSpec.firstElement(), expCtx)}, - expCtx)); + expCtx); auto involvedNssSet = pipeline->getInvolvedCollections(); ASSERT_EQ(involvedNssSet.size(), 3UL); |