diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-06-12 16:12:24 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-06-15 13:57:07 -0400 |
commit | e733c07891c2f1e16320707317eeb28559bdc03f (patch) | |
tree | 3996cacafb06f58e2d35f13b779cdc632c84bde9 /src/mongo/dbtests | |
parent | 4b23c5793849cb9a6943607d2a55d7306e61eed4 (diff) | |
download | mongo-e733c07891c2f1e16320707317eeb28559bdc03f.tar.gz |
SERVER-35516 Get rid of OldClientWriteContext
Diffstat (limited to 'src/mongo/dbtests')
24 files changed, 176 insertions, 111 deletions
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp index 13fc07014bd..cbec62d92b5 100644 --- a/src/mongo/dbtests/clienttests.cpp +++ b/src/mongo/dbtests/clienttests.cpp @@ -108,7 +108,7 @@ public: const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; - OldClientWriteContext ctx(&opCtx, ns()); + dbtests::WriteContextForTests ctx(&opCtx, ns()); DBDirectClient db(&opCtx); db.insert(ns(), BSON("x" << 1 << "y" << 2)); diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp index 91d32f7e032..2aff3249936 100644 --- a/src/mongo/dbtests/dbtests.cpp +++ b/src/mongo/dbtests/dbtests.cpp @@ -123,6 +123,39 @@ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj return Status::OK(); } +WriteContextForTests::WriteContextForTests(OperationContext* opCtx, StringData ns) + : _opCtx(opCtx), _nss(ns) { + // Lock the database and collection + _autoCreateDb.emplace(opCtx, _nss.db(), MODE_IX); + _collLock.emplace(opCtx->lockState(), _nss.ns(), MODE_IX); + + const bool doShardVersionCheck = false; + + _clientContext.emplace(opCtx, _nss.ns(), doShardVersionCheck); + invariant(_autoCreateDb->getDb() == _clientContext->db()); + + // If the collection exists, there is no need to lock into stronger mode + if (getCollection()) + return; + + // If the database was just created, it is already locked in MODE_X so we can skip the relocking + // code below + if (_autoCreateDb->justCreated()) { + dassert(opCtx->lockState()->isDbLockedForMode(_nss.db(), MODE_X)); + return; + } + + // If the collection doesn't exists, put the context in a state where the database is locked in + // MODE_X so that the collection can be created + _clientContext.reset(); + _collLock.reset(); + _autoCreateDb.reset(); + _autoCreateDb.emplace(opCtx, _nss.db(), MODE_X); + + _clientContext.emplace(opCtx, _nss.ns(), _autoCreateDb->getDb()); + invariant(_autoCreateDb->getDb() == _clientContext->db()); +} + } // namespace dbtests } // namespace mongo diff --git a/src/mongo/dbtests/dbtests.h b/src/mongo/dbtests/dbtests.h index 68b7b0825fa..49a891b56c4 100644 --- a/src/mongo/dbtests/dbtests.h +++ b/src/mongo/dbtests/dbtests.h @@ -31,6 +31,7 @@ #pragma once +#include "mongo/db/db_raii.h" #include "mongo/unittest/unittest.h" using namespace mongo; @@ -38,6 +39,7 @@ using namespace mongo::unittest; using std::shared_ptr; namespace mongo { + class BSONObj; class OperationContext; class Status; @@ -57,5 +59,35 @@ Status createIndex(OperationContext* opCtx, * Creates an index from a BSON spec, if it does not already exist. */ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj& spec); + +/** + * Combines AutoGetOrCreateDb and OldClientContext. If the requested 'ns' exists, the constructed + * object will have both the database and the collection locked in MODE_IX. Otherwise, the database + * will be locked in MODE_X and will be created (note, only the database will be created, but not + * the collection). + */ +class WriteContextForTests { + MONGO_DISALLOW_COPYING(WriteContextForTests); + +public: + WriteContextForTests(OperationContext* opCtx, StringData ns); + + Database* db() const { + return _clientContext->db(); + } + + Collection* getCollection() const { + return db()->getCollection(_opCtx, _nss); + } + +private: + OperationContext* const _opCtx; + const NamespaceString _nss; + + boost::optional<AutoGetOrCreateDb> _autoCreateDb; + boost::optional<Lock::CollectionLock> _collLock; + boost::optional<OldClientContext> _clientContext; +}; + } // namespace dbtests } // namespace mongo diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp index 33530e2c2a5..867d253b87d 100644 --- a/src/mongo/dbtests/documentsourcetests.cpp +++ b/src/mongo/dbtests/documentsourcetests.cpp @@ -86,7 +86,7 @@ protected: // clean up first if this was called before _source.reset(); - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); auto qr = stdx::make_unique<QueryRequest>(nss); if (hint) { diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp index 044499c4416..02686dd2c26 100644 --- a/src/mongo/dbtests/executor_registry.cpp +++ b/src/mongo/dbtests/executor_registry.cpp @@ -56,7 +56,7 @@ static const NamespaceString nss("unittests.ExecutorRegistryDiskLocInvalidation" class ExecutorRegistryBase { public: ExecutorRegistryBase() : _client(&_opCtx) { - _ctx.reset(new OldClientWriteContext(&_opCtx, nss.ns())); + _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); _client.dropCollection(nss.ns()); for (int i = 0; i < N(); ++i) { @@ -103,7 +103,7 @@ public: // Order of these is important for initialization const ServiceContext::UniqueOperationContext _opCtxPtr = cc().makeOperationContext(); OperationContext& _opCtx = *_opCtxPtr; - unique_ptr<OldClientWriteContext> _ctx; + unique_ptr<dbtests::WriteContextForTests> _ctx; DBDirectClient _client; }; @@ -243,7 +243,7 @@ public: // requires a "global write lock." _ctx.reset(); _client.dropDatabase("somesillydb"); - _ctx.reset(new OldClientWriteContext(&_opCtx, nss.ns())); + _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); ASSERT_OK(exec->restoreState()); ASSERT_EQUALS(PlanExecutor::ADVANCED, exec->getNext(&obj, NULL)); @@ -254,7 +254,7 @@ public: // Drop our DB. Once again, must give up the lock. _ctx.reset(); _client.dropDatabase("unittests"); - _ctx.reset(new OldClientWriteContext(&_opCtx, nss.ns())); + _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); ASSERT_EQUALS(ErrorCodes::QueryPlanKilled, exec->restoreState()); } }; diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp index 0696e151858..ed479bfb267 100644 --- a/src/mongo/dbtests/indexcatalogtests.cpp +++ b/src/mongo/dbtests/indexcatalogtests.cpp @@ -63,7 +63,7 @@ public: void run() { const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; - OldClientWriteContext ctx(&opCtx, _ns); + dbtests::WriteContextForTests ctx(&opCtx, _ns); int numFinishedIndexesStart = _catalog->numIndexesReady(&opCtx); @@ -130,7 +130,7 @@ public: void run() { const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; - OldClientWriteContext ctx(&opCtx, _ns); + dbtests::WriteContextForTests ctx(&opCtx, _ns); const std::string indexName = "x_1"; ASSERT_OK(dbtests::createIndexFromSpec( diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp index 650370c7bb1..e7926489671 100644 --- a/src/mongo/dbtests/indexupdatetests.cpp +++ b/src/mongo/dbtests/indexupdatetests.cpp @@ -95,7 +95,7 @@ protected: const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); OperationContext& _opCtx = *_txnPtr; - OldClientWriteContext _ctx; + dbtests::WriteContextForTests _ctx; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp index affc2bca9d0..a2467126c1a 100644 --- a/src/mongo/dbtests/plan_ranking.cpp +++ b/src/mongo/dbtests/plan_ranking.cpp @@ -80,7 +80,7 @@ public: // Ensure N is significantly larger then internalQueryPlanEvaluationWorks. ASSERT_GTE(N, internalQueryPlanEvaluationWorks.load() + 1000); - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.dropCollection(nss.ns()); } @@ -91,7 +91,7 @@ public: } void insert(const BSONObj& obj) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.insert(nss.ns(), obj); } diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp index 51a5f7723cd..33e5a893bfd 100644 --- a/src/mongo/dbtests/query_plan_executor.cpp +++ b/src/mongo/dbtests/query_plan_executor.cpp @@ -193,7 +193,7 @@ private: * PlanExecutor is doing a collection scan. */ TEST_F(PlanExecutorTest, DropCollScan) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); @@ -215,7 +215,7 @@ TEST_F(PlanExecutorTest, DropCollScan) { * Test dropping the collection while the PlanExecutor is doing an index scan. */ TEST_F(PlanExecutorTest, DropIndexScan) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1 << "a" << 6)); insert(BSON("_id" << 2 << "a" << 7)); insert(BSON("_id" << 3 << "a" << 8)); @@ -237,7 +237,7 @@ TEST_F(PlanExecutorTest, DropIndexScan) { * Test dropping the collection while an agg PlanExecutor is doing an index scan. */ TEST_F(PlanExecutorTest, DropIndexScanAgg) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1 << "a" << 6)); insert(BSON("_id" << 2 << "a" << 7)); @@ -282,7 +282,7 @@ TEST_F(PlanExecutorTest, DropIndexScanAgg) { } TEST_F(PlanExecutorTest, ShouldReportErrorIfExceedsTimeLimitDuringYield) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); @@ -297,7 +297,7 @@ TEST_F(PlanExecutorTest, ShouldReportErrorIfExceedsTimeLimitDuringYield) { } TEST_F(PlanExecutorTest, ShouldReportErrorIfKilledDuringYieldButIsTailableAndAwaitData) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); @@ -315,7 +315,7 @@ TEST_F(PlanExecutorTest, ShouldReportErrorIfKilledDuringYieldButIsTailableAndAwa } TEST_F(PlanExecutorTest, ShouldNotSwallowExceedsTimeLimitDuringYieldButIsTailableButNotAwaitData) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); @@ -331,7 +331,7 @@ TEST_F(PlanExecutorTest, ShouldNotSwallowExceedsTimeLimitDuringYieldButIsTailabl } TEST_F(PlanExecutorTest, ShouldReportErrorIfKilledDuringYield) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); insert(BSON("_id" << 1)); insert(BSON("_id" << 2)); @@ -395,7 +395,7 @@ protected: * scan. */ TEST_F(PlanExecutorSnapshotTest, SnapshotControl) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); setupCollection(); BSONObj filterObj = fromjson("{a: {$gte: 2}}"); @@ -419,7 +419,7 @@ TEST_F(PlanExecutorSnapshotTest, SnapshotControl) { * index scan. */ TEST_F(PlanExecutorSnapshotTest, SnapshotTest) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); setupCollection(); BSONObj indexSpec = BSON("_id" << 1); addIndex(indexSpec); diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp index 7f6404cbcac..ea845004d55 100644 --- a/src/mongo/dbtests/query_stage_and.cpp +++ b/src/mongo/dbtests/query_stage_and.cpp @@ -169,7 +169,7 @@ private: class QueryStageAndHashInvalidation : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -274,7 +274,7 @@ public: class QueryStageAndHashInvalidateLookahead : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -364,7 +364,7 @@ public: class QueryStageAndHashTwoLeaf : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -414,7 +414,7 @@ public: class QueryStageAndHashTwoLeafFirstChildLargeKeys : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -467,7 +467,7 @@ public: class QueryStageAndHashTwoLeafLastChildLargeKeys : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -519,7 +519,7 @@ public: class QueryStageAndHashThreeLeaf : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -581,7 +581,7 @@ public: class QueryStageAndHashThreeLeafMiddleChildLargeKeys : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -641,7 +641,7 @@ public: class QueryStageAndHashWithNothing : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -703,7 +703,7 @@ public: class QueryStageAndHashProducesNothing : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -756,7 +756,7 @@ public: class QueryStageAndHashFirstChildFetched : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -815,7 +815,7 @@ public: class QueryStageAndHashSecondChildFetched : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -871,7 +871,7 @@ public: class QueryStageAndHashDeadChild : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1009,7 +1009,7 @@ public: class QueryStageAndSortedInvalidation : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1133,7 +1133,7 @@ public: class QueryStageAndSortedThreeLeaf : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1187,7 +1187,7 @@ public: class QueryStageAndSortedWithNothing : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1232,7 +1232,7 @@ public: class QueryStageAndSortedProducesNothing : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1281,7 +1281,7 @@ public: class QueryStageAndSortedByLastChild : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1346,7 +1346,7 @@ public: class QueryStageAndSortedFirstChildFetched : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { @@ -1400,7 +1400,7 @@ public: class QueryStageAndSortedSecondChildFetched : public QueryStageAndBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = ctx.getCollection(); if (!coll) { diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp index f202477b2af..f5afe597563 100644 --- a/src/mongo/dbtests/query_stage_cached_plan.cpp +++ b/src/mongo/dbtests/query_stage_cached_plan.cpp @@ -74,7 +74,7 @@ public: addIndex(BSON("a" << 1)); addIndex(BSON("b" << 1)); - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* collection = ctx.getCollection(); ASSERT(collection); diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp index 16d016f8eb9..f13b997bdb5 100644 --- a/src/mongo/dbtests/query_stage_collscan.cpp +++ b/src/mongo/dbtests/query_stage_collscan.cpp @@ -64,7 +64,7 @@ static const NamespaceString nss{"unittests.QueryStageCollectionScan"}; class QueryStageCollectionScanBase { public: QueryStageCollectionScanBase() : _client(&_opCtx) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); for (int i = 0; i < numObj(); ++i) { BSONObjBuilder bob; @@ -74,7 +74,7 @@ public: } virtual ~QueryStageCollectionScanBase() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.dropCollection(nss.ns()); } @@ -277,7 +277,7 @@ public: class QueryStageCollscanInvalidateUpcomingObject : public QueryStageCollectionScanBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* coll = ctx.getCollection(); @@ -343,7 +343,7 @@ public: class QueryStageCollscanInvalidateUpcomingObjectBackward : public QueryStageCollectionScanBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* coll = ctx.getCollection(); // Get the RecordIds that would be returned by an in-order scan. diff --git a/src/mongo/dbtests/query_stage_count_scan.cpp b/src/mongo/dbtests/query_stage_count_scan.cpp index 492b5693404..7e243068ae6 100644 --- a/src/mongo/dbtests/query_stage_count_scan.cpp +++ b/src/mongo/dbtests/query_stage_count_scan.cpp @@ -56,7 +56,7 @@ public: CountBase() : _client(&_opCtx) {} virtual ~CountBase() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); _client.dropCollection(ns()); } @@ -117,7 +117,7 @@ private: class QueryStageCountScanDups : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert some docs insert(BSON("a" << BSON_ARRAY(5 << 7))); @@ -149,7 +149,7 @@ public: class QueryStageCountScanInclusiveBounds : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert some docs for (int i = 0; i < 10; ++i) { @@ -181,7 +181,7 @@ public: class QueryStageCountScanExclusiveBounds : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert some docs for (int i = 0; i < 10; ++i) { @@ -213,7 +213,7 @@ public: class QueryStageCountScanLowerBound : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert doc, add index insert(BSON("a" << 2)); @@ -241,7 +241,7 @@ public: class QueryStageCountScanNothingInInterval : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index insert(BSON("a" << 2)); @@ -271,7 +271,7 @@ public: class QueryStageCountScanNothingInIntervalFirstMatchTooHigh : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert some documents, add index insert(BSON("a" << 2)); @@ -301,7 +301,7 @@ public: class QueryStageCountScanNoChangeDuringYield : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index for (int i = 0; i < 10; ++i) { @@ -354,7 +354,7 @@ public: class QueryStageCountScanDeleteDuringYield : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index for (int i = 0; i < 10; ++i) { @@ -410,7 +410,7 @@ public: class QueryStageCountScanInsertNewDocsDuringYield : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index for (int i = 0; i < 10; ++i) { @@ -469,7 +469,7 @@ public: class QueryStageCountScanBecomesMultiKeyDuringYield : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index for (int i = 0; i < 10; ++i) { @@ -524,7 +524,7 @@ public: class QueryStageCountScanUnusedKeys : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert docs, add index for (int i = 0; i < 10; ++i) { @@ -559,7 +559,7 @@ public: class QueryStageCountScanUnusedEndKey : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert docs, add index for (int i = 0; i < 10; ++i) { @@ -592,7 +592,7 @@ public: class QueryStageCountScanKeyBecomesUnusedDuringYield : public CountBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // Insert documents, add index for (int i = 0; i < 10; ++i) { diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp index 97e7166a478..987eb822f3f 100644 --- a/src/mongo/dbtests/query_stage_delete.cpp +++ b/src/mongo/dbtests/query_stage_delete.cpp @@ -61,7 +61,7 @@ static const NamespaceString nss("unittests.QueryStageDelete"); class QueryStageDeleteBase { public: QueryStageDeleteBase() : _client(&_opCtx) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); for (size_t i = 0; i < numObj(); ++i) { BSONObjBuilder bob; @@ -72,7 +72,7 @@ public: } virtual ~QueryStageDeleteBase() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.dropCollection(nss.ns()); } @@ -130,7 +130,7 @@ private: class QueryStageDeleteInvalidateUpcomingObject : public QueryStageDeleteBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* coll = ctx.getCollection(); @@ -196,7 +196,7 @@ class QueryStageDeleteReturnOldDoc : public QueryStageDeleteBase { public: void run() { // Various variables we'll need. - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* coll = ctx.getCollection(); const int targetDocIndex = 0; const BSONObj query = BSON("foo" << BSON("$gte" << targetDocIndex)); @@ -265,7 +265,7 @@ class QueryStageDeleteSkipOwnedObjects : public QueryStageDeleteBase { public: void run() { // Various variables we'll need. - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); Collection* coll = ctx.getCollection(); const BSONObj query = BSONObj(); const auto ws = make_unique<WorkingSet>(); diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp index ae1dd71152e..3ddf6b6e630 100644 --- a/src/mongo/dbtests/query_stage_fetch.cpp +++ b/src/mongo/dbtests/query_stage_fetch.cpp @@ -93,7 +93,7 @@ protected: class FetchStageAlreadyFetched : public QueryStageFetchBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { diff --git a/src/mongo/dbtests/query_stage_keep.cpp b/src/mongo/dbtests/query_stage_keep.cpp index 06e5753f85e..5a40ec12cc4 100644 --- a/src/mongo/dbtests/query_stage_keep.cpp +++ b/src/mongo/dbtests/query_stage_keep.cpp @@ -111,7 +111,7 @@ protected: class KeepStageBasic : public QueryStageKeepBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -178,7 +178,7 @@ public: class KeepStageFlagAdditionalAfterStreamingStarts : public QueryStageKeepBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp index 6670b4c1e58..44708b006b3 100644 --- a/src/mongo/dbtests/query_stage_merge_sort.cpp +++ b/src/mongo/dbtests/query_stage_merge_sort.cpp @@ -61,7 +61,7 @@ public: QueryStageMergeSortTestBase() : _client(&_opCtx) {} virtual ~QueryStageMergeSortTestBase() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); _client.dropCollection(ns()); } @@ -121,7 +121,7 @@ private: class QueryStageMergeSortPrefixIndex : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -192,7 +192,7 @@ public: class QueryStageMergeSortDups : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -262,7 +262,7 @@ public: class QueryStageMergeSortDupsNoDedup : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -333,7 +333,7 @@ public: class QueryStageMergeSortPrefixIndexReverse : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -405,7 +405,7 @@ public: class QueryStageMergeSortOneStageEOF : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -474,7 +474,7 @@ public: class QueryStageMergeSortManyShort : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -533,7 +533,7 @@ public: class QueryStageMergeSortInvalidation : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -649,7 +649,7 @@ public: class QueryStageMergeSortInvalidationMutationDedup : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -746,7 +746,7 @@ private: class QueryStageMergeSortStringsWithNullCollation : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -819,7 +819,7 @@ public: class QueryStageMergeSortStringsRespectsCollation : public QueryStageMergeSortTestBase { public: void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp index bc12573b8aa..b0fa90d210c 100644 --- a/src/mongo/dbtests/query_stage_multiplan.cpp +++ b/src/mongo/dbtests/query_stage_multiplan.cpp @@ -81,12 +81,12 @@ std::unique_ptr<QuerySolution> createQuerySolution() { class QueryStageMultiPlanTest : public unittest::Test { public: QueryStageMultiPlanTest() : _client(_opCtx.get()) { - OldClientWriteContext ctx(_opCtx.get(), nss.ns()); + dbtests::WriteContextForTests ctx(_opCtx.get(), nss.ns()); _client.dropCollection(nss.ns()); } virtual ~QueryStageMultiPlanTest() { - OldClientWriteContext ctx(_opCtx.get(), nss.ns()); + dbtests::WriteContextForTests ctx(_opCtx.get(), nss.ns()); _client.dropCollection(nss.ns()); } @@ -95,12 +95,12 @@ public: } void insert(const BSONObj& obj) { - OldClientWriteContext ctx(_opCtx.get(), nss.ns()); + dbtests::WriteContextForTests ctx(_opCtx.get(), nss.ns()); _client.insert(nss.ns(), obj); } void remove(const BSONObj& obj) { - OldClientWriteContext ctx(_opCtx.get(), nss.ns()); + dbtests::WriteContextForTests ctx(_opCtx.get(), nss.ns()); _client.remove(nss.ns(), obj); } diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp index 6da81f409a7..cfa651d2ed9 100644 --- a/src/mongo/dbtests/query_stage_sort.cpp +++ b/src/mongo/dbtests/query_stage_sort.cpp @@ -236,7 +236,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -258,7 +258,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -289,7 +289,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -314,7 +314,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -426,7 +426,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { @@ -525,7 +525,7 @@ public: } void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); Database* db = ctx.db(); Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp index 891493e99c1..3d1f5764648 100644 --- a/src/mongo/dbtests/query_stage_subplan.cpp +++ b/src/mongo/dbtests/query_stage_subplan.cpp @@ -58,7 +58,7 @@ public: QueryStageSubplanTest() : _client(_opCtx.get()) {} virtual ~QueryStageSubplanTest() { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); _client.dropCollection(nss.ns()); } @@ -112,7 +112,7 @@ private: * back to regular planning. */ TEST_F(QueryStageSubplanTest, QueryStageSubplanGeo2dOr) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); addIndex(BSON("a" << "2d" << "b" @@ -149,7 +149,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanGeo2dOr) { * Test the SubplanStage's ability to plan an individual branch using the plan cache. */ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanFromCache) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); addIndex(BSON("a" << 1)); addIndex(BSON("a" << 1 << "b" << 1)); @@ -207,7 +207,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanFromCache) { * Ensure that the subplan stage doesn't create a plan cache entry if there are no query results. */ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheZeroResults) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); addIndex(BSON("a" << 1 << "b" << 1)); addIndex(BSON("a" << 1)); @@ -262,7 +262,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheZeroResults) { * Ensure that the subplan stage doesn't create a plan cache entry if there are no query results. */ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheTies) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); addIndex(BSON("a" << 1 << "b" << 1)); addIndex(BSON("a" << 1 << "c" << 1)); @@ -441,7 +441,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanCanUseSubplanning) { * Regression test for SERVER-19388. */ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); addIndex(BSON("a" << 1 << "b" << 1)); addIndex(BSON("a" << 1 << "c" << 1)); @@ -484,7 +484,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) { } TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); // Build a query with a rooted $or. auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); @@ -517,7 +517,7 @@ TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning) } TEST_F(QueryStageSubplanTest, ShouldReportErrorIfKilledDuringPlanning) { - OldClientWriteContext ctx(opCtx(), nss.ns()); + dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); // Build a query with a rooted $or. auto queryRequest = stdx::make_unique<QueryRequest>(nss); queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp index 8f6e5a52373..002a213791b 100644 --- a/src/mongo/dbtests/query_stage_tests.cpp +++ b/src/mongo/dbtests/query_stage_tests.cpp @@ -55,7 +55,7 @@ using std::unique_ptr; class IndexScanBase { public: IndexScanBase() : _client(&_opCtx) { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); for (int i = 0; i < numObj(); ++i) { BSONObjBuilder bob; @@ -70,7 +70,7 @@ public: } virtual ~IndexScanBase() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); _client.dropCollection(ns()); } @@ -109,7 +109,7 @@ public: } void makeGeoData() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); for (int i = 0; i < numObj(); ++i) { double lat = double(rand()) / RAND_MAX; diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp index cc9cc693e34..fb8d4b57994 100644 --- a/src/mongo/dbtests/query_stage_update.cpp +++ b/src/mongo/dbtests/query_stage_update.cpp @@ -65,13 +65,13 @@ static const NamespaceString nss("unittests.QueryStageUpdate"); class QueryStageUpdateBase { public: QueryStageUpdateBase() : _client(&_opCtx) { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.dropCollection(nss.ns()); _client.createCollection(nss.ns()); } virtual ~QueryStageUpdateBase() { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); _client.dropCollection(nss.ns()); } @@ -186,7 +186,7 @@ public: void run() { // Run the update. { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); CurOp& curOp = *CurOp::get(_opCtx); OpDebug* opDebug = &curOp.debug(); const CollatorInterface* collator = nullptr; @@ -250,7 +250,7 @@ public: void run() { // Run the update. { - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); // Populate the collection. for (int i = 0; i < 10; ++i) { @@ -374,7 +374,7 @@ public: ASSERT_EQUALS(10U, count(BSONObj())); // Various variables we'll need. - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); OpDebug* opDebug = &CurOp::get(_opCtx)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(nss); @@ -465,7 +465,7 @@ public: ASSERT_EQUALS(50U, count(BSONObj())); // Various variables we'll need. - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); OpDebug* opDebug = &CurOp::get(_opCtx)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(nss); @@ -552,7 +552,7 @@ class QueryStageUpdateSkipOwnedObjects : public QueryStageUpdateBase { public: void run() { // Various variables we'll need. - OldClientWriteContext ctx(&_opCtx, nss.ns()); + dbtests::WriteContextForTests ctx(&_opCtx, nss.ns()); OpDebug* opDebug = &CurOp::get(_opCtx)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(nss); diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index c581aa74023..6cda42ae07f 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -282,7 +282,7 @@ public: { // Check internal server handoff to getmore. - OldClientWriteContext ctx(&_opCtx, ns); + dbtests::WriteContextForTests ctx(&_opCtx, ns); auto pinnedCursor = unittest::assertGet( ctx.getCollection()->getCursorManager()->pinCursor(&_opCtx, cursorId)); ASSERT_EQUALS(2, pinnedCursor.getCursor()->pos()); @@ -1285,7 +1285,7 @@ public: } string err; - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); // note that extents are always at least 4KB now - so this will get rounded up // a bit. @@ -1352,7 +1352,7 @@ public: HelperTest() : CollectionBase("helpertest") {} void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); for (int i = 0; i < 50; i++) { insert(ns(), BSON("_id" << i << "x" << i * 2)); @@ -1399,7 +1399,7 @@ public: HelperByIdTest() : CollectionBase("helpertestbyid") {} void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); for (int i = 0; i < 1000; i++) { insert(ns(), BSON("_id" << i << "x" << i * 2)); @@ -1420,7 +1420,7 @@ class ClientCursorTest : public CollectionBase { ClientCursorTest() : CollectionBase("clientcursortest") {} void run() { - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); for (int i = 0; i < 1000; i++) { insert(ns(), BSON("_id" << i << "x" << i * 2)); diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp index 2314ad40cad..5707b2f667f 100644 --- a/src/mongo/dbtests/repltests.cpp +++ b/src/mongo/dbtests/repltests.cpp @@ -138,7 +138,7 @@ public: setOplogCollectionName(getGlobalServiceContext()); createOplog(&_opCtx); - OldClientWriteContext ctx(&_opCtx, ns()); + dbtests::WriteContextForTests ctx(&_opCtx, ns()); WriteUnitOfWork wuow(&_opCtx); Collection* c = ctx.db()->getCollection(&_opCtx, ns()); |