diff options
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/documentsourcetests.cpp | 12 | ||||
-rw-r--r-- | src/mongo/dbtests/executor_registry.cpp | 18 | ||||
-rw-r--r-- | src/mongo/dbtests/query_plan_executor.cpp | 3 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_collscan.cpp | 29 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_count.cpp | 6 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_delete.cpp | 6 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_multiplan.cpp | 8 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_sort.cpp | 8 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_update.cpp | 10 |
9 files changed, 41 insertions, 59 deletions
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp index bd37bc31416..40e666ad92c 100644 --- a/src/mongo/dbtests/documentsourcetests.cpp +++ b/src/mongo/dbtests/documentsourcetests.cpp @@ -368,12 +368,11 @@ TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorShouldErrorAfterTimeout) AutoGetCollectionForRead readLock(opCtx(), nss); auto workingSet = stdx::make_unique<WorkingSet>(); CollectionScanParams collScanParams; - collScanParams.collection = readLock.getCollection(); collScanParams.tailable = true; auto filter = BSON("a" << 1); auto matchExpression = uassertStatusOK(MatchExpressionParser::parse(filter, ctx())); auto collectionScan = stdx::make_unique<CollectionScan>( - opCtx(), collScanParams, workingSet.get(), matchExpression.get()); + opCtx(), readLock.getCollection(), collScanParams, workingSet.get(), matchExpression.get()); auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(filter); queryRequest->setTailableMode(TailableModeEnum::kTailableAndAwaitData); @@ -408,11 +407,10 @@ TEST_F(DocumentSourceCursorTest, NonAwaitDataCursorShouldErrorAfterTimeout) { AutoGetCollectionForRead readLock(opCtx(), nss); auto workingSet = stdx::make_unique<WorkingSet>(); CollectionScanParams collScanParams; - collScanParams.collection = readLock.getCollection(); auto filter = BSON("a" << 1); auto matchExpression = uassertStatusOK(MatchExpressionParser::parse(filter, ctx())); auto collectionScan = stdx::make_unique<CollectionScan>( - opCtx(), collScanParams, workingSet.get(), matchExpression.get()); + opCtx(), readLock.getCollection(), collScanParams, workingSet.get(), matchExpression.get()); auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(filter); auto canonicalQuery = unittest::assertGet( @@ -453,12 +451,11 @@ TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorShouldErrorAfterBeingKil AutoGetCollectionForRead readLock(opCtx(), nss); auto workingSet = stdx::make_unique<WorkingSet>(); CollectionScanParams collScanParams; - collScanParams.collection = readLock.getCollection(); collScanParams.tailable = true; auto filter = BSON("a" << 1); auto matchExpression = uassertStatusOK(MatchExpressionParser::parse(filter, ctx())); auto collectionScan = stdx::make_unique<CollectionScan>( - opCtx(), collScanParams, workingSet.get(), matchExpression.get()); + opCtx(), readLock.getCollection(), collScanParams, workingSet.get(), matchExpression.get()); auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(filter); queryRequest->setTailableMode(TailableModeEnum::kTailableAndAwaitData); @@ -492,11 +489,10 @@ TEST_F(DocumentSourceCursorTest, NormalCursorShouldErrorAfterBeingKilled) { AutoGetCollectionForRead readLock(opCtx(), nss); auto workingSet = stdx::make_unique<WorkingSet>(); CollectionScanParams collScanParams; - collScanParams.collection = readLock.getCollection(); auto filter = BSON("a" << 1); auto matchExpression = uassertStatusOK(MatchExpressionParser::parse(filter, ctx())); auto collectionScan = stdx::make_unique<CollectionScan>( - opCtx(), collScanParams, workingSet.get(), matchExpression.get()); + opCtx(), readLock.getCollection(), collScanParams, workingSet.get(), matchExpression.get()); auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(filter); auto canonicalQuery = unittest::assertGet( diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp index ea0934836bd..b53ec260a8e 100644 --- a/src/mongo/dbtests/executor_registry.cpp +++ b/src/mongo/dbtests/executor_registry.cpp @@ -72,10 +72,10 @@ public: std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> getCollscan() { unique_ptr<WorkingSet> ws(new WorkingSet()); CollectionScanParams params; - params.collection = collection(); params.direction = CollectionScanParams::FORWARD; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, ws.get(), NULL)); + unique_ptr<CollectionScan> scan( + new CollectionScan(&_opCtx, collection(), params, ws.get(), NULL)); // Create a plan executor to hold it auto qr = stdx::make_unique<QueryRequest>(nss); @@ -139,7 +139,7 @@ public: // At this point, we're done yielding. We recover our lock. // And clean up anything that happened before. - ASSERT_OK(exec->restoreState()); + exec->restoreState(); // Make sure that the PlanExecutor moved forward over the deleted data. We don't see // foo==10 @@ -171,7 +171,7 @@ public: // Drop a collection that's not ours. _client.dropCollection("unittests.someboguscollection"); - ASSERT_OK(exec->restoreState()); + exec->restoreState(); ASSERT_EQUALS(PlanExecutor::ADVANCED, exec->getNext(&obj, NULL)); ASSERT_EQUALS(10, obj["foo"].numberInt()); @@ -180,7 +180,7 @@ public: _client.dropCollection(nss.ns()); - ASSERT_EQUALS(ErrorCodes::QueryPlanKilled, exec->restoreState()); + ASSERT_THROWS_CODE(exec->restoreState(), DBException, ErrorCodes::QueryPlanKilled); } }; @@ -201,7 +201,7 @@ public: exec->saveState(); _client.dropIndexes(nss.ns()); - ASSERT_EQUALS(ErrorCodes::QueryPlanKilled, exec->restoreState()); + ASSERT_THROWS_CODE(exec->restoreState(), DBException, ErrorCodes::QueryPlanKilled); } }; @@ -222,7 +222,7 @@ public: exec->saveState(); _client.dropIndex(nss.ns(), BSON("foo" << 1)); - ASSERT_EQUALS(ErrorCodes::QueryPlanKilled, exec->restoreState()); + ASSERT_THROWS_CODE(exec->restoreState(), DBException, ErrorCodes::QueryPlanKilled); } }; @@ -246,7 +246,7 @@ public: _ctx.reset(); _client.dropDatabase("somesillydb"); _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); - ASSERT_OK(exec->restoreState()); + exec->restoreState(); ASSERT_EQUALS(PlanExecutor::ADVANCED, exec->getNext(&obj, NULL)); ASSERT_EQUALS(10, obj["foo"].numberInt()); @@ -257,7 +257,7 @@ public: _ctx.reset(); _client.dropDatabase("unittests"); _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); - ASSERT_EQUALS(ErrorCodes::QueryPlanKilled, exec->restoreState()); + ASSERT_THROWS_CODE(exec->restoreState(), DBException, ErrorCodes::QueryPlanKilled); } }; diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp index a5c968c5f03..7aaf6145e87 100644 --- a/src/mongo/dbtests/query_plan_executor.cpp +++ b/src/mongo/dbtests/query_plan_executor.cpp @@ -103,7 +103,6 @@ public: PlanExecutor::YieldPolicy yieldPolicy = PlanExecutor::YieldPolicy::YIELD_MANUAL, TailableModeEnum tailableMode = TailableModeEnum::kNormal) { CollectionScanParams csparams; - csparams.collection = coll; csparams.direction = CollectionScanParams::FORWARD; unique_ptr<WorkingSet> ws(new WorkingSet()); @@ -118,7 +117,7 @@ public: // Make the stage. unique_ptr<PlanStage> root( - new CollectionScan(&_opCtx, csparams, ws.get(), cq.get()->root())); + new CollectionScan(&_opCtx, coll, csparams, ws.get(), cq.get()->root())); // Hand the plan off to the executor. auto statusWithPlanExecutor = PlanExecutor::make( diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp index e11bbe5eb4c..5fa7248fbbb 100644 --- a/src/mongo/dbtests/query_stage_collscan.cpp +++ b/src/mongo/dbtests/query_stage_collscan.cpp @@ -86,10 +86,10 @@ public: int countResults(CollectionScanParams::Direction direction, const BSONObj& filterObj) { AutoGetCollectionForReadCommand ctx(&_opCtx, nss); + auto collection = ctx.getCollection(); // Configure the scan. CollectionScanParams params; - params.collection = ctx.getCollection(); params.direction = direction; params.tailable = false; @@ -105,10 +105,10 @@ public: // Make a scan and have the runner own it. unique_ptr<WorkingSet> ws = make_unique<WorkingSet>(); unique_ptr<PlanStage> ps = - make_unique<CollectionScan>(&_opCtx, params, ws.get(), filterExpr.get()); + make_unique<CollectionScan>(&_opCtx, collection, params, ws.get(), filterExpr.get()); auto statusWithPlanExecutor = PlanExecutor::make( - &_opCtx, std::move(ws), std::move(ps), params.collection, PlanExecutor::NO_YIELD); + &_opCtx, std::move(ws), std::move(ps), collection, PlanExecutor::NO_YIELD); ASSERT_OK(statusWithPlanExecutor.getStatus()); auto exec = std::move(statusWithPlanExecutor.getValue()); @@ -128,11 +128,10 @@ public: WorkingSet ws; CollectionScanParams params; - params.collection = collection; params.direction = direction; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, collection, params, &ws, NULL)); while (!scan->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState state = scan->work(&id); @@ -210,19 +209,20 @@ class QueryStageCollscanObjectsInOrderForward : public QueryStageCollectionScanB public: void run() { AutoGetCollectionForReadCommand ctx(&_opCtx, nss); + auto collection = ctx.getCollection(); // Configure the scan. CollectionScanParams params; - params.collection = ctx.getCollection(); params.direction = CollectionScanParams::FORWARD; params.tailable = false; // Make a scan and have the runner own it. unique_ptr<WorkingSet> ws = make_unique<WorkingSet>(); - unique_ptr<PlanStage> ps = make_unique<CollectionScan>(&_opCtx, params, ws.get(), nullptr); + unique_ptr<PlanStage> ps = + make_unique<CollectionScan>(&_opCtx, collection, params, ws.get(), nullptr); auto statusWithPlanExecutor = PlanExecutor::make( - &_opCtx, std::move(ws), std::move(ps), params.collection, PlanExecutor::NO_YIELD); + &_opCtx, std::move(ws), std::move(ps), collection, PlanExecutor::NO_YIELD); ASSERT_OK(statusWithPlanExecutor.getStatus()); auto exec = std::move(statusWithPlanExecutor.getValue()); @@ -246,17 +246,18 @@ class QueryStageCollscanObjectsInOrderBackward : public QueryStageCollectionScan public: void run() { AutoGetCollectionForReadCommand ctx(&_opCtx, nss); + auto collection = ctx.getCollection(); CollectionScanParams params; - params.collection = ctx.getCollection(); params.direction = CollectionScanParams::BACKWARD; params.tailable = false; unique_ptr<WorkingSet> ws = make_unique<WorkingSet>(); - unique_ptr<PlanStage> ps = make_unique<CollectionScan>(&_opCtx, params, ws.get(), nullptr); + unique_ptr<PlanStage> ps = + make_unique<CollectionScan>(&_opCtx, collection, params, ws.get(), nullptr); auto statusWithPlanExecutor = PlanExecutor::make( - &_opCtx, std::move(ws), std::move(ps), params.collection, PlanExecutor::NO_YIELD); + &_opCtx, std::move(ws), std::move(ps), collection, PlanExecutor::NO_YIELD); ASSERT_OK(statusWithPlanExecutor.getStatus()); auto exec = std::move(statusWithPlanExecutor.getValue()); @@ -289,12 +290,11 @@ public: // Configure the scan. CollectionScanParams params; - params.collection = coll; params.direction = CollectionScanParams::FORWARD; params.tailable = false; WorkingSet ws; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<PlanStage> scan(new CollectionScan(&_opCtx, coll, params, &ws, NULL)); int count = 0; while (count < 10) { @@ -349,12 +349,11 @@ public: // Configure the scan. CollectionScanParams params; - params.collection = coll; params.direction = CollectionScanParams::BACKWARD; params.tailable = false; WorkingSet ws; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<PlanStage> scan(new CollectionScan(&_opCtx, coll, params, &ws, NULL)); int count = 0; while (count < 10) { diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp index c6ab01e62c8..82d7cef339e 100644 --- a/src/mongo/dbtests/query_stage_count.cpp +++ b/src/mongo/dbtests/query_stage_count.cpp @@ -91,11 +91,10 @@ public: WorkingSet ws; CollectionScanParams params; - params.collection = _coll; params.direction = CollectionScanParams::FORWARD; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, _coll, params, &ws, NULL)); while (!scan->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState state = scan->work(&id); @@ -221,10 +220,9 @@ public: CollectionScan* createCollScan(MatchExpression* expr, WorkingSet* ws) { CollectionScanParams params; - params.collection = _coll; // This child stage gets owned and freed by its parent CountStage - return new CollectionScan(&_opCtx, params, ws, expr); + return new CollectionScan(&_opCtx, _coll, params, ws, expr); } static const char* ns() { diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp index 5d86035a58e..e22ee615b3f 100644 --- a/src/mongo/dbtests/query_stage_delete.cpp +++ b/src/mongo/dbtests/query_stage_delete.cpp @@ -88,11 +88,10 @@ public: WorkingSet ws; CollectionScanParams params; - params.collection = collection; params.direction = direction; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, collection, params, &ws, NULL)); while (!scan->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState state = scan->work(&id); @@ -139,7 +138,6 @@ public: // Configure the scan. CollectionScanParams collScanParams; - collScanParams.collection = coll; collScanParams.direction = CollectionScanParams::FORWARD; collScanParams.tailable = false; @@ -152,7 +150,7 @@ public: deleteStageParams, &ws, coll, - new CollectionScan(&_opCtx, collScanParams, &ws, NULL)); + new CollectionScan(&_opCtx, coll, collScanParams, &ws, NULL)); const DeleteStats* stats = static_cast<const DeleteStats*>(deleteStage.getSpecificStats()); diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp index 3c2cc9d27d4..d4cdeb8048f 100644 --- a/src/mongo/dbtests/query_stage_multiplan.cpp +++ b/src/mongo/dbtests/query_stage_multiplan.cpp @@ -171,10 +171,9 @@ unique_ptr<PlanStage> getCollScanPlan(OperationContext* opCtx, WorkingSet* sharedWs, MatchExpression* matchExpr) { CollectionScanParams csparams; - csparams.collection = coll; csparams.direction = CollectionScanParams::FORWARD; - unique_ptr<PlanStage> root(new CollectionScan(opCtx, csparams, sharedWs, matchExpr)); + unique_ptr<PlanStage> root(new CollectionScan(opCtx, coll, csparams, sharedWs, matchExpr)); return root; } @@ -581,11 +580,6 @@ TEST_F(QueryStageMultiPlanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlannin unique_ptr<WorkingSet> sharedWs(new WorkingSet()); unique_ptr<PlanStage> ixScanRoot = getIxScanPlan(_opCtx.get(), coll, sharedWs.get(), 7); - // Plan 1: CollScan with matcher. - CollectionScanParams csparams; - csparams.collection = coll; - csparams.direction = CollectionScanParams::FORWARD; - // Make the filter. BSONObj filterObj = BSON("foo" << 7); unique_ptr<MatchExpression> filter = makeMatchExpressionFromFilter(_opCtx.get(), filterObj); diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp index 62b87d30c24..dec254e9a50 100644 --- a/src/mongo/dbtests/query_stage_sort.cpp +++ b/src/mongo/dbtests/query_stage_sort.cpp @@ -366,7 +366,7 @@ public: coll->updateDocument(&_opCtx, *it, oldDoc, newDoc(oldDoc), false, NULL, &args); wuow.commit(); } - ASSERT_OK(exec->restoreState()); + exec->restoreState(); // Read the rest of the data from the queued data stage. while (!queuedDataStage->isEOF()) { @@ -385,7 +385,7 @@ public: wuow.commit(); } } - ASSERT_OK(exec->restoreState()); + exec->restoreState(); // Verify that it's sorted, the right number of documents are returned, and they're all // in the expected range. @@ -465,7 +465,7 @@ public: coll->deleteDocument(&_opCtx, kUninitializedStmtId, *it++, nullOpDebug); wuow.commit(); } - ASSERT_OK(exec->restoreState()); + exec->restoreState(); // Read the rest of the data from the queued data stage. while (!queuedDataStage->isEOF()) { @@ -482,7 +482,7 @@ public: wuow.commit(); } } - ASSERT_OK(exec->restoreState()); + exec->restoreState(); // Regardless of storage engine, all the documents should come back with their objects int count = 0; diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp index b5e153294d3..bc07c4ec803 100644 --- a/src/mongo/dbtests/query_stage_update.cpp +++ b/src/mongo/dbtests/query_stage_update.cpp @@ -129,11 +129,10 @@ public: WorkingSet ws; CollectionScanParams params; - params.collection = collection; params.direction = CollectionScanParams::FORWARD; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, collection, params, &ws, NULL)); while (!scan->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState state = scan->work(&id); @@ -151,11 +150,10 @@ public: WorkingSet ws; CollectionScanParams params; - params.collection = collection; params.direction = direction; params.tailable = false; - unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, params, &ws, NULL)); + unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, collection, params, &ws, NULL)); while (!scan->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState state = scan->work(&id); @@ -300,7 +298,6 @@ public: // Configure the scan. CollectionScanParams collScanParams; - collScanParams.collection = coll; collScanParams.direction = CollectionScanParams::FORWARD; collScanParams.tailable = false; @@ -310,7 +307,8 @@ public: updateParams.canonicalQuery = cq.get(); auto ws = make_unique<WorkingSet>(); - auto cs = make_unique<CollectionScan>(&_opCtx, collScanParams, ws.get(), cq->root()); + auto cs = + make_unique<CollectionScan>(&_opCtx, coll, collScanParams, ws.get(), cq->root()); auto updateStage = make_unique<UpdateStage>(&_opCtx, updateParams, ws.get(), coll, cs.release()); |