diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-07-12 11:43:48 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-08-01 17:16:14 -0400 |
commit | 2431e1356823d898ef8af16997d6f63b65b385a5 (patch) | |
tree | 6df997de8e8e0378d4a2d711fce1d28be772293b /src/mongo/db/pipeline/document_source_facet_test.cpp | |
parent | 718cf09aa21b36e9436a675c8645770826078da7 (diff) | |
download | mongo-2431e1356823d898ef8af16997d6f63b65b385a5.tar.gz |
SERVER-29506 Require $changeNotification to be the first stage.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_facet_test.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp index a41b3a2b1ce..60aefdead64 100644 --- a/src/mongo/db/pipeline/document_source_facet_test.cpp +++ b/src/mongo/db/pipeline/document_source_facet_test.cpp @@ -111,16 +111,6 @@ TEST_F(DocumentSourceFacetTest, ShouldRejectEmptyPipelines) { ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException); } -TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsWithStagesThatMustBeTheFirstStage) { - auto ctx = getExpCtx(); - auto spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$indexStats" << BSONObj())))); - ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException); - - spec = BSON("$facet" << BSON( - "a" << BSON_ARRAY(BSON("$limit" << 1) << BSON("$indexStats" << BSONObj())))); - ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException); -} - TEST_F(DocumentSourceFacetTest, ShouldSucceedWhenNamespaceIsCollectionless) { auto ctx = getExpCtx(); auto spec = fromjson("{$facet: {a: [{$match: {}}]}}"); @@ -178,9 +168,10 @@ class DocumentSourcePassthrough : public DocumentSourceMock { public: DocumentSourcePassthrough() : DocumentSourceMock({}) {} - // We need this to be false so that it can be used in a $facet stage. - InitialSourceType getInitialSourceType() const final { - return InitialSourceType::kNotInitialSource; + StageConstraints constraints() const override { + StageConstraints constraints; + constraints.isAllowedInsideFacetStage = true; + return constraints; } DocumentSource::GetNextResult getNext() final { @@ -616,8 +607,10 @@ TEST_F(DocumentSourceFacetTest, ShouldThrowIfAnyPipelineRequiresTextScoreButItIs */ class DocumentSourceNeedsPrimaryShard final : public DocumentSourcePassthrough { public: - bool needsPrimaryShard() const final { - return true; + StageConstraints constraints() const final { + StageConstraints constraints; + constraints.mustRunOnPrimaryShardIfSharded = true; + return constraints; } static boost::intrusive_ptr<DocumentSourceNeedsPrimaryShard> create() { @@ -640,7 +633,7 @@ TEST_F(DocumentSourceFacetTest, ShouldRequirePrimaryShardIfAnyStageRequiresPrima facets.emplace_back("needsPrimaryShard", std::move(secondPipeline)); auto facetStage = DocumentSourceFacet::create(std::move(facets), ctx); - ASSERT_TRUE(facetStage->needsPrimaryShard()); + ASSERT_TRUE(facetStage->constraints().mustRunOnPrimaryShardIfSharded); } TEST_F(DocumentSourceFacetTest, ShouldNotRequirePrimaryShardIfNoStagesRequiresPrimaryShard) { @@ -659,7 +652,7 @@ TEST_F(DocumentSourceFacetTest, ShouldNotRequirePrimaryShardIfNoStagesRequiresPr facets.emplace_back("second", std::move(secondPipeline)); auto facetStage = DocumentSourceFacet::create(std::move(facets), ctx); - ASSERT_FALSE(facetStage->needsPrimaryShard()); + ASSERT_FALSE(facetStage->constraints().mustRunOnPrimaryShardIfSharded); } } // namespace |