diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2017-08-03 13:55:23 -0400 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2017-08-03 14:32:12 -0400 |
commit | 0686b1ed2d042ad5adb671912e7d6b9cc89d0c4f (patch) | |
tree | 5fe3f0a6d4e8445eaec46b564b55cfc6753cbcac /src/mongo/db/pipeline/pipeline_test.cpp | |
parent | 07d4d94b06c6899699410312e20ef33d954ddbd1 (diff) | |
download | mongo-0686b1ed2d042ad5adb671912e7d6b9cc89d0c4f.tar.gz |
SERVER-29131 Support resumeAfter option to control where to start returning notifications from, which always errors if no entry with the given resumeToken exists
Diffstat (limited to 'src/mongo/db/pipeline/pipeline_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/pipeline_test.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp index 9909895feb3..91d04bdf2a2 100644 --- a/src/mongo/db/pipeline/pipeline_test.cpp +++ b/src/mongo/db/pipeline/pipeline_test.cpp @@ -48,6 +48,7 @@ #include "mongo/db/pipeline/pipeline.h" #include "mongo/db/query/collation/collator_interface_mock.h" #include "mongo/db/query/query_test_service_context.h" +#include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/dbtests/dbtests.h" namespace PipelineTests { @@ -58,6 +59,14 @@ using std::vector; const NamespaceString kTestNss = NamespaceString("a.collection"); +namespace { +void setMockReplicationCoordinatorOnOpCtx(OperationContext* opCtx) { + repl::ReplicationCoordinator::set( + opCtx->getServiceContext(), + stdx::make_unique<repl::ReplicationCoordinatorMock>(opCtx->getServiceContext())); +} +} // namespace + namespace Optimizations { using namespace mongo; @@ -974,6 +983,7 @@ TEST(PipelineOptimizationTest, ChangeNotificationLookupSwapsWithIndependentMatch intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest(kTestNss)); expCtx->opCtx = opCtx.get(); + setMockReplicationCoordinatorOnOpCtx(expCtx->opCtx); auto spec = BSON("$changeNotification" << BSON("fullDocument" << "lookup")); @@ -998,6 +1008,7 @@ TEST(PipelineOptimizationTest, ChangeNotificationLookupDoesNotSwapWithMatchOnPos intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest(kTestNss)); expCtx->opCtx = opCtx.get(); + setMockReplicationCoordinatorOnOpCtx(expCtx->opCtx); auto spec = BSON("$changeNotification" << BSON("fullDocument" << "lookup")); @@ -1472,6 +1483,7 @@ TEST_F(PipelineInitialSourceNSTest, AggregateOneNSValidForFacetPipelineRegardles TEST_F(PipelineInitialSourceNSTest, ChangeNotificationIsValidAsFirstStage) { const std::vector<BSONObj> rawPipeline = {fromjson("{$changeNotification: {}}")}; auto ctx = getExpCtx(); + setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); ASSERT_OK(Pipeline::parse(rawPipeline, ctx).getStatus()); } @@ -1480,6 +1492,7 @@ TEST_F(PipelineInitialSourceNSTest, ChangeNotificationIsNotValidIfNotFirstStage) const std::vector<BSONObj> rawPipeline = {fromjson("{$match: {custom: 'filter'}}"), fromjson("{$changeNotification: {}}")}; auto ctx = getExpCtx(); + setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); auto parseStatus = Pipeline::parse(rawPipeline, ctx).getStatus(); ASSERT_EQ(parseStatus, ErrorCodes::BadValue); @@ -1490,6 +1503,7 @@ TEST_F(PipelineInitialSourceNSTest, ChangeNotificationIsNotValidIfNotFirstStageI const std::vector<BSONObj> rawPipeline = {fromjson("{$match: {custom: 'filter'}}"), fromjson("{$changeNotification: {}}")}; auto ctx = getExpCtx(); + setMockReplicationCoordinatorOnOpCtx(ctx->opCtx); ctx->ns = NamespaceString("a.collection"); auto parseStatus = Pipeline::parseFacetPipeline(rawPipeline, ctx).getStatus(); ASSERT_EQ(parseStatus, ErrorCodes::BadValue); |