summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2018-11-27 13:28:27 -0500
committerJames Wahlin <james@mongodb.com>2018-12-12 14:41:24 -0500
commit056d61676f91f6da0a030347ae4b92255d752d8f (patch)
tree92f5b2d319ce1cd5701be912e6b96cf9a6fdaa4b /src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
parentd2573d47786b035d5bcdeaf30207bbfcd58bf14e (diff)
downloadmongo-056d61676f91f6da0a030347ae4b92255d752d8f.tar.gz
SERVER-32308 Support for $lookup to execute on mongos against a sharded foreign collection
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
index 148197d4d5b..9c3dbf5777b 100644
--- a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
@@ -85,34 +85,31 @@ public:
MockMongoInterface(deque<DocumentSource::GetNextResult> mockResults)
: _mockResults(std::move(mockResults)) {}
- bool isSharded(OperationContext* opCtx, const NamespaceString& ns) final {
+ bool isSharded(OperationContext* opCtx, const NamespaceString& nss) final {
return false;
}
- StatusWith<std::unique_ptr<Pipeline, PipelineDeleter>> makePipeline(
+ std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
const std::vector<BSONObj>& rawPipeline,
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const MakePipelineOptions opts = MakePipelineOptions{}) final {
- auto pipeline = Pipeline::parse(rawPipeline, expCtx);
- if (!pipeline.isOK()) {
- return pipeline.getStatus();
- }
+ auto pipeline = uassertStatusOK(Pipeline::parse(rawPipeline, expCtx));
if (opts.optimize) {
- pipeline.getValue()->optimizePipeline();
+ pipeline->optimizePipeline();
}
if (opts.attachCursorSource) {
- uassertStatusOK(attachCursorSourceToPipeline(expCtx, pipeline.getValue().get()));
+ pipeline = attachCursorSourceToPipeline(expCtx, pipeline.release());
}
return pipeline;
}
- Status attachCursorSourceToPipeline(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- Pipeline* pipeline) final {
+ std::unique_ptr<Pipeline, PipelineDeleter> attachCursorSourceToPipeline(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx, Pipeline* pipeline) final {
pipeline->addInitialSource(DocumentSourceMock::create(_mockResults));
- return Status::OK();
+ return std::unique_ptr<Pipeline, PipelineDeleter>(pipeline, PipelineDeleter(expCtx->opCtx));
}
boost::optional<Document> lookupSingleDocument(
@@ -125,11 +122,12 @@ public:
// case of a change stream on a whole database so we need to make a copy of the
// ExpressionContext with the new namespace.
auto foreignExpCtx = expCtx->copyWith(nss, collectionUUID, boost::none);
- auto swPipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx);
- if (swPipeline == ErrorCodes::NamespaceNotFound) {
+ std::unique_ptr<Pipeline, PipelineDeleter> pipeline;
+ try {
+ pipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx);
+ } catch (ExceptionFor<ErrorCodes::NamespaceNotFound>& ex) {
return boost::none;
}
- auto pipeline = uassertStatusOK(std::move(swPipeline));
auto lookedUpDocument = pipeline->getNext();
if (auto next = pipeline->getNext()) {