diff options
Diffstat (limited to 'src/mongo/db')
42 files changed, 722 insertions, 682 deletions
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp index 93cb2604b2b..ae018c38d0e 100644 --- a/src/mongo/db/operation_context.cpp +++ b/src/mongo/db/operation_context.cpp @@ -35,6 +35,7 @@ #include "mongo/db/client.h" #include "mongo/db/service_context.h" #include "mongo/platform/random.h" +#include "mongo/stdx/mutex.h" #include "mongo/util/assert_util.h" #include "mongo/util/clock_source.h" #include "mongo/util/fail_point_service.h" @@ -72,10 +73,9 @@ MONGO_FP_DECLARE(checkForInterruptFail); } // namespace -OperationContext::OperationContext(Client* client, unsigned int opId, Locker* locker) +OperationContext::OperationContext(Client* client, unsigned int opId) : _client(client), _opId(opId), - _locker(locker), _elapsedTime(client ? client->getServiceContext()->getTickSource() : SystemTickSource::get()) {} @@ -216,4 +216,15 @@ OperationContext::RecoveryUnitState OperationContext::setRecoveryUnit(RecoveryUn return oldState; } +std::unique_ptr<Locker> OperationContext::releaseLockState() { + dassert(_locker); + return std::move(_locker); +} + +void OperationContext::setLockState(std::unique_ptr<Locker> locker) { + dassert(!_locker); + dassert(locker); + _locker = std::move(locker); +} + } // namespace mongo diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index 07606c04715..0035bfa70d4 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -28,6 +28,8 @@ #pragma once +#include <memory> + #include "mongo/base/disallow_copying.h" #include "mongo/base/status.h" #include "mongo/db/client.h" @@ -109,9 +111,21 @@ public: * Interface for locking. Caller DOES NOT own pointer. */ Locker* lockState() const { - return _locker; + return _locker.get(); } + /** + * Sets the locker for use by this OperationContext. Call during OperationContext + * initialization, only. + */ + void setLockState(std::unique_ptr<Locker> locker); + + /** + * Releases the locker to the caller. Call during OperationContext cleanup or initialization, + * only. + */ + std::unique_ptr<Locker> releaseLockState(); + // --- operation level info? --- /** @@ -269,7 +283,7 @@ public: Microseconds getRemainingMaxTimeMicros() const; protected: - OperationContext(Client* client, unsigned int opId, Locker* locker); + OperationContext(Client* client, unsigned int opId); private: /** @@ -288,8 +302,7 @@ private: Client* const _client; const unsigned int _opId; - // Not owned. - Locker* const _locker; + std::unique_ptr<Locker> _locker; std::unique_ptr<RecoveryUnit> _recoveryUnit; RecoveryUnitState _ruState = kNotInUnitOfWork; diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 139cfddd869..7fae6cfa4a7 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -35,8 +35,6 @@ #include "mongo/db/client.h" #include "mongo/db/concurrency/lock_state.h" #include "mongo/db/curop.h" -#include "mongo/db/namespace_string.h" -#include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/stdx/memory.h" @@ -52,11 +50,11 @@ std::unique_ptr<Locker> newLocker() { class ClientOperationInfo { public: - Locker* getLocker() { + std::unique_ptr<Locker>& locker() { if (!_locker) { _locker = newLocker(); } - return _locker.get(); + return _locker; } private: @@ -70,19 +68,15 @@ const auto clientOperationInfoDecoration = Client::declareDecoration<ClientOpera using std::string; OperationContextImpl::OperationContextImpl(Client* client, unsigned opId) - : OperationContext(client, opId, clientOperationInfoDecoration(client).getLocker()) { + : OperationContext(client, opId) { + setLockState(std::move(clientOperationInfoDecoration(client).locker())); StorageEngine* storageEngine = getServiceContext()->getGlobalStorageEngine(); setRecoveryUnit(storageEngine->newRecoveryUnit(), kNotInUnitOfWork); - - stdx::lock_guard<Client> lk(*client); - client->setOperationContext(this); } OperationContextImpl::~OperationContextImpl() { lockState()->assertEmptyAndReset(); - auto client = getClient(); - stdx::lock_guard<Client> lk(*client); - client->resetOperationContext(); + clientOperationInfoDecoration(getClient()).locker() = releaseLockState(); } ProgressMeter* OperationContextImpl::setMessage_inlock(const char* msg, diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h index 92efb01802f..695fabb14f5 100644 --- a/src/mongo/db/operation_context_noop.h +++ b/src/mongo/db/operation_context_noop.h @@ -27,49 +27,38 @@ */ #pragma once - -#include "mongo/db/client.h" #include "mongo/db/concurrency/locker_noop.h" -#include "mongo/db/curop.h" #include "mongo/db/operation_context.h" #include "mongo/db/storage/recovery_unit_noop.h" +#include "mongo/stdx/memory.h" +#include "mongo/util/progress_meter.h" namespace mongo { +class Client; + class OperationContextNoop : public OperationContext { public: - OperationContextNoop() : OperationContextNoop(new RecoveryUnitNoop()) {} - - OperationContextNoop(RecoveryUnit* ru) : OperationContextNoop(nullptr, 0, ru) {} - - OperationContextNoop(Client* client, unsigned int opId) - : OperationContextNoop(client, opId, new RecoveryUnitNoop()) {} - - OperationContextNoop(Client* client, unsigned int opId, RecoveryUnit* ru) - : OperationContextNoop(client, opId, new LockerNoop(), ru) {} - - OperationContextNoop(Client* client, unsigned int opId, Locker* locker) - : OperationContextNoop(client, opId, locker, new RecoveryUnitNoop()) {} - - OperationContextNoop(Client* client, unsigned int opId, Locker* locker, RecoveryUnit* ru) - : OperationContext(client, opId, locker) { + /** + * These constructors are for use in legacy tests that do not need operation contexts that are + * properly connected to clients. + */ + OperationContextNoop() : OperationContextNoop(nullptr, 0) {} + OperationContextNoop(RecoveryUnit* ru) : OperationContextNoop(nullptr, 0) { setRecoveryUnit(ru, kNotInUnitOfWork); - _locker.reset(lockState()); - - if (client) { - stdx::lock_guard<Client> lk(*client); - client->setOperationContext(this); - } } - virtual ~OperationContextNoop() { - auto client = getClient(); - if (client) { - stdx::lock_guard<Client> lk(*client); - client->resetOperationContext(); - } + + /** + * This constructor is for use by ServiceContexts, and should not be called directly. + */ + OperationContextNoop(Client* client, unsigned int opId) : OperationContext(client, opId) { + setRecoveryUnit(new RecoveryUnitNoop(), kNotInUnitOfWork); + setLockState(stdx::make_unique<LockerNoop>()); } + virtual ~OperationContextNoop() = default; + virtual ProgressMeter* setMessage_inlock(const char* msg, const std::string& name, unsigned long long progressMeterTotal, @@ -78,7 +67,6 @@ public: } private: - std::unique_ptr<Locker> _locker; ProgressMeter _pm; }; diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index c40542ebc5e..368961bc728 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -847,7 +847,7 @@ TEST_F(ReplCoordTest, NodeReturnsUnknownReplWriteConcernWhenAwaitReplicationReceivesAnInvalidWriteConcernMode) { auto service = stdx::make_unique<ServiceContextNoop>(); auto client = service->makeClient("test"); - OperationContextNoop txn(client.get(), 100); + auto txn = client->makeOperationContext(); assertStartSuccess(BSON("_id" << "mySet" @@ -879,7 +879,7 @@ TEST_F(ReplCoordTest, invalidWriteConcern.wMode = "fakemode"; ReplicationCoordinator::StatusAndDuration statusAndDur = - getReplCoord()->awaitReplication(&txn, time1, invalidWriteConcern); + getReplCoord()->awaitReplication(txn.get(), time1, invalidWriteConcern); ASSERT_EQUALS(ErrorCodes::UnknownReplWriteConcern, statusAndDur.status); } @@ -888,7 +888,7 @@ TEST_F( NodeReturnsWriteConcernFailedUntilASufficientSetOfNodesHaveTheWriteAndTheWriteIsInACommittedSnapshot) { auto service = stdx::make_unique<ServiceContextNoop>(); auto client = service->makeClient("test"); - OperationContextNoop txn(client.get(), 100); + auto txn = client->makeOperationContext(); assertStartSuccess( BSON("_id" @@ -963,11 +963,11 @@ TEST_F( getReplCoord()->setMyLastAppliedOpTime(time1); getReplCoord()->setMyLastDurableOpTime(time1); ReplicationCoordinator::StatusAndDuration statusAndDur = - getReplCoord()->awaitReplication(&txn, time1, majorityWriteConcern); + getReplCoord()->awaitReplication(txn.get(), time1, majorityWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiDCWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiDCWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiRackWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiRackWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); // Majority satisfied but not either custom mode @@ -977,46 +977,52 @@ TEST_F( getReplCoord()->setLastDurableOptime_forTest(2, 2, time1); getReplCoord()->onSnapshotCreate(time1, SnapshotName(1)); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, majorityWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, majorityWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiDCWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiDCWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiRackWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiRackWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); // All modes satisfied getReplCoord()->setLastAppliedOptime_forTest(2, 3, time1); getReplCoord()->setLastDurableOptime_forTest(2, 3, time1); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, majorityWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, majorityWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiDCWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiDCWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time1, multiRackWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time1, multiRackWriteConcern); ASSERT_OK(statusAndDur.status); // Majority also waits for the committed snapshot to be newer than all snapshots reserved by // this operation. Custom modes not affected by this. - while (getReplCoord()->reserveSnapshotName(&txn) <= SnapshotName(1)) { + while (getReplCoord()->reserveSnapshotName(txn.get()) <= SnapshotName(1)) { // These unittests "cheat" and use SnapshotName(1) without advancing the counter. Reserve // another name if we didn't get a high enough one. } - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, majorityWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), majorityWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, multiDCWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), multiDCWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, multiRackWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), multiRackWriteConcern); ASSERT_OK(statusAndDur.status); // All modes satisfied getReplCoord()->onSnapshotCreate(time1, getReplCoord()->reserveSnapshotName(nullptr)); - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, majorityWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), majorityWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, multiDCWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), multiDCWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplicationOfLastOpForClient(&txn, multiRackWriteConcern); + statusAndDur = + getReplCoord()->awaitReplicationOfLastOpForClient(txn.get(), multiRackWriteConcern); ASSERT_OK(statusAndDur.status); // multiDC satisfied but not majority or multiRack @@ -1025,11 +1031,11 @@ TEST_F( getReplCoord()->setLastAppliedOptime_forTest(2, 3, time2); getReplCoord()->setLastDurableOptime_forTest(2, 3, time2); - statusAndDur = getReplCoord()->awaitReplication(&txn, time2, majorityWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time2, majorityWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time2, multiDCWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time2, multiDCWriteConcern); ASSERT_OK(statusAndDur.status); - statusAndDur = getReplCoord()->awaitReplication(&txn, time2, multiRackWriteConcern); + statusAndDur = getReplCoord()->awaitReplication(txn.get(), time2, multiRackWriteConcern); ASSERT_EQUALS(ErrorCodes::WriteConcernFailed, statusAndDur.status); } diff --git a/src/mongo/db/repl/service_context_repl_mock.cpp b/src/mongo/db/repl/service_context_repl_mock.cpp index 8b4e9ed2ee7..4f8a424d274 100644 --- a/src/mongo/db/repl/service_context_repl_mock.cpp +++ b/src/mongo/db/repl/service_context_repl_mock.cpp @@ -35,13 +35,16 @@ #include "mongo/db/concurrency/lock_state.h" #include "mongo/db/concurrency/locker.h" #include "mongo/db/operation_context_noop.h" +#include "mongo/stdx/memory.h" namespace mongo { namespace repl { std::unique_ptr<OperationContext> ServiceContextReplMock::_newOpCtx(Client* client, unsigned opId) { - return std::unique_ptr<OperationContext>( - new OperationContextNoop(client, opId, new MMAPV1LockerImpl())); + auto opCtx = stdx::make_unique<OperationContextNoop>(client, opId); + opCtx->releaseLockState(); + opCtx->setLockState(stdx::make_unique<MMAPV1LockerImpl>()); + return opCtx; } } // namespace repl diff --git a/src/mongo/db/s/collection_sharding_state_test.cpp b/src/mongo/db/s/collection_sharding_state_test.cpp index c12d4395f7f..3e618df3f04 100644 --- a/src/mongo/db/s/collection_sharding_state_test.cpp +++ b/src/mongo/db/s/collection_sharding_state_test.cpp @@ -38,6 +38,7 @@ #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/type_shard_identity.h" +#include "mongo/db/server_options.h" #include "mongo/db/service_context_noop.h" #include "mongo/db/service_context_noop.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/s/sharding_state_test.cpp b/src/mongo/db/s/sharding_state_test.cpp index ecd4fe0af3b..ba8a456f51e 100644 --- a/src/mongo/db/s/sharding_state_test.cpp +++ b/src/mongo/db/s/sharding_state_test.cpp @@ -38,6 +38,7 @@ #include "mongo/db/operation_context_noop.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/type_shard_identity.h" +#include "mongo/db/server_options.h" #include "mongo/db/service_context_noop.h" #include "mongo/db/service_context_noop.h" #include "mongo/executor/network_interface_mock.h" diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index d34920f6704..03dc9bcaf8d 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -208,27 +208,20 @@ ServiceContext::UniqueOperationContext ServiceContext::makeOperationContext(Clie } throw; } - // // TODO(schwerin): When callers no longer construct their own OperationContexts directly, - // // but only through the ServiceContext, uncomment the following. Until then, it must - // // be done in the operation context destructors, which introduces a potential race. - // { - // stdx::lock_guard<Client> lk(*client); - // client->setOperationContext(opCtx.get()); - // } + { + stdx::lock_guard<Client> lk(*client); + client->setOperationContext(opCtx.get()); + } return UniqueOperationContext(opCtx.release()); }; void ServiceContext::OperationContextDeleter::operator()(OperationContext* opCtx) const { auto client = opCtx->getClient(); - invariant(client); auto service = client->getServiceContext(); - // // TODO(schwerin): When callers no longer construct their own OperationContexts directly, - // // but only through the ServiceContext, uncomment the following. Until then, it must - // // be done in the operation context destructors, which introduces a potential race. - // { - // stdx::lock_guard<Client> lk(*client); - // client->resetOperationContext(); - // } + { + stdx::lock_guard<Client> lk(*client); + client->resetOperationContext(); + } try { for (const auto& observer : service->_clientObservers) { observer->onDestroyOperationContext(opCtx); diff --git a/src/mongo/db/storage/record_store_test_datafor.cpp b/src/mongo/db/storage/record_store_test_datafor.cpp index f29300d9525..aa97da93979 100644 --- a/src/mongo/db/storage/record_store_test_datafor.cpp +++ b/src/mongo/db/storage/record_store_test_datafor.cpp @@ -51,14 +51,14 @@ TEST(RecordStoreTestHarness, DataFor) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } string data = "record-"; RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -70,12 +70,12 @@ TEST(RecordStoreTestHarness, DataFor) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(data.size() + 1, static_cast<size_t>(record.size())); @@ -91,14 +91,14 @@ TEST(RecordStoreTestHarness, DataForMultiple) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record----" << i; @@ -114,12 +114,12 @@ TEST(RecordStoreTestHarness, DataForMultiple) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record----" << i; diff --git a/src/mongo/db/storage/record_store_test_datasize.cpp b/src/mongo/db/storage/record_store_test_datasize.cpp index 03f06bd0834..cf8b1bf8360 100644 --- a/src/mongo/db/storage/record_store_test_datasize.cpp +++ b/src/mongo/db/storage/record_store_test_datasize.cpp @@ -49,12 +49,12 @@ TEST(RecordStoreTestHarness, DataSizeEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(rs->dataSize(opCtx.get()) == 0); } } @@ -65,13 +65,13 @@ TEST(RecordStoreTestHarness, DataSizeNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -86,12 +86,12 @@ TEST(RecordStoreTestHarness, DataSizeNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(rs->dataSize(opCtx.get()) > 0); } } diff --git a/src/mongo/db/storage/record_store_test_deleterecord.cpp b/src/mongo/db/storage/record_store_test_deleterecord.cpp index 372b67e1915..f3261d1c4d1 100644 --- a/src/mongo/db/storage/record_store_test_deleterecord.cpp +++ b/src/mongo/db/storage/record_store_test_deleterecord.cpp @@ -51,14 +51,14 @@ TEST(RecordStoreTestHarness, DeleteRecord) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } string data = "my record"; RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -70,12 +70,12 @@ TEST(RecordStoreTestHarness, DeleteRecord) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); rs->deleteRecord(opCtx.get(), loc); @@ -84,7 +84,7 @@ TEST(RecordStoreTestHarness, DeleteRecord) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } } @@ -95,14 +95,14 @@ TEST(RecordStoreTestHarness, DeleteMultipleRecords) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -118,12 +118,12 @@ TEST(RecordStoreTestHarness, DeleteMultipleRecords) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); rs->deleteRecord(opCtx.get(), locs[i]); @@ -132,7 +132,7 @@ TEST(RecordStoreTestHarness, DeleteMultipleRecords) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } } diff --git a/src/mongo/db/storage/record_store_test_harness.cpp b/src/mongo/db/storage/record_store_test_harness.cpp index 6512e3bfff1..8c59bff89fb 100644 --- a/src/mongo/db/storage/record_store_test_harness.cpp +++ b/src/mongo/db/storage/record_store_test_harness.cpp @@ -46,7 +46,7 @@ TEST(RecordStoreTestHarness, Simple1) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -55,7 +55,7 @@ TEST(RecordStoreTestHarness, Simple1) { RecordId loc1; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -69,7 +69,7 @@ TEST(RecordStoreTestHarness, Simple1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s, rs->dataFor(opCtx.get(), loc1).data()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); @@ -82,7 +82,7 @@ TEST(RecordStoreTestHarness, Simple1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -93,7 +93,7 @@ TEST(RecordStoreTestHarness, Simple1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, rs->numRecords(opCtx.get())); } } @@ -122,7 +122,7 @@ TEST(RecordStoreTestHarness, Simple1InsertDocWroter) { RecordId loc1; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -142,7 +142,7 @@ TEST(RecordStoreTestHarness, Delete1) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -150,7 +150,7 @@ TEST(RecordStoreTestHarness, Delete1) { RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -165,12 +165,12 @@ TEST(RecordStoreTestHarness, Delete1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -187,7 +187,7 @@ TEST(RecordStoreTestHarness, Delete2) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -195,7 +195,7 @@ TEST(RecordStoreTestHarness, Delete2) { RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -210,13 +210,13 @@ TEST(RecordStoreTestHarness, Delete2) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s, rs->dataFor(opCtx.get(), loc).data()); ASSERT_EQUALS(2, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); rs->deleteRecord(opCtx.get(), loc); @@ -230,7 +230,7 @@ TEST(RecordStoreTestHarness, Update1) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -239,7 +239,7 @@ TEST(RecordStoreTestHarness, Update1) { RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -251,12 +251,12 @@ TEST(RecordStoreTestHarness, Update1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s1, rs->dataFor(opCtx.get(), loc).data()); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); Status status = @@ -281,7 +281,7 @@ TEST(RecordStoreTestHarness, Update1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); ASSERT_EQUALS(s2, rs->dataFor(opCtx.get(), loc).data()); } @@ -300,7 +300,7 @@ TEST(RecordStoreTestHarness, UpdateInPlace1) { RecordId loc; const RecordData s1Rec(s1.c_str(), s1.size() + 1); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -312,12 +312,12 @@ TEST(RecordStoreTestHarness, UpdateInPlace1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s1, rs->dataFor(opCtx.get(), loc).data()); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); const char* damageSource = "222"; @@ -335,7 +335,7 @@ TEST(RecordStoreTestHarness, UpdateInPlace1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s2, rs->dataFor(opCtx.get(), loc).data()); } } @@ -346,7 +346,7 @@ TEST(RecordStoreTestHarness, Truncate1) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -354,7 +354,7 @@ TEST(RecordStoreTestHarness, Truncate1) { RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -367,17 +367,17 @@ TEST(RecordStoreTestHarness, Truncate1) { { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(s, rs->dataFor(opCtx.get(), loc).data()); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); rs->truncate(opCtx.get()); @@ -386,7 +386,7 @@ TEST(RecordStoreTestHarness, Truncate1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } } @@ -398,12 +398,12 @@ TEST(RecordStoreTestHarness, Cursor1) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); for (int i = 0; i < N; i++) { @@ -416,13 +416,13 @@ TEST(RecordStoreTestHarness, Cursor1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(N, rs->numRecords(opCtx.get())); } { int x = 0; - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get()); while (auto record = cursor->next()) { string s = str::stream() << "eliot" << x++; @@ -434,7 +434,7 @@ TEST(RecordStoreTestHarness, Cursor1) { { int x = N; - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get(), false); while (auto record = cursor->next()) { string s = str::stream() << "eliot" << --x; diff --git a/src/mongo/db/storage/record_store_test_harness.h b/src/mongo/db/storage/record_store_test_harness.h index cc613c3bd3b..09d028a97bd 100644 --- a/src/mongo/db/storage/record_store_test_harness.h +++ b/src/mongo/db/storage/record_store_test_harness.h @@ -52,12 +52,14 @@ public: virtual std::unique_ptr<RecordStore> newCappedRecordStore( int64_t cappedSizeBytes = kDefaultCapedSizeBytes, int64_t cappedMaxDocs = -1) = 0; - virtual std::unique_ptr<OperationContext> newOperationContext(Client* client) { - return stdx::make_unique<OperationContextNoop>(client, 1, newRecoveryUnit()); + virtual ServiceContext::UniqueOperationContext newOperationContext(Client* client) { + auto opCtx = client->makeOperationContext(); + opCtx->setRecoveryUnit(newRecoveryUnit(), OperationContext::kNotInUnitOfWork); + return opCtx; } - std::unique_ptr<OperationContext> newOperationContext() { - return newOperationContext(nullptr); + ServiceContext::UniqueOperationContext newOperationContext() { + return newOperationContext(_client.get()); } /** diff --git a/src/mongo/db/storage/record_store_test_insertrecord.cpp b/src/mongo/db/storage/record_store_test_insertrecord.cpp index 0ebca91645a..f1d04e72b18 100644 --- a/src/mongo/db/storage/record_store_test_insertrecord.cpp +++ b/src/mongo/db/storage/record_store_test_insertrecord.cpp @@ -52,14 +52,14 @@ TEST(RecordStoreTestHarness, InsertRecord) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } string data = "my record"; RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -71,7 +71,7 @@ TEST(RecordStoreTestHarness, InsertRecord) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } } @@ -83,14 +83,14 @@ TEST(RecordStoreTestHarness, InsertMultipleRecords) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -106,7 +106,7 @@ TEST(RecordStoreTestHarness, InsertMultipleRecords) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } } @@ -118,13 +118,13 @@ TEST(RecordStoreTestHarness, InsertRecordUsingDocWriter) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { StringDocWriter docWriter("my record", false); @@ -137,7 +137,7 @@ TEST(RecordStoreTestHarness, InsertRecordUsingDocWriter) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } } @@ -149,14 +149,14 @@ TEST(RecordStoreTestHarness, InsertMultipleRecordsUsingDocWriter) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -171,7 +171,7 @@ TEST(RecordStoreTestHarness, InsertMultipleRecordsUsingDocWriter) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } } diff --git a/src/mongo/db/storage/record_store_test_manyiter.cpp b/src/mongo/db/storage/record_store_test_manyiter.cpp index ead99310fc4..bed787057e4 100644 --- a/src/mongo/db/storage/record_store_test_manyiter.cpp +++ b/src/mongo/db/storage/record_store_test_manyiter.cpp @@ -53,12 +53,12 @@ TEST(RecordStoreTestHarness, GetManyIteratorsEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); for (auto&& cursor : rs->getManyCursors(opCtx.get())) { ASSERT(!cursor->next()); ASSERT(!cursor->next()); @@ -72,14 +72,14 @@ TEST(RecordStoreTestHarness, GetManyIteratorsNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -95,13 +95,13 @@ TEST(RecordStoreTestHarness, GetManyIteratorsNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } set<RecordId> remain(locs, locs + nToInsert); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); for (auto&& cursor : rs->getManyCursors(opCtx.get())) { while (auto record = cursor->next()) { ASSERT_EQ(remain.erase(record->id), size_t(1)); diff --git a/src/mongo/db/storage/record_store_test_randomiter.cpp b/src/mongo/db/storage/record_store_test_randomiter.cpp index 18379372f83..dbb34c00fb4 100644 --- a/src/mongo/db/storage/record_store_test_randomiter.cpp +++ b/src/mongo/db/storage/record_store_test_randomiter.cpp @@ -51,12 +51,12 @@ TEST(RecordStoreTestHarness, GetRandomIteratorEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getRandomCursor(opCtx.get()); // returns NULL if getRandomCursor is not supported if (!cursor) { @@ -72,7 +72,7 @@ TEST(RecordStoreTestHarness, GetRandomIteratorNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -80,7 +80,7 @@ TEST(RecordStoreTestHarness, GetRandomIteratorNonEmpty) { 5000; // should be non-trivial amount, so we get multiple btree levels RecordId locs[nToInsert]; for (unsigned i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -96,13 +96,13 @@ TEST(RecordStoreTestHarness, GetRandomIteratorNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } set<RecordId> remain(locs, locs + nToInsert); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getRandomCursor(opCtx.get()); // returns NULL if getRandomCursor is not supported if (!cursor) { @@ -133,14 +133,14 @@ TEST(RecordStoreTestHarness, GetRandomIteratorSingleton) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQ(0, rs->numRecords(opCtx.get())); } // Insert one record. RecordId idToRetrieve; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "some data", 10, false); ASSERT_OK(res.getStatus()); @@ -150,12 +150,12 @@ TEST(RecordStoreTestHarness, GetRandomIteratorSingleton) { // Double-check that the record store has one record in it now. { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQ(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getRandomCursor(opCtx.get()); // returns NULL if getRandomCursor is not supported if (!cursor) { @@ -167,6 +167,7 @@ TEST(RecordStoreTestHarness, GetRandomIteratorSingleton) { // Check deattaching / reattaching cursor->save(); cursor->detachFromOperationContext(); + opCtx.reset(); opCtx = harnessHelper->newOperationContext(); cursor->reattachToOperationContext(opCtx.get()); ASSERT_TRUE(cursor->restore()); diff --git a/src/mongo/db/storage/record_store_test_recorditer.cpp b/src/mongo/db/storage/record_store_test_recorditer.cpp index c9367e81ce4..e2cba18ea94 100644 --- a/src/mongo/db/storage/record_store_test_recorditer.cpp +++ b/src/mongo/db/storage/record_store_test_recorditer.cpp @@ -54,7 +54,7 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecords) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -62,7 +62,7 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecords) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -79,13 +79,13 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecords) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } std::sort(locs, locs + nToInsert); // inserted records may not be in RecordId order { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get()); for (int i = 0; i < nToInsert; i++) { const auto record = cursor->next(); @@ -105,7 +105,7 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecordsReversed) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -113,7 +113,7 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecordsReversed) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -130,13 +130,13 @@ TEST(RecordStoreTestHarness, IterateOverMultipleRecordsReversed) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } std::sort(locs, locs + nToInsert); // inserted records may not be in RecordId order { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get(), false); for (int i = nToInsert - 1; i >= 0; i--) { @@ -156,7 +156,7 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddle) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -164,7 +164,7 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddle) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -181,13 +181,13 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddle) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } std::sort(locs, locs + nToInsert); // inserted records may not be in RecordId order { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); int start = nToInsert / 2; auto cursor = rs->getCursor(opCtx.get()); @@ -208,7 +208,7 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddleReversed) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -216,7 +216,7 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddleReversed) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -233,13 +233,13 @@ TEST(RecordStoreTestHarness, IterateStartFromMiddleReversed) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } std::sort(locs, locs + nToInsert); // inserted records may not be in RecordId order { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); int start = nToInsert / 2; auto cursor = rs->getCursor(opCtx.get(), false); @@ -261,7 +261,7 @@ TEST(RecordStoreTestHarness, RecordIteratorEOF) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -269,7 +269,7 @@ TEST(RecordStoreTestHarness, RecordIteratorEOF) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { StringBuilder sb; sb << "record " << i; @@ -286,12 +286,12 @@ TEST(RecordStoreTestHarness, RecordIteratorEOF) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); // Get a forward iterator starting at the beginning of the record store. auto cursor = rs->getCursor(opCtx.get()); @@ -332,7 +332,7 @@ TEST(RecordStoreTestHarness, RecordIteratorSaveRestore) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -340,7 +340,7 @@ TEST(RecordStoreTestHarness, RecordIteratorSaveRestore) { RecordId locs[nToInsert]; std::string datas[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { StringBuilder sb; sb << "record " << i; @@ -357,12 +357,12 @@ TEST(RecordStoreTestHarness, RecordIteratorSaveRestore) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); // Get a forward iterator starting at the beginning of the record store. auto cursor = rs->getCursor(opCtx.get()); @@ -393,7 +393,7 @@ TEST(RecordStoreTestHarness, SeekAfterEofAndContinue) { unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const int nToInsert = 2; RecordId locs[nToInsert]; diff --git a/src/mongo/db/storage/record_store_test_repairiter.cpp b/src/mongo/db/storage/record_store_test_repairiter.cpp index 7c158d4b6e7..eca6c3fdc1d 100644 --- a/src/mongo/db/storage/record_store_test_repairiter.cpp +++ b/src/mongo/db/storage/record_store_test_repairiter.cpp @@ -51,12 +51,12 @@ TEST(RecordStoreTestHarness, GetIteratorForRepairEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursorForRepair(opCtx.get()); // returns NULL if getCursorForRepair is not supported if (!cursor) { @@ -73,14 +73,14 @@ TEST(RecordStoreTestHarness, GetIteratorForRepairNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -96,13 +96,13 @@ TEST(RecordStoreTestHarness, GetIteratorForRepairNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } set<RecordId> remain(locs, locs + nToInsert); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursorForRepair(opCtx.get()); // returns NULL if getCursorForRepair is not supported if (!cursor) { @@ -126,14 +126,14 @@ TEST(RecordStoreTestHarness, GetIteratorForRepairInvalidateSingleton) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQ(0, rs->numRecords(opCtx.get())); } // Insert one record. RecordId idToInvalidate; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "some data", 10, false); ASSERT_OK(res.getStatus()); @@ -143,12 +143,12 @@ TEST(RecordStoreTestHarness, GetIteratorForRepairInvalidateSingleton) { // Double-check that the record store has one record in it now. { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQ(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursorForRepair(opCtx.get()); // returns NULL if getCursorForRepair is not supported if (!cursor) { diff --git a/src/mongo/db/storage/record_store_test_storagesize.cpp b/src/mongo/db/storage/record_store_test_storagesize.cpp index 76c870404bf..cedcc930bab 100644 --- a/src/mongo/db/storage/record_store_test_storagesize.cpp +++ b/src/mongo/db/storage/record_store_test_storagesize.cpp @@ -48,13 +48,13 @@ TEST(RecordStoreTestHarness, StorageSizeNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -69,12 +69,12 @@ TEST(RecordStoreTestHarness, StorageSizeNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(rs->storageSize(opCtx.get(), NULL) >= 0); } } diff --git a/src/mongo/db/storage/record_store_test_touch.cpp b/src/mongo/db/storage/record_store_test_touch.cpp index 50cb891cca1..74fb7a2f0a7 100644 --- a/src/mongo/db/storage/record_store_test_touch.cpp +++ b/src/mongo/db/storage/record_store_test_touch.cpp @@ -48,12 +48,12 @@ TEST(RecordStoreTestHarness, TouchEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx( + ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext(harnessHelper->client())); { BSONObjBuilder stats; @@ -70,13 +70,13 @@ TEST(RecordStoreTestHarness, TouchNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -91,12 +91,12 @@ TEST(RecordStoreTestHarness, TouchNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx( + ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext(harnessHelper->client())); { BSONObjBuilder stats; @@ -115,12 +115,12 @@ TEST(RecordStoreTestHarness, TouchEmptyWithNullStats) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx( + ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext(harnessHelper->client())); Status status = rs->touch(opCtx.get(), NULL /* stats output */); ASSERT(status.isOK() || status.code() == ErrorCodes::CommandNotSupported); @@ -134,13 +134,13 @@ TEST(RecordStoreTestHarness, TouchNonEmptyWithNullStats) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -155,12 +155,12 @@ TEST(RecordStoreTestHarness, TouchNonEmptyWithNullStats) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx( + ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext(harnessHelper->client())); // XXX does not verify the collection was loaded into cache // (even if supported by storage engine) diff --git a/src/mongo/db/storage/record_store_test_truncate.cpp b/src/mongo/db/storage/record_store_test_truncate.cpp index 8f29c838705..bb485c9ade8 100644 --- a/src/mongo/db/storage/record_store_test_truncate.cpp +++ b/src/mongo/db/storage/record_store_test_truncate.cpp @@ -48,12 +48,12 @@ TEST(RecordStoreTestHarness, TruncateEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(rs->truncate(opCtx.get())); @@ -62,7 +62,7 @@ TEST(RecordStoreTestHarness, TruncateEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } } @@ -74,13 +74,13 @@ TEST(RecordStoreTestHarness, TruncateNonEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -95,12 +95,12 @@ TEST(RecordStoreTestHarness, TruncateNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(rs->truncate(opCtx.get())); @@ -109,7 +109,7 @@ TEST(RecordStoreTestHarness, TruncateNonEmpty) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } } diff --git a/src/mongo/db/storage/record_store_test_updaterecord.cpp b/src/mongo/db/storage/record_store_test_updaterecord.cpp index 0d1f4749460..cc2285aa6d0 100644 --- a/src/mongo/db/storage/record_store_test_updaterecord.cpp +++ b/src/mongo/db/storage/record_store_test_updaterecord.cpp @@ -51,14 +51,14 @@ TEST(RecordStoreTestHarness, UpdateRecord) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } string data = "my record"; RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -70,13 +70,13 @@ TEST(RecordStoreTestHarness, UpdateRecord) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } data = "updated record-"; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); Status res = @@ -97,7 +97,7 @@ TEST(RecordStoreTestHarness, UpdateRecord) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(data.size() + 1, static_cast<size_t>(record.size())); @@ -112,14 +112,14 @@ TEST(RecordStoreTestHarness, UpdateMultipleRecords) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } const int nToInsert = 10; RecordId locs[nToInsert]; for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "record " << i; @@ -135,12 +135,12 @@ TEST(RecordStoreTestHarness, UpdateMultipleRecords) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get())); } for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "update record-" << i; @@ -165,7 +165,7 @@ TEST(RecordStoreTestHarness, UpdateMultipleRecords) { } for (int i = 0; i < nToInsert; i++) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { stringstream ss; ss << "update record-" << i; @@ -184,14 +184,14 @@ TEST(RecordStoreTestHarness, UpdateRecordWithMoveNotifier) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } string oldData = "my record"; RecordId loc; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = @@ -203,13 +203,13 @@ TEST(RecordStoreTestHarness, UpdateRecordWithMoveNotifier) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } string newData = "my updated record--"; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { UpdateNotifierSpy umn(opCtx.get(), loc, oldData.c_str(), oldData.size()); @@ -234,7 +234,7 @@ TEST(RecordStoreTestHarness, UpdateRecordWithMoveNotifier) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(newData.size() + 1, static_cast<size_t>(record.size())); diff --git a/src/mongo/db/storage/record_store_test_updatewithdamages.cpp b/src/mongo/db/storage/record_store_test_updatewithdamages.cpp index 30850daffe5..97627963cab 100644 --- a/src/mongo/db/storage/record_store_test_updatewithdamages.cpp +++ b/src/mongo/db/storage/record_store_test_updatewithdamages.cpp @@ -52,7 +52,7 @@ TEST(RecordStoreTestHarness, UpdateWithDamages) { return; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -60,7 +60,7 @@ TEST(RecordStoreTestHarness, UpdateWithDamages) { RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); @@ -71,13 +71,13 @@ TEST(RecordStoreTestHarness, UpdateWithDamages) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } string modifiedData = "11101000"; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { mutablebson::DamageVector dv(3); dv[0].sourceOffset = 5; @@ -99,7 +99,7 @@ TEST(RecordStoreTestHarness, UpdateWithDamages) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(modifiedData, record.data()); @@ -117,7 +117,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEvents) { return; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -125,7 +125,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEvents) { RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); @@ -136,13 +136,13 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEvents) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } string modifiedData = "10100010"; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { mutablebson::DamageVector dv(2); dv[0].sourceOffset = 3; @@ -161,7 +161,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEvents) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(modifiedData, record.data()); @@ -180,7 +180,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed) { return; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -188,7 +188,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed) { RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); @@ -199,13 +199,13 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } string modifiedData = "10111010"; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { mutablebson::DamageVector dv(2); dv[0].sourceOffset = 0; @@ -224,7 +224,7 @@ TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(modifiedData, record.data()); @@ -241,7 +241,7 @@ TEST(RecordStoreTestHarness, UpdateWithNoDamages) { return; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } @@ -249,7 +249,7 @@ TEST(RecordStoreTestHarness, UpdateWithNoDamages) { RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); @@ -260,12 +260,12 @@ TEST(RecordStoreTestHarness, UpdateWithNoDamages) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { mutablebson::DamageVector dv; @@ -278,7 +278,7 @@ TEST(RecordStoreTestHarness, UpdateWithNoDamages) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { RecordData record = rs->dataFor(opCtx.get(), loc); ASSERT_EQUALS(data, record.data()); diff --git a/src/mongo/db/storage/record_store_test_validate.cpp b/src/mongo/db/storage/record_store_test_validate.cpp index f8d08afbef4..0654b43829c 100644 --- a/src/mongo/db/storage/record_store_test_validate.cpp +++ b/src/mongo/db/storage/record_store_test_validate.cpp @@ -49,12 +49,12 @@ TEST(RecordStoreTestHarness, ValidateEmpty) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { ValidateAdaptorSpy adaptor; ValidateResults results; @@ -72,12 +72,12 @@ TEST(RecordStoreTestHarness, ValidateEmptyAndScanData) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { ValidateAdaptorSpy adaptor; ValidateResults results; @@ -95,12 +95,12 @@ TEST(RecordStoreTestHarness, FullValidateEmptyAndScanData) { unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { ValidateAdaptorSpy adaptor; ValidateResults results; @@ -116,7 +116,7 @@ TEST(RecordStoreTestHarness, FullValidateEmptyAndScanData) { // returns an OK status. TEST_F(ValidateTest, ValidateNonEmpty) { { - unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); { ValidateAdaptorSpy adaptor; ValidateResults results; @@ -133,7 +133,7 @@ TEST_F(ValidateTest, ValidateNonEmpty) { // returns an OK status. TEST_F(ValidateTest, ValidateAndScanDataNonEmpty) { { - unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); { ValidateAdaptorSpy adaptor; ValidateResults results; @@ -150,7 +150,7 @@ TEST_F(ValidateTest, ValidateAndScanDataNonEmpty) { // returns an OK status. TEST_F(ValidateTest, FullValidateNonEmptyAndScanData) { { - unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); { ValidateAdaptorSpy adaptor(getInsertedRecords()); ValidateResults results; diff --git a/src/mongo/db/storage/record_store_test_validate.h b/src/mongo/db/storage/record_store_test_validate.h index 3ef5bcdd368..88e01d7bf2e 100644 --- a/src/mongo/db/storage/record_store_test_validate.h +++ b/src/mongo/db/storage/record_store_test_validate.h @@ -68,7 +68,7 @@ public: ValidateTest() : _harnessHelper(newHarnessHelper()), _rs(_harnessHelper->newNonCappedRecordStore()) {} - std::unique_ptr<OperationContext> newOperationContext() { + ServiceContext::UniqueOperationContext newOperationContext() { return _harnessHelper->newOperationContext(); } @@ -82,13 +82,13 @@ public: void setUp() { { - std::unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); ASSERT_EQUALS(0, _rs->numRecords(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - std::unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); { std::stringstream ss; ss << "record " << i; @@ -104,7 +104,7 @@ public: } { - std::unique_ptr<OperationContext> opCtx(newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(newOperationContext()); ASSERT_EQUALS(nToInsert, _rs->numRecords(opCtx.get())); } } diff --git a/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp b/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp index 754bed1d757..a12a589d259 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp @@ -43,12 +43,12 @@ TEST(SortedDataInterface, BuilderAddKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), true)); @@ -57,7 +57,7 @@ TEST(SortedDataInterface, BuilderAddKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -68,12 +68,12 @@ TEST(SortedDataInterface, BuilderAddCompoundKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), true)); @@ -82,7 +82,7 @@ TEST(SortedDataInterface, BuilderAddCompoundKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -95,12 +95,12 @@ TEST(SortedDataInterface, BuilderAddSameKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), false)); @@ -110,7 +110,7 @@ TEST(SortedDataInterface, BuilderAddSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -122,12 +122,12 @@ TEST(SortedDataInterface, BuilderAddSameKeyWithDupsAllowed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), true /* allow duplicates */)); @@ -137,7 +137,7 @@ TEST(SortedDataInterface, BuilderAddSameKeyWithDupsAllowed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } } @@ -148,12 +148,12 @@ TEST(SortedDataInterface, BuilderAddMultipleKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), true)); @@ -164,7 +164,7 @@ TEST(SortedDataInterface, BuilderAddMultipleKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } } @@ -175,12 +175,12 @@ TEST(SortedDataInterface, BuilderAddMultipleCompoundKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataBuilderInterface> builder( sorted->getBulkBuilder(opCtx.get(), true)); @@ -193,7 +193,7 @@ TEST(SortedDataInterface, BuilderAddMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } } diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp index b1ed07f8901..dcda494d541 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp @@ -43,12 +43,12 @@ TEST(SortedDataInterface, CursorIsEOFWhenEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(kMinBSONKey, true)); @@ -64,12 +64,12 @@ TEST(SortedDataInterface, CursorIsEOFWhenEmptyReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -87,13 +87,13 @@ TEST(SortedDataInterface, ExhaustCursor) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -104,12 +104,12 @@ TEST(SortedDataInterface, ExhaustCursor) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); for (int i = 0; i < nToInsert; i++) { auto entry = i == 0 ? cursor->seek(kMinBSONKey, true) : cursor->next(); @@ -129,13 +129,13 @@ TEST(SortedDataInterface, ExhaustCursorReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -146,12 +146,12 @@ TEST(SortedDataInterface, ExhaustCursorReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); for (int i = nToInsert - 1; i >= 0; i--) { diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp index d36e84a8a66..5a7dff46889 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp @@ -47,12 +47,12 @@ TEST(SortedDataInterface, AdvanceTo) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -65,12 +65,12 @@ TEST(SortedDataInterface, AdvanceTo) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -102,12 +102,12 @@ TEST(SortedDataInterface, AdvanceToReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -120,12 +120,12 @@ TEST(SortedDataInterface, AdvanceToReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -156,12 +156,12 @@ TEST(SortedDataInterface, AdvanceToKeyBeforeCursorPosition) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -171,12 +171,12 @@ TEST(SortedDataInterface, AdvanceToKeyBeforeCursorPosition) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -200,12 +200,12 @@ TEST(SortedDataInterface, AdvanceToKeyAfterCursorPositionReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -215,12 +215,12 @@ TEST(SortedDataInterface, AdvanceToKeyAfterCursorPositionReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -247,12 +247,12 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPosition) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -261,12 +261,12 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPosition) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -292,12 +292,12 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPositionReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -306,12 +306,12 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPositionReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -337,12 +337,12 @@ TEST(SortedDataInterface, AdvanceToExclusive) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -355,12 +355,12 @@ TEST(SortedDataInterface, AdvanceToExclusive) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -391,12 +391,12 @@ TEST(SortedDataInterface, AdvanceToExclusiveReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -409,12 +409,12 @@ TEST(SortedDataInterface, AdvanceToExclusiveReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -447,12 +447,12 @@ TEST(SortedDataInterface, AdvanceToIndirect) { BSONObj unusedKey = key6; // larger than any inserted key { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -463,12 +463,12 @@ TEST(SortedDataInterface, AdvanceToIndirect) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -497,12 +497,12 @@ TEST(SortedDataInterface, AdvanceToIndirectReversed) { BSONObj unusedKey = key0; // smaller than any inserted key { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -513,12 +513,12 @@ TEST(SortedDataInterface, AdvanceToIndirectReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -550,12 +550,12 @@ TEST(SortedDataInterface, AdvanceToIndirectExclusive) { BSONObj unusedKey = key6; // larger than any inserted key { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -566,12 +566,12 @@ TEST(SortedDataInterface, AdvanceToIndirectExclusive) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -607,12 +607,12 @@ TEST(SortedDataInterface, AdvanceToIndirectExclusiveReversed) { BSONObj unusedKey = key0; // smaller than any inserted key { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -623,12 +623,12 @@ TEST(SortedDataInterface, AdvanceToIndirectExclusiveReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp index 80e71b57da2..6d0f05c0cf2 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp @@ -44,13 +44,13 @@ TEST(SortedDataInterface, Locate) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(key1, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -59,7 +59,7 @@ TEST(SortedDataInterface, Locate) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -74,14 +74,14 @@ TEST(SortedDataInterface, LocateReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(key1, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -90,7 +90,7 @@ TEST(SortedDataInterface, LocateReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -106,13 +106,13 @@ TEST(SortedDataInterface, LocateCompoundKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(compoundKey1a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -121,7 +121,7 @@ TEST(SortedDataInterface, LocateCompoundKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(compoundKey1a, true), IndexKeyEntry(compoundKey1a, loc1)); @@ -136,14 +136,14 @@ TEST(SortedDataInterface, LocateCompoundKeyReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(compoundKey1a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -152,7 +152,7 @@ TEST(SortedDataInterface, LocateCompoundKeyReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -168,13 +168,13 @@ TEST(SortedDataInterface, LocateMultiple) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(key1, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -184,7 +184,7 @@ TEST(SortedDataInterface, LocateMultiple) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -193,7 +193,7 @@ TEST(SortedDataInterface, LocateMultiple) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -202,7 +202,7 @@ TEST(SortedDataInterface, LocateMultiple) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key2, true), IndexKeyEntry(key2, loc2)); @@ -223,14 +223,14 @@ TEST(SortedDataInterface, LocateMultipleReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(key3, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -240,7 +240,7 @@ TEST(SortedDataInterface, LocateMultipleReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -250,7 +250,7 @@ TEST(SortedDataInterface, LocateMultipleReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -259,7 +259,7 @@ TEST(SortedDataInterface, LocateMultipleReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -281,13 +281,13 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(compoundKey1a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -298,7 +298,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(compoundKey1a, true), IndexKeyEntry(compoundKey1a, loc1)); @@ -308,7 +308,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, true)); @@ -318,7 +318,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(compoundKey1a, true), IndexKeyEntry(compoundKey1a, loc1)); @@ -337,14 +337,14 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(compoundKey3a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -355,7 +355,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -366,7 +366,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, true)); @@ -376,7 +376,7 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -396,13 +396,13 @@ TEST(SortedDataInterface, LocateIndirect) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(key1, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -412,7 +412,7 @@ TEST(SortedDataInterface, LocateIndirect) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, false), IndexKeyEntry(key2, loc2)); @@ -420,7 +420,7 @@ TEST(SortedDataInterface, LocateIndirect) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -429,7 +429,7 @@ TEST(SortedDataInterface, LocateIndirect) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key1, true), IndexKeyEntry(key1, loc1)); @@ -446,14 +446,14 @@ TEST(SortedDataInterface, LocateIndirectReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(key3, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -463,7 +463,7 @@ TEST(SortedDataInterface, LocateIndirectReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -472,7 +472,7 @@ TEST(SortedDataInterface, LocateIndirectReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -481,7 +481,7 @@ TEST(SortedDataInterface, LocateIndirectReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -499,13 +499,13 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(compoundKey1a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -516,7 +516,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(compoundKey1a, false), IndexKeyEntry(compoundKey1b, loc2)); @@ -525,7 +525,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, true)); @@ -535,7 +535,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(compoundKey2a, true), IndexKeyEntry(compoundKey2b, loc3)); @@ -551,14 +551,14 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT(!cursor->seek(compoundKey3a, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -569,7 +569,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -579,7 +579,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, true)); @@ -589,7 +589,7 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); @@ -607,12 +607,12 @@ TEST(SortedDataInterface, LocateEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(BSONObj(), true)); @@ -627,12 +627,12 @@ TEST(SortedDataInterface, LocateEmptyReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp index 63c3bf6bc44..1e711d449e3 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp @@ -45,13 +45,13 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursor) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -62,12 +62,12 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursor) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); int i = 0; for (auto entry = cursor->seek(kMinBSONKey, true); entry; i++, entry = cursor->next()) { @@ -90,13 +90,13 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -107,12 +107,12 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); int i = nToInsert - 1; @@ -137,13 +137,13 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); RecordId loc(42, i * 2); @@ -153,12 +153,12 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); int i = 0; for (auto entry = cursor->seek(kMinBSONKey, true); entry; i++, entry = cursor->next()) { @@ -182,13 +182,13 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeysRev const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); RecordId loc(42, i * 2); @@ -198,12 +198,12 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeysRev } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); int i = nToInsert - 1; @@ -226,12 +226,12 @@ TEST(SortedDataInterface, SavePositionWithoutRestore) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -240,12 +240,12 @@ TEST(SortedDataInterface, SavePositionWithoutRestore) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); cursor->save(); } @@ -258,12 +258,12 @@ TEST(SortedDataInterface, SavePositionWithoutRestoreReversed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -272,12 +272,12 @@ TEST(SortedDataInterface, SavePositionWithoutRestoreReversed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); cursor->save(); diff --git a/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp b/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp index 1c069da9ebe..c52ff7cc644 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp @@ -45,12 +45,12 @@ TEST(SortedDataInterface, DupKeyCheckAfterInsert) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -59,12 +59,12 @@ TEST(SortedDataInterface, DupKeyCheckAfterInsert) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->dupKeyCheck(opCtx.get(), key1, loc1)); @@ -81,12 +81,12 @@ TEST(SortedDataInterface, DupKeyCheckEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->dupKeyCheck(opCtx.get(), key1, loc1)); @@ -102,12 +102,12 @@ TEST(SortedDataInterface, DupKeyCheckWhenDiskLocBefore) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -116,12 +116,12 @@ TEST(SortedDataInterface, DupKeyCheckWhenDiskLocBefore) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_NOT_OK(sorted->dupKeyCheck(opCtx.get(), key1, RecordId::min())); @@ -137,12 +137,12 @@ TEST(SortedDataInterface, DupKeyCheckWhenDiskLocAfter) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -151,12 +151,12 @@ TEST(SortedDataInterface, DupKeyCheckWhenDiskLocAfter) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_NOT_OK(sorted->dupKeyCheck(opCtx.get(), key1, RecordId::max())); diff --git a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp index 98bb9936da9..ce0a31fcc53 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp @@ -44,13 +44,13 @@ TEST(SortedDataInterface, FullValidate) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -61,13 +61,13 @@ TEST(SortedDataInterface, FullValidate) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } { long long numKeysOut; - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); sorted->fullValidate(opCtx.get(), &numKeysOut, NULL); // fullValidate() can set numKeysOut as the number of existing keys or -1. ASSERT(numKeysOut == nToInsert || numKeysOut == -1); diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp index 40ce99a6911..8e99d7d3461 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp @@ -72,7 +72,7 @@ TEST(SortedDataInterface, InsertWithDups1) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 2), true); @@ -81,7 +81,7 @@ TEST(SortedDataInterface, InsertWithDups1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(6, 2), true); @@ -90,7 +90,7 @@ TEST(SortedDataInterface, InsertWithDups1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); long long x = 0; @@ -104,7 +104,7 @@ TEST(SortedDataInterface, InsertWithDups2) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -113,7 +113,7 @@ TEST(SortedDataInterface, InsertWithDups2) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 20), true); @@ -122,7 +122,7 @@ TEST(SortedDataInterface, InsertWithDups2) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } } @@ -132,7 +132,7 @@ TEST(SortedDataInterface, InsertWithDups3AndRollback) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -141,7 +141,7 @@ TEST(SortedDataInterface, InsertWithDups3AndRollback) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 20), true); @@ -150,7 +150,7 @@ TEST(SortedDataInterface, InsertWithDups3AndRollback) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -160,7 +160,7 @@ TEST(SortedDataInterface, InsertNoDups1) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 18), false); @@ -169,7 +169,7 @@ TEST(SortedDataInterface, InsertNoDups1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 2), RecordId(5, 20), false); @@ -178,7 +178,7 @@ TEST(SortedDataInterface, InsertNoDups1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } } @@ -188,7 +188,7 @@ TEST(SortedDataInterface, InsertNoDups2) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 2), false); @@ -197,7 +197,7 @@ TEST(SortedDataInterface, InsertNoDups2) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 4), false); @@ -206,7 +206,7 @@ TEST(SortedDataInterface, InsertNoDups2) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -216,7 +216,7 @@ TEST(SortedDataInterface, Unindex1) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -225,12 +225,12 @@ TEST(SortedDataInterface, Unindex1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), BSON("" << 1), RecordId(5, 20), true); @@ -240,12 +240,12 @@ TEST(SortedDataInterface, Unindex1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), BSON("" << 2), RecordId(5, 18), true); @@ -255,13 +255,13 @@ TEST(SortedDataInterface, Unindex1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -271,7 +271,7 @@ TEST(SortedDataInterface, Unindex1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -281,7 +281,7 @@ TEST(SortedDataInterface, Unindex2Rollback) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -290,12 +290,12 @@ TEST(SortedDataInterface, Unindex2Rollback) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), BSON("" << 1), RecordId(5, 18), true); @@ -305,7 +305,7 @@ TEST(SortedDataInterface, Unindex2Rollback) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -317,7 +317,7 @@ TEST(SortedDataInterface, CursorIterate1) { int N = 5; for (int i = 0; i < N; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), BSON("" << i), RecordId(5, i * 2), true)); @@ -326,7 +326,7 @@ TEST(SortedDataInterface, CursorIterate1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); int n = 0; for (auto entry = cursor->seek(BSONObj(), true); entry; entry = cursor->next()) { @@ -343,7 +343,7 @@ TEST(SortedDataInterface, CursorIterate1WithSaveRestore) { int N = 5; for (int i = 0; i < N; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << i), RecordId(5, i * 2), true); @@ -352,7 +352,7 @@ TEST(SortedDataInterface, CursorIterate1WithSaveRestore) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); int n = 0; for (auto entry = cursor->seek(BSONObj(), true); entry; entry = cursor->next()) { @@ -372,7 +372,7 @@ TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) { int N = 5; for (int i = 0; i < N; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->insert(opCtx.get(), BSON("" << 5), RecordId(5, i * 2), true); @@ -381,7 +381,7 @@ TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); int n = 0; for (auto entry = cursor->seek(BSONObj(), true); entry; entry = cursor->next()) { @@ -403,13 +403,13 @@ TEST(SortedDataInterface, Locate1) { RecordId loc(5, 16); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT(!cursor->seek(key, true)); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); Status res = sorted->insert(opCtx.get(), key, loc, true); @@ -419,7 +419,7 @@ TEST(SortedDataInterface, Locate1) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(key, true), IndexKeyEntry(key, loc)); } @@ -430,7 +430,7 @@ TEST(SortedDataInterface, Locate2) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -442,7 +442,7 @@ TEST(SortedDataInterface, Locate2) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(BSON("a" << 2), true), IndexKeyEntry(BSON("" << 2), RecordId(1, 4))); @@ -456,7 +456,7 @@ TEST(SortedDataInterface, Locate2Empty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -468,13 +468,13 @@ TEST(SortedDataInterface, Locate2Empty) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get())); ASSERT_EQ(cursor->seek(BSONObj(), true), IndexKeyEntry(BSON("" << 1), RecordId(1, 2))); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false)); ASSERT_EQ(cursor->seek(BSONObj(), false), boost::none); @@ -489,7 +489,7 @@ TEST(SortedDataInterface, Locate3Descending) { auto buildEntry = [](int i) { return IndexKeyEntry(BSON("" << i), RecordId(1, i * 2)); }; { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); for (int i = 0; i < 10; i++) { if (i == 6) continue; @@ -500,7 +500,7 @@ TEST(SortedDataInterface, Locate3Descending) { } } - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); std::unique_ptr<SortedDataInterface::Cursor> cursor(sorted->newCursor(opCtx.get(), true)); ASSERT_EQ(cursor->seek(BSON("" << 5), true), buildEntry(5)); ASSERT_EQ(cursor->next(), buildEntry(7)); diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.h b/src/mongo/db/storage/sorted_data_interface_test_harness.h index ddc34c6419b..37e991221f8 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_harness.h +++ b/src/mongo/db/storage/sorted_data_interface_test_harness.h @@ -92,12 +92,14 @@ public: virtual std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) = 0; virtual std::unique_ptr<RecoveryUnit> newRecoveryUnit() = 0; - std::unique_ptr<OperationContext> newOperationContext(Client* client) { - return stdx::make_unique<OperationContextNoop>(client, 1, newRecoveryUnit().release()); + ServiceContext::UniqueOperationContext newOperationContext(Client* client) { + auto opCtx = client->makeOperationContext(); + opCtx->setRecoveryUnit(newRecoveryUnit().release(), OperationContext::kNotInUnitOfWork); + return opCtx; } - std::unique_ptr<OperationContext> newOperationContext() { - return newOperationContext(nullptr); + ServiceContext::UniqueOperationContext newOperationContext() { + return newOperationContext(_client.get()); } /** @@ -135,7 +137,8 @@ void insertToIndex(unowned_ptr<OperationContext> txn, inline void insertToIndex(unowned_ptr<HarnessHelper> harness, unowned_ptr<SortedDataInterface> index, std::initializer_list<IndexKeyEntry> toInsert) { - insertToIndex(harness->newOperationContext(), index, toInsert); + auto client = harness->serviceContext()->makeClient("insertToIndex"); + insertToIndex(harness->newOperationContext(client.get()), index, toInsert); } /** @@ -151,7 +154,8 @@ void removeFromIndex(unowned_ptr<OperationContext> txn, inline void removeFromIndex(unowned_ptr<HarnessHelper> harness, unowned_ptr<SortedDataInterface> index, std::initializer_list<IndexKeyEntry> toRemove) { - removeFromIndex(harness->newOperationContext(), index, toRemove); + auto client = harness->serviceContext()->makeClient("removeFromIndex"); + removeFromIndex(harness->newOperationContext(client.get()), index, toRemove); } std::unique_ptr<HarnessHelper> newHarnessHelper(); diff --git a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp index 71ec797cc17..5c10b1f6828 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp @@ -43,12 +43,12 @@ TEST(SortedDataInterface, Insert) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -57,7 +57,7 @@ TEST(SortedDataInterface, Insert) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -68,12 +68,12 @@ TEST(SortedDataInterface, InsertCompoundKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -82,7 +82,7 @@ TEST(SortedDataInterface, InsertCompoundKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -95,12 +95,12 @@ TEST(SortedDataInterface, InsertSameDiskLoc) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -110,12 +110,12 @@ TEST(SortedDataInterface, InsertSameDiskLoc) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc1, true)); @@ -124,7 +124,7 @@ TEST(SortedDataInterface, InsertSameDiskLoc) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } } @@ -137,12 +137,12 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -152,12 +152,12 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc1, true /* allow duplicates */)); @@ -166,7 +166,7 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } } @@ -178,12 +178,12 @@ TEST(SortedDataInterface, InsertSameKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -193,12 +193,12 @@ TEST(SortedDataInterface, InsertSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_NOT_OK(sorted->insert(opCtx.get(), key1, loc2, false)); @@ -207,7 +207,7 @@ TEST(SortedDataInterface, InsertSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } } @@ -225,12 +225,14 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) { harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx( + harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx( + harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, locs[0], false)); @@ -241,7 +243,8 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx( + harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); for (int i = 0; i < 3; i++) { @@ -254,7 +257,8 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx( + harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); const std::unique_ptr<SortedDataInterface::Cursor> cursor( @@ -283,12 +287,12 @@ TEST(SortedDataInterface, InsertMultiple) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -298,12 +302,12 @@ TEST(SortedDataInterface, InsertMultiple) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, false)); @@ -312,7 +316,7 @@ TEST(SortedDataInterface, InsertMultiple) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } } @@ -324,12 +328,12 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, false)); @@ -340,12 +344,12 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1c, loc4, false)); @@ -355,7 +359,7 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(5, sorted->numEntries(opCtx.get())); } } diff --git a/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp b/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp index 16ea19ca815..52a2b60b311 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp @@ -45,12 +45,12 @@ TEST(SortedDataInterface, IsEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -59,12 +59,12 @@ TEST(SortedDataInterface, IsEmpty) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(!sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, false); @@ -74,7 +74,7 @@ TEST(SortedDataInterface, IsEmpty) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } diff --git a/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp b/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp index c99627bf4d1..fe980b0f129 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp @@ -44,12 +44,12 @@ TEST(SortedDataInterface, InsertWithoutCommit) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -58,12 +58,12 @@ TEST(SortedDataInterface, InsertWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key2, loc1, false)); @@ -73,7 +73,7 @@ TEST(SortedDataInterface, InsertWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -86,12 +86,12 @@ TEST(SortedDataInterface, UnindexWithoutCommit) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -101,12 +101,12 @@ TEST(SortedDataInterface, UnindexWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key2, loc2, true); @@ -116,12 +116,12 @@ TEST(SortedDataInterface, UnindexWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -130,12 +130,12 @@ TEST(SortedDataInterface, UnindexWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, true); @@ -147,7 +147,7 @@ TEST(SortedDataInterface, UnindexWithoutCommit) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } } diff --git a/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp b/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp index 64171093fb2..70f44980c8d 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp @@ -43,14 +43,15 @@ TEST(SortedDataInterface, GetSpaceUsedBytesEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } // SERVER-15416 mmapv1 test harness does not use SimpleRecordStoreV1 as its record store // and HeapRecordStoreBtree::dataSize does not have an actual implementation // { - // const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); + // const ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext() + // ); // ASSERT( sorted->getSpaceUsedBytes( opCtx.get() ) == 0 ); // } } @@ -61,13 +62,13 @@ TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } int nToInsert = 10; for (int i = 0; i < nToInsert; i++) { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); BSONObj key = BSON("" << i); @@ -78,7 +79,7 @@ TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } @@ -86,7 +87,8 @@ TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) { // and HeapRecordStoreBtree::dataSize does not have an actual implementation // long long spaceUsedBytes; // { - // const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); + // const ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext() + // ); // spaceUsedBytes = sorted->getSpaceUsedBytes( opCtx.get() ); // ASSERT( spaceUsedBytes > 0 ); // } @@ -94,7 +96,8 @@ TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) { // { // // getSpaceUsedBytes() returns the same value when called multiple times // // and there were not interleaved write operations. - // const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); + // const ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext() + // ); // ASSERT_EQUALS( spaceUsedBytes, sorted->getSpaceUsedBytes( opCtx.get() ) ); // ASSERT_EQUALS( spaceUsedBytes, sorted->getSpaceUsedBytes( opCtx.get() ) ); // } diff --git a/src/mongo/db/storage/sorted_data_interface_test_touch.cpp b/src/mongo/db/storage/sorted_data_interface_test_touch.cpp index 07ec83fb9c7..a54fb010832 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_touch.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_touch.cpp @@ -43,7 +43,7 @@ TEST(SortedDataInterface, TouchEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); Status status = sorted->touch(opCtx.get()); ASSERT(status.isOK() || status.code() == ErrorCodes::CommandNotSupported); } @@ -55,12 +55,12 @@ TEST(SortedDataInterface, TouchNonEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, false)); @@ -71,12 +71,12 @@ TEST(SortedDataInterface, TouchNonEmpty) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(3, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); // XXX does not verify the index was brought into memory // (even if supported by storage engine) Status status = sorted->touch(opCtx.get()); diff --git a/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp b/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp index d1101a90d12..1e217651fc4 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp @@ -43,12 +43,12 @@ TEST(SortedDataInterface, Unindex) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -57,12 +57,12 @@ TEST(SortedDataInterface, Unindex) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, true); @@ -72,7 +72,7 @@ TEST(SortedDataInterface, Unindex) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -83,12 +83,12 @@ TEST(SortedDataInterface, UnindexCompoundKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), compoundKey1a, loc1, true)); @@ -97,12 +97,12 @@ TEST(SortedDataInterface, UnindexCompoundKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), compoundKey1a, loc1, true); @@ -112,7 +112,7 @@ TEST(SortedDataInterface, UnindexCompoundKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -123,12 +123,12 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -138,12 +138,12 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key2, loc2, true); @@ -153,12 +153,12 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key3, loc3, true)); @@ -167,12 +167,12 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, true); @@ -184,7 +184,7 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -195,12 +195,12 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true)); @@ -210,12 +210,12 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc2, true); @@ -225,12 +225,12 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(1, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); ASSERT_OK(sorted->insert(opCtx.get(), key1, loc3, true /* allow duplicates */)); @@ -239,12 +239,12 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, true); @@ -256,7 +256,7 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) { } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } } @@ -267,12 +267,12 @@ TEST(SortedDataInterface, UnindexEmpty) { const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT(sorted->isEmpty(opCtx.get())); } { - const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); sorted->unindex(opCtx.get(), key1, loc1, true); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp index 249dcacdc81..abbdc343d76 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp @@ -213,7 +213,7 @@ TEST(WiredTigerRecordStoreTest, Isolation1) { RecordId id2; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -230,8 +230,9 @@ TEST(WiredTigerRecordStoreTest, Isolation1) { } { - unique_ptr<OperationContext> t1(harnessHelper->newOperationContext()); - unique_ptr<OperationContext> t2(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext t1(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto t2 = harnessHelper->newOperationContext(client2.get()); unique_ptr<WriteUnitOfWork> w1(new WriteUnitOfWork(t1.get())); unique_ptr<WriteUnitOfWork> w2(new WriteUnitOfWork(t2.get())); @@ -263,7 +264,7 @@ TEST(WiredTigerRecordStoreTest, Isolation2) { RecordId id2; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); @@ -280,8 +281,9 @@ TEST(WiredTigerRecordStoreTest, Isolation2) { } { - unique_ptr<OperationContext> t1(harnessHelper->newOperationContext()); - unique_ptr<OperationContext> t2(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext t1(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto t2 = harnessHelper->newOperationContext(client2.get()); // ensure we start transactions rs->dataFor(t1.get(), id2); @@ -319,7 +321,7 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) { int N = 12; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); for (int i = 0; i < N; i++) { @@ -331,7 +333,7 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(N, rs->numRecords(opCtx.get())); } @@ -345,18 +347,18 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); rs.reset(new WiredTigerRecordStore( opCtx.get(), "a.b", uri, kWiredTigerEngineName, false, false, -1, -1, NULL, &ss)); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(N, rs->numRecords(opCtx.get())); } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WiredTigerRecoveryUnit* ru = checked_cast<WiredTigerRecoveryUnit*>(opCtx->recoveryUnit()); { @@ -370,7 +372,7 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WiredTigerSizeStorer ss2(harnessHelper->conn(), indexUri); ss2.fillCache(); long long numRecords; @@ -413,7 +415,7 @@ private: expectedNumRecords = 10000; expectedDataSize = expectedNumRecords * 2; { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WriteUnitOfWork uow(opCtx.get()); for (int i = 0; i < expectedNumRecords; i++) { ASSERT_OK(rs->insertRecord(opCtx.get(), "a", 2, false).getStatus()); @@ -460,7 +462,7 @@ protected: // Basic validation - size storer data is updated. TEST_F(SizeStorerValidateTest, Basic) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ValidateResults results; BSONObjBuilder output; ASSERT_OK(rs->validate(opCtx.get(), kValidateIndex, NULL, &results, &output)); @@ -472,7 +474,7 @@ TEST_F(SizeStorerValidateTest, Basic) { // Full validation - size storer data is updated. TEST_F(SizeStorerValidateTest, FullWithGoodAdaptor) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); GoodValidateAdaptor adaptor; ValidateResults results; BSONObjBuilder output; @@ -486,7 +488,7 @@ TEST_F(SizeStorerValidateTest, FullWithGoodAdaptor) { // Basic validation does not use the validation adaptor. So passing a bad adaptor // should not cause validate to fail. TEST_F(SizeStorerValidateTest, BasicWithBadAdapter) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); BadValidateAdaptor adaptor; ValidateResults results; BSONObjBuilder output; @@ -496,7 +498,7 @@ TEST_F(SizeStorerValidateTest, BasicWithBadAdapter) { // Full validation with a validation adaptor that fails - size storer data is not updated. TEST_F(SizeStorerValidateTest, FullWithBadAdapter) { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); BadValidateAdaptor adaptor; ValidateResults results; BSONObjBuilder output; @@ -511,7 +513,7 @@ TEST_F(SizeStorerValidateTest, FullWithBadAdapter) { TEST_F(SizeStorerValidateTest, InvalidSizeStorerAtCreation) { rs.reset(NULL); - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); sizeStorer->storeToCache(uri, expectedNumRecords * 2, expectedDataSize * 2); rs.reset(new WiredTigerRecordStore(opCtx.get(), "a.b", @@ -543,7 +545,7 @@ TEST_F(SizeStorerValidateTest, InvalidSizeStorerAtCreation) { } // namespace -StatusWith<RecordId> insertBSON(unique_ptr<OperationContext>& opCtx, +StatusWith<RecordId> insertBSON(ServiceContext::UniqueOperationContext& opCtx, unique_ptr<RecordStore>& rs, const Timestamp& opTime) { BSONObj obj = BSON("ts" << opTime); @@ -568,7 +570,7 @@ TEST(WiredTigerRecordStoreTest, OplogHack) { unique_ptr<RecordStore> rs( harnessHelper.newCappedRecordStore("local.oplog.foo", cappedMaxSize, -1)); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); // always illegal ASSERT_EQ(insertBSON(opCtx, rs, Timestamp(2, -1)).getStatus(), ErrorCodes::BadValue); @@ -599,7 +601,7 @@ TEST(WiredTigerRecordStoreTest, OplogHack) { } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); // find start ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(0, 1)), RecordId()); // nothing <= ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(2, 1)), RecordId(1, 2)); // between @@ -608,44 +610,44 @@ TEST(WiredTigerRecordStoreTest, OplogHack) { } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(2, 2), false); // no-op } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(2, 3)), RecordId(2, 2)); } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 2), false); // deletes 2,2 } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(2, 3)), RecordId(1, 2)); } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 2), true); // deletes 1,2 } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(2, 3)), RecordId(1, 1)); } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); WriteUnitOfWork wuow(opCtx.get()); ASSERT_OK(rs->truncate(opCtx.get())); // deletes 1,1 and leaves collection empty wuow.commit(); } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(rs->oplogStartHack(opCtx.get(), RecordId(2, 3)), RecordId()); } } @@ -654,7 +656,7 @@ TEST(WiredTigerRecordStoreTest, OplogHackOnNonOplog) { WiredTigerHarnessHelper harnessHelper; unique_ptr<RecordStore> rs(harnessHelper.newNonCappedRecordStore("local.NOT_oplog.foo")); - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); BSONObj obj = BSON("ts" << Timestamp(2, -1)); { @@ -672,7 +674,7 @@ TEST(WiredTigerRecordStoreTest, CappedOrder) { RecordId id1; { // first insert a document - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "a", 2, false); @@ -683,7 +685,7 @@ TEST(WiredTigerRecordStoreTest, CappedOrder) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -693,13 +695,14 @@ TEST(WiredTigerRecordStoreTest, CappedOrder) { { // now we insert 2 docs, but commit the 2nd one fiirst // we make sure we can't find the 2nd until the first is commited - unique_ptr<OperationContext> t1(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext t1(harnessHelper->newOperationContext()); unique_ptr<WriteUnitOfWork> w1(new WriteUnitOfWork(t1.get())); rs->insertRecord(t1.get(), "b", 2, false); // do not commit yet { // create 2nd doc - unique_ptr<OperationContext> t2(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto t2 = harnessHelper->newOperationContext(client2.get()); { WriteUnitOfWork w2(t2.get()); rs->insertRecord(t2.get(), "c", 2, false); @@ -708,7 +711,8 @@ TEST(WiredTigerRecordStoreTest, CappedOrder) { } { // state should be the same - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto opCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -719,7 +723,8 @@ TEST(WiredTigerRecordStoreTest, CappedOrder) { } { // now all 3 docs should be visible - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto opCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -734,7 +739,7 @@ TEST(WiredTigerRecordStoreTest, CappedCursorRollover) { unique_ptr<RecordStore> rs(harnessHelper->newCappedRecordStore("a.b", 10000, 5)); { // first insert 3 documents - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); for (int i = 0; i < 3; ++i) { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "a", 2, false); @@ -744,14 +749,17 @@ TEST(WiredTigerRecordStoreTest, CappedCursorRollover) { } // set up our cursor that should rollover - unique_ptr<OperationContext> cursorCtx(harnessHelper->newOperationContext()); + + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto cursorCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(cursorCtx.get()); ASSERT(cursor->next()); cursor->save(); cursorCtx->recoveryUnit()->abandonSnapshot(); { // insert 100 documents which causes rollover - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client3 = harnessHelper->serviceContext()->makeClient("c3"); + auto opCtx = harnessHelper->newOperationContext(client3.get()); for (int i = 0; i < 100; i++) { WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "a", 2, false); @@ -789,7 +797,7 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { RecordId id1; { // first insert a document - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); id1 = _oplogOrderInsertOplog(opCtx.get(), rs, 1); @@ -798,7 +806,7 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { } { - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -808,19 +816,21 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { { // now we insert 2 docs, but commit the 2nd one first. // we make sure we can't find the 2nd until the first is commited. - unique_ptr<OperationContext> earlyReader(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext earlyReader(harnessHelper->newOperationContext()); auto earlyCursor = rs->getCursor(earlyReader.get()); ASSERT_EQ(earlyCursor->seekExact(id1)->id, id1); earlyCursor->save(); earlyReader->recoveryUnit()->abandonSnapshot(); - unique_ptr<OperationContext> t1(harnessHelper->newOperationContext()); + auto client1 = harnessHelper->serviceContext()->makeClient("c1"); + auto t1 = harnessHelper->newOperationContext(client1.get()); WriteUnitOfWork w1(t1.get()); _oplogOrderInsertOplog(t1.get(), rs, 20); // do not commit yet { // create 2nd doc - unique_ptr<OperationContext> t2(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto t2 = harnessHelper->newOperationContext(client2.get()); { WriteUnitOfWork w2(t2.get()); _oplogOrderInsertOplog(t2.get(), rs, 30); @@ -832,7 +842,8 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { earlyCursor->restore(); ASSERT(!earlyCursor->next()); - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto opCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -843,7 +854,8 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { } { // now all 3 docs should be visible - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto opCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -855,26 +867,29 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { // Rollback the last two oplog entries, then insert entries with older optimes and ensure that // the visibility rules aren't violated. See SERVER-21645 { - unique_ptr<OperationContext> txn(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto txn = harnessHelper->newOperationContext(client2.get()); rs->temp_cappedTruncateAfter(txn.get(), id1, /*inclusive*/ false); } { // Now we insert 2 docs with timestamps earlier than before, but commit the 2nd one first. // We make sure we can't find the 2nd until the first is commited. - unique_ptr<OperationContext> earlyReader(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext earlyReader(harnessHelper->newOperationContext()); auto earlyCursor = rs->getCursor(earlyReader.get()); ASSERT_EQ(earlyCursor->seekExact(id1)->id, id1); earlyCursor->save(); earlyReader->recoveryUnit()->abandonSnapshot(); - unique_ptr<OperationContext> t1(harnessHelper->newOperationContext()); + auto client1 = harnessHelper->serviceContext()->makeClient("c1"); + auto t1 = harnessHelper->newOperationContext(client1.get()); WriteUnitOfWork w1(t1.get()); _oplogOrderInsertOplog(t1.get(), rs, 2); // do not commit yet { // create 2nd doc - unique_ptr<OperationContext> t2(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto t2 = harnessHelper->newOperationContext(client2.get()); { WriteUnitOfWork w2(t2.get()); _oplogOrderInsertOplog(t2.get(), rs, 3); @@ -886,7 +901,8 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { ASSERT(earlyCursor->restore()); ASSERT(!earlyCursor->next()); - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + auto client2 = harnessHelper->serviceContext()->makeClient("c2"); + auto opCtx = harnessHelper->newOperationContext(client2.get()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -897,7 +913,7 @@ TEST(WiredTigerRecordStoreTest, OplogOrder) { } { // now all 3 docs should be visible - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(opCtx.get()); auto record = cursor->seekExact(id1); ASSERT_EQ(id1, record->id); @@ -911,7 +927,7 @@ TEST(WiredTigerRecordStoreTest, StorageSizeStatisticsDisabled) { WiredTigerHarnessHelper harnessHelper("statistics=(none)"); unique_ptr<RecordStore> rs(harnessHelper.newNonCappedRecordStore("a.b")); - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_THROWS(rs->storageSize(opCtx.get()), UserException); } @@ -919,7 +935,7 @@ TEST(WiredTigerRecordStoreTest, AppendCustomStatsMetadata) { WiredTigerHarnessHelper harnessHelper; unique_ptr<RecordStore> rs(harnessHelper.newNonCappedRecordStore("a.b")); - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); BSONObjBuilder builder; rs->appendCustomStats(opCtx.get(), &builder, 1.0); BSONObj customStats = builder.obj(); @@ -946,7 +962,7 @@ TEST(WiredTigerRecordStoreTest, CappedCursorYieldFirst) { RecordId id1; { // first insert a document - unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); WriteUnitOfWork uow(opCtx.get()); StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), "a", 2, false); ASSERT_OK(res.getStatus()); @@ -954,7 +970,7 @@ TEST(WiredTigerRecordStoreTest, CappedCursorYieldFirst) { uow.commit(); } - unique_ptr<OperationContext> cursorCtx(harnessHelper->newOperationContext()); + ServiceContext::UniqueOperationContext cursorCtx(harnessHelper->newOperationContext()); auto cursor = rs->getCursor(cursorCtx.get()); // See that things work if you yield before you first call next(). @@ -1013,7 +1029,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CreateNewStone) { oplogStones->setMinBytesPerStone(100); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(0U, oplogStones->numStones()); @@ -1071,7 +1087,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_UpdateRecord) { // Insert two records such that one makes up a full stone and the other is a part of the stone // currently being filled. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 1), 100), RecordId(1, 1)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 2), 50), RecordId(1, 2)); @@ -1083,7 +1099,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_UpdateRecord) { // Attempts to grow the records should fail. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); BSONObj changed1 = makeBSONObjWithSize(Timestamp(1, 1), 101); BSONObj changed2 = makeBSONObjWithSize(Timestamp(1, 2), 51); @@ -1097,7 +1113,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_UpdateRecord) { // Attempts to shrink the records should also fail. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); BSONObj changed1 = makeBSONObjWithSize(Timestamp(1, 1), 99); BSONObj changed2 = makeBSONObjWithSize(Timestamp(1, 2), 49); @@ -1111,7 +1127,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_UpdateRecord) { // Changing the contents of the records without changing their size should succeed. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); BSONObj changed1 = makeBSONObjWithSize(Timestamp(1, 1), 100, 'y'); BSONObj changed2 = makeBSONObjWithSize(Timestamp(1, 2), 50, 'z'); @@ -1144,7 +1160,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_Truncate) { oplogStones->setMinBytesPerStone(100); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 1), 50), RecordId(1, 1)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 2), 50), RecordId(1, 2)); @@ -1156,7 +1172,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_Truncate) { } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(3, rs->numRecords(opCtx.get())); ASSERT_EQ(150, rs->dataSize(opCtx.get())); @@ -1189,7 +1205,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { oplogStones->setMinBytesPerStone(1000); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 1), 400), RecordId(1, 1)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 2), 800), RecordId(1, 2)); @@ -1213,7 +1229,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { // Truncate data using an inclusive RecordId that exists inside the stone currently being // filled. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 8), true); @@ -1227,7 +1243,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { // Truncate data using an inclusive RecordId that refers to the 'lastRecord' of a full stone. // The stone should become the one currently being filled. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 6), true); @@ -1241,7 +1257,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { // Truncate data using a non-inclusive RecordId that exists inside the stone currently being // filled. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 3), false); @@ -1255,7 +1271,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { // Truncate data using a non-inclusive RecordId that refers to the 'lastRecord' of a full stone. // The stone should remain intact. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 2), false); @@ -1269,7 +1285,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_CappedTruncateAfter) { // Truncate data using a non-inclusive RecordId that exists inside a full stone. The stone // should become the one currently being filled. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); rs->temp_cappedTruncateAfter(opCtx.get(), RecordId(1, 1), false); @@ -1296,7 +1312,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ReclaimStones) { oplogStones->setNumStonesToKeep(2U); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 1), 100), RecordId(1, 1)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 2), 110), RecordId(1, 2)); @@ -1311,7 +1327,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ReclaimStones) { // Truncate a stone when number of stones to keep is exceeded. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); wtrs->reclaimOplog(opCtx.get()); @@ -1323,7 +1339,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ReclaimStones) { } { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 4), 130), RecordId(1, 4)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 5), 140), RecordId(1, 5)); @@ -1338,7 +1354,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ReclaimStones) { // Truncate multiple stones if necessary. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); wtrs->reclaimOplog(opCtx.get()); @@ -1351,7 +1367,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ReclaimStones) { // No-op if the number of oplog stones is less than or equal to the number of stones to keep. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); wtrs->reclaimOplog(opCtx.get()); @@ -1379,7 +1395,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ExceedCappedMaxSize) { oplogStones->setNumStonesToKeep(10U); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 1), 100), RecordId(1, 1)); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(1, 2), 110), RecordId(1, 2)); @@ -1395,7 +1411,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_ExceedCappedMaxSize) { // Shouldn't truncate a stone when the number of oplog stones is less than the number of stones // to keep, even though the size of the record store exceeds 'cappedMaxSize'. { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); wtrs->reclaimOplog(opCtx.get()); @@ -1422,7 +1438,7 @@ TEST(WiredTigerRecordStoreTest, OplogStones_AscendingOrder) { oplogStones->setMinBytesPerStone(100); { - unique_ptr<OperationContext> opCtx(harnessHelper.newOperationContext()); + ServiceContext::UniqueOperationContext opCtx(harnessHelper.newOperationContext()); ASSERT_EQ(0U, oplogStones->numStones()); ASSERT_EQ(insertBSONWithSize(opCtx.get(), rs.get(), Timestamp(2, 2), 50), RecordId(2, 2)); |