diff options
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/SConscript | 47 | ||||
-rw-r--r-- | src/mongo/db/repl/collection_bulk_loader_impl.cpp | 34 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_test.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_test_fixture.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_test_fixture.h | 29 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_impl_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_test_fixture.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_test_fixture.h | 14 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback_test.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/repl/service_context_repl_mock.cpp | 47 | ||||
-rw-r--r-- | src/mongo/db/repl/service_context_repl_mock.h | 46 | ||||
-rw-r--r-- | src/mongo/db/repl/service_context_repl_mock_init.cpp | 49 | ||||
-rw-r--r-- | src/mongo/db/repl/task_runner_test_fixture.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/task_runner_test_fixture.h | 4 |
14 files changed, 28 insertions, 306 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 187aa7f366c..ac1d6cb6f04 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -796,7 +796,6 @@ env.CppUnitTest( 'topology_coordinator', 'replica_set_messages', '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/executor/network_interface_factory', '$BUILD_DIR/mongo/executor/network_interface_mock', '$BUILD_DIR/mongo/executor/network_interface_thread_pool', @@ -852,10 +851,10 @@ env.Library( LIBDEPS=[ 'repl_coordinator_impl', 'replmocks', - 'service_context_repl_mock_init', 'topology_coordinator', '$BUILD_DIR/mongo/db/auth/authorization_manager_global', '$BUILD_DIR/mongo/db/auth/authmocks', + '$BUILD_DIR/mongo/db/service_context_d_test_fixture', '$BUILD_DIR/mongo/executor/network_interface_mock', '$BUILD_DIR/mongo/executor/network_interface_factory', '$BUILD_DIR/mongo/executor/network_interface_thread_pool', @@ -863,6 +862,10 @@ env.Library( '$BUILD_DIR/mongo/unittest/unittest', ], + LIBDEPS_PRIVATE=[ + '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/storage_ephemeral_for_test', + '$BUILD_DIR/mongo/db/storage/storage_engine_common', + ], ) env.CppUnitTest( @@ -885,7 +888,6 @@ env.CppUnitTest( 'repl_coordinator_impl', 'replmocks', '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', ], ) @@ -908,7 +910,6 @@ env.CppUnitTest( LIBDEPS=[ 'repl_coordinator_impl', 'replmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', ], @@ -923,7 +924,6 @@ env.CppUnitTest( 'repl_coordinator_impl', 'replica_set_messages', 'replmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', ], @@ -939,7 +939,6 @@ env.CppUnitTest( 'replica_set_messages', 'replmocks', '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', ], ) @@ -953,7 +952,6 @@ env.CppUnitTest( 'repl_coordinator_impl', 'replica_set_messages', 'replmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', ], @@ -992,7 +990,6 @@ env.Library( 'replication_consistency_markers_mock.cpp', 'replication_coordinator_external_state_mock.cpp', 'replication_coordinator_mock.cpp', - 'service_context_repl_mock.cpp', 'storage_interface_mock.cpp', ], LIBDEPS=[ @@ -1007,17 +1004,6 @@ env.Library( ], ) -env.Library( - target='service_context_repl_mock_init', - source=[ - 'service_context_repl_mock_init.cpp', - ], - LIBDEPS=[ - 'replmocks', - '$BUILD_DIR/mongo/util/clock_source_mock', - ], -) - env.Library('read_concern_args', [ 'read_concern_args.cpp' @@ -1186,7 +1172,6 @@ env.CppUnitTest( source='oplog_fetcher_test.cpp', LIBDEPS=[ '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', 'oplog_fetcher', 'data_replicator_external_state_mock', 'abstract_oplog_fetcher_test_fixture', @@ -1215,7 +1200,6 @@ env.CppUnitTest( 'reporter', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/unittest/task_executor_proxy', ], ) @@ -1300,7 +1284,6 @@ env.CppUnitTest( 'base_cloner_test_fixture', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/db/auth/authorization_manager_global', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/unittest/task_executor_proxy', ], ) @@ -1327,7 +1310,6 @@ env.CppUnitTest( 'base_cloner_test_fixture', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/db/commands/list_collections_filter', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/unittest/task_executor_proxy', ], ) @@ -1351,7 +1333,6 @@ env.CppUnitTest( 'oplog_entry', 'replmocks', '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/service_context_noop_init', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', '$BUILD_DIR/mongo/unittest/task_executor_proxy', ], @@ -1368,32 +1349,24 @@ env.Library( ], ) -env.Library( - target='task_runner_test_fixture', +env.CppUnitTest( + target='task_runner_test', source=[ + 'task_runner_test.cpp', 'task_runner_test_fixture.cpp', ], LIBDEPS=[ 'replmocks', - 'service_context_repl_mock_init', 'task_runner', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/db/auth/authorization_manager_global', - '$BUILD_DIR/mongo/db/service_context', + '$BUILD_DIR/mongo/db/service_context_test_fixture', '$BUILD_DIR/mongo/unittest/concurrency', '$BUILD_DIR/mongo/unittest/unittest', ], ) env.CppUnitTest( - target='task_runner_test', - source='task_runner_test.cpp', - LIBDEPS=[ - 'task_runner_test_fixture', - ], -) - -env.CppUnitTest( target='read_concern_args_test', source=[ 'read_concern_args_test.cpp', @@ -1442,7 +1415,6 @@ env.CppUnitTest( source='multiapplier_test.cpp', LIBDEPS=[ 'multiapplier', - 'service_context_repl_mock_init', '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture', '$BUILD_DIR/mongo/unittest/task_executor_proxy', @@ -1533,7 +1505,6 @@ env.CppUnitTest( 'initial_syncer', 'replication_process', 'replmocks', - 'service_context_repl_mock_init', 'sync_source_selector_mock', 'task_executor_mock', ], diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp index a8b432e7a7f..b0ccc6dfcc9 100644 --- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp +++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp @@ -51,40 +51,6 @@ namespace mongo { namespace repl { -namespace { - -/** - * Utility class to temporarily swap which client is bound to the running thread. - * - * Use this class to bind a client to the current thread for the duration of the - * AlternativeClientRegion's lifetime, restoring the prior client, if any, at the - * end of the block. - */ -class AlternativeClientRegion { -public: - explicit AlternativeClientRegion(ServiceContext::UniqueClient& clientToUse) - : _alternateClient(&clientToUse) { - invariant(clientToUse); - if (Client::getCurrent()) { - _originalClient = Client::releaseCurrent(); - } - Client::setCurrent(std::move(*_alternateClient)); - } - - ~AlternativeClientRegion() { - *_alternateClient = Client::releaseCurrent(); - if (_originalClient) { - Client::setCurrent(std::move(_originalClient)); - } - } - -private: - ServiceContext::UniqueClient _originalClient; - ServiceContext::UniqueClient* const _alternateClient; -}; - -} // namespace - CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(ServiceContext::UniqueClient&& client, ServiceContext::UniqueOperationContext&& opCtx, std::unique_ptr<AutoGetCollection>&& autoColl, diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index a3f3c3e2669..d009a9914fc 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -56,7 +56,7 @@ #include "mongo/db/repl/topology_coordinator.h" #include "mongo/db/repl/update_position_args.h" #include "mongo/db/server_options.h" -#include "mongo/db/service_context_noop.h" +#include "mongo/db/service_context.h" #include "mongo/db/write_concern_options.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/rpc/metadata/oplog_query_metadata.h" @@ -828,10 +828,6 @@ TEST_F(ReplCoordTest, NodeReturnsWriteConcernFailedUntilASufficientNumberOfNodes TEST_F(ReplCoordTest, NodeReturnsUnknownReplWriteConcernWhenAwaitReplicationReceivesAnInvalidWriteConcernMode) { - auto service = stdx::make_unique<ServiceContextNoop>(); - auto client = service->makeClient("test"); - auto opCtx = client->makeOperationContext(); - assertStartSuccess(BSON("_id" << "mySet" << "version" @@ -861,6 +857,7 @@ TEST_F(ReplCoordTest, invalidWriteConcern.wTimeout = WriteConcernOptions::kNoWaiting; invalidWriteConcern.wMode = "fakemode"; + auto opCtx = makeOperationContext(); ReplicationCoordinator::StatusAndDuration statusAndDur = getReplCoord()->awaitReplication(opCtx.get(), time1, invalidWriteConcern); ASSERT_EQUALS(ErrorCodes::UnknownReplWriteConcern, statusAndDur.status); @@ -869,10 +866,6 @@ TEST_F(ReplCoordTest, TEST_F( ReplCoordTest, NodeReturnsWriteConcernFailedUntilASufficientSetOfNodesHaveTheWriteAndTheWriteIsInACommittedSnapshot) { - auto service = stdx::make_unique<ServiceContextNoop>(); - auto client = service->makeClient("test"); - auto opCtx = client->makeOperationContext(); - assertStartSuccess( BSON("_id" << "mySet" @@ -940,7 +933,7 @@ TEST_F( multiRackWriteConcern.wTimeout = WriteConcernOptions::kNoWaiting; multiRackWriteConcern.wMode = "multiDCAndRack"; - + auto opCtx = makeOperationContext(); // Nothing satisfied getReplCoord()->setMyLastAppliedOpTime(time1); getReplCoord()->setMyLastDurableOpTime(time1); diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp index db81b8e46d8..7b2defbe0ad 100644 --- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp +++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp @@ -45,6 +45,8 @@ #include "mongo/db/repl/replication_recovery_mock.h" #include "mongo/db/repl/storage_interface_mock.h" #include "mongo/db/repl/topology_coordinator.h" +#include "mongo/db/storage/storage_engine_init.h" +#include "mongo/db/storage/storage_options.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/executor/thread_pool_mock.h" #include "mongo/executor/thread_pool_task_executor.h" @@ -79,12 +81,11 @@ BSONObj ReplCoordTest::addProtocolVersion(const BSONObj& configDoc, int protocol return builder.obj(); } - -void ReplCoordTest::setUp() { +ReplCoordTest::ReplCoordTest() { _settings.setReplSetString("mySet/node1:12345,node2:54321"); } -void ReplCoordTest::tearDown() { +ReplCoordTest::~ReplCoordTest() { getGlobalFailPointRegistry() ->getFailPoint("blockHeartbeatReconfigFinish") ->setMode(FailPoint::off); diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.h b/src/mongo/db/repl/replication_coordinator_test_fixture.h index 67f30ceeff9..3f0cb66f838 100644 --- a/src/mongo/db/repl/replication_coordinator_test_fixture.h +++ b/src/mongo/db/repl/replication_coordinator_test_fixture.h @@ -33,6 +33,7 @@ #include "mongo/db/client.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/repl/replication_coordinator.h" +#include "mongo/db/service_context_d_test_fixture.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/executor/task_executor.h" #include "mongo/unittest/unittest.h" @@ -55,7 +56,7 @@ using executor::NetworkInterfaceMock; /** * Fixture for testing ReplicationCoordinatorImpl behaviors. */ -class ReplCoordTest : public mongo::unittest::Test { +class ReplCoordTest : public ServiceContextMongoDTest { public: /** * Makes a command response with the given "doc" response and optional elapsed time "millis". @@ -81,8 +82,8 @@ public: static BSONObj addProtocolVersion(const BSONObj& configDoc, int protocolVersion); protected: - virtual void setUp(); - virtual void tearDown(); + ReplCoordTest(); + virtual ~ReplCoordTest(); /** * Asserts that calling start(configDoc, selfHost) successfully initiates the @@ -131,27 +132,6 @@ protected: } /** - * Makes a new OperationContext on the default Client for this test. - */ - ServiceContext::UniqueOperationContext makeOperationContext() { - return _client->makeOperationContext(); - } - - /** - * Returns the ServiceContext for this test. - */ - ServiceContext* getServiceContext() { - return getGlobalServiceContext(); - } - - /** - * Returns the default Client for this test. - */ - Client* getClient() { - return _client.get(); - } - - /** * Adds "selfHost" to the list of hosts that identify as "this" host. */ void addSelf(const HostAndPort& selfHost); @@ -298,7 +278,6 @@ private: ReplSettings _settings; bool _callShutdown = false; - ServiceContext::UniqueClient _client = getGlobalServiceContext()->makeClient("testClient"); }; } // namespace repl diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp index 427ff7688a4..8561743e303 100644 --- a/src/mongo/db/repl/rollback_impl_test.cpp +++ b/src/mongo/db/repl/rollback_impl_test.cpp @@ -419,7 +419,7 @@ void _assertDocsInOplog(OperationContext* opCtx, std::vector<int> timestamps) { } TEST_F(RollbackImplTest, TestFixtureSetUpInitializesStorageEngine) { - auto serviceContext = _serviceContextMongoDTest.getServiceContext(); + auto serviceContext = getServiceContext(); ASSERT_TRUE(serviceContext); ASSERT_TRUE(serviceContext->getStorageEngine()); } diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp index b0d49b1473a..db6b01e3d02 100644 --- a/src/mongo/db/repl/rollback_test_fixture.cpp +++ b/src/mongo/db/repl/rollback_test_fixture.cpp @@ -68,9 +68,8 @@ ReplSettings createReplSettings() { } // namespace void RollbackTest::setUp() { - _serviceContextMongoDTest.setUp(); _storageInterface = new StorageInterfaceRollback(); - auto serviceContext = _serviceContextMongoDTest.getServiceContext(); + auto serviceContext = getServiceContext(); auto consistencyMarkers = stdx::make_unique<ReplicationConsistencyMarkersMock>(); auto recovery = stdx::make_unique<ReplicationRecoveryImpl>(_storageInterface, consistencyMarkers.get()); @@ -85,7 +84,7 @@ void RollbackTest::setUp() { std::unique_ptr<ReplicationCoordinator>(_coordinator)); setOplogCollectionName(serviceContext); - _opCtx = cc().makeOperationContext(); + _opCtx = makeOperationContext(); _replicationProcess->getConsistencyMarkers()->clearAppliedThrough(_opCtx.get(), {}); _replicationProcess->getConsistencyMarkers()->setMinValid(_opCtx.get(), OpTime{}); _replicationProcess->initializeRollbackID(_opCtx.get()).transitional_ignore(); @@ -95,24 +94,6 @@ void RollbackTest::setUp() { logger::LogComponent::kReplicationRollback, logger::LogSeverity::Debug(2)); } -void RollbackTest::tearDown() { - _coordinator = nullptr; - _opCtx.reset(); - - SessionCatalog::get(_serviceContextMongoDTest.getServiceContext())->reset_forTest(); - - // We cannot unset the global replication coordinator because ServiceContextMongoD::tearDown() - // calls Databse::dropAllDatabasesExceptLocal() which requires the replication coordinator to - // clear all snapshots. - _serviceContextMongoDTest.tearDown(); - - // ServiceContextMongoD::tearDown() does not destroy service context so it is okay - // to access the service context after tearDown(). - auto serviceContext = _serviceContextMongoDTest.getServiceContext(); - _replicationProcess.reset(); - ReplicationCoordinator::set(serviceContext, {}); -} - RollbackTest::ReplicationCoordinatorRollbackMock::ReplicationCoordinatorRollbackMock( ServiceContext* service) : ReplicationCoordinatorMock(service, createReplSettings()) {} diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h index 4f43fb47945..8d31c63564f 100644 --- a/src/mongo/db/repl/rollback_test_fixture.h +++ b/src/mongo/db/repl/rollback_test_fixture.h @@ -49,7 +49,7 @@ namespace repl { * storage layer. The storage engine is initialized as part of the ServiceContextForMongoD test * fixture. */ -class RollbackTest : public unittest::Test { +class RollbackTest : public ServiceContextMongoDTest { public: RollbackTest() = default; @@ -59,15 +59,6 @@ public: void setUp() override; /** - * Destroys the service context and task executor. - * - * Note on overriding tearDown() in tests: - * This cancels outstanding tasks and remote command requests scheduled using the task - * executor. - */ - void tearDown() override; - - /** * Creates a collection with the given namespace and options. */ static Collection* _createCollection(OperationContext* opCtx, @@ -101,9 +92,6 @@ public: Timestamp ts, OptionalCollectionUUID uuid, StringData nss, BSONObj cmdObj, int recordId); protected: - // Test fixture used to manage the service context and global storage engine. - ServiceContextMongoDTest _serviceContextMongoDTest; - // OperationContext provided to test cases for storage layer operations. ServiceContext::UniqueOperationContext _opCtx; diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 4573e277d83..8b254a65988 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -69,23 +69,8 @@ using namespace mongo::repl::rollback_internal; const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2; -class RSRollbackTest : public RollbackTest { -private: - void setUp() override; - void tearDown() override; -}; - -void RSRollbackTest::setUp() { - RollbackTest::setUp(); - auto observerRegistry = stdx::make_unique<OpObserverRegistry>(); - observerRegistry->addObserver(stdx::make_unique<UUIDCatalogObserver>()); - _serviceContextMongoDTest.getServiceContext()->setOpObserver( - std::unique_ptr<OpObserver>(observerRegistry.release())); -} +class RSRollbackTest : public RollbackTest {}; -void RSRollbackTest::tearDown() { - RollbackTest::tearDown(); -} OplogInterfaceMock::Operation makeNoopOplogEntryAndRecordId(Seconds seconds) { OpTime ts(Timestamp(seconds, 0), 0); diff --git a/src/mongo/db/repl/service_context_repl_mock.cpp b/src/mongo/db/repl/service_context_repl_mock.cpp deleted file mode 100644 index c8d87716e8d..00000000000 --- a/src/mongo/db/repl/service_context_repl_mock.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (C) 2016 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/db/repl/service_context_repl_mock.h" - -#include "mongo/db/concurrency/lock_state.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) { - auto opCtx = stdx::make_unique<OperationContextNoop>(client, opId); - opCtx->swapLockState(stdx::make_unique<MMAPV1LockerImpl>()); - return {std::move(opCtx)}; -} - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/service_context_repl_mock.h b/src/mongo/db/repl/service_context_repl_mock.h deleted file mode 100644 index 8ffb92a9da1..00000000000 --- a/src/mongo/db/repl/service_context_repl_mock.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2016 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#pragma once - -#include "mongo/db/service_context_noop.h" - -namespace mongo { -namespace repl { - -/** - * Testing-only service context that extends ServiceContextNoop so that makeOperationContext() - * returns an instance of OperationContextReplMock. - */ -class ServiceContextReplMock : public ServiceContextNoop { -private: - std::unique_ptr<OperationContext> _newOpCtx(Client* client, unsigned opId) override; -}; - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/service_context_repl_mock_init.cpp b/src/mongo/db/repl/service_context_repl_mock_init.cpp deleted file mode 100644 index c35b47f61d7..00000000000 --- a/src/mongo/db/repl/service_context_repl_mock_init.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2016 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/base/init.h" -#include "mongo/db/repl/service_context_repl_mock.h" -#include "mongo/db/service_context.h" -#include "mongo/db/service_context_registrar.h" -#include "mongo/util/clock_source_mock.h" - -#include <memory> - -namespace mongo { -namespace repl { -namespace { - -ServiceContextRegistrar serviceContextCreator([]() { - return std::make_unique<ServiceContextReplMock>(); -}); - -} // namespace -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/task_runner_test_fixture.cpp b/src/mongo/db/repl/task_runner_test_fixture.cpp index f16bfa67be0..3e510603d8a 100644 --- a/src/mongo/db/repl/task_runner_test_fixture.cpp +++ b/src/mongo/db/repl/task_runner_test_fixture.cpp @@ -30,7 +30,7 @@ #include "mongo/db/repl/task_runner_test_fixture.h" -#include "mongo/db/operation_context_noop.h" +#include "mongo/db/auth/authorization_manager.h" #include "mongo/db/repl/task_runner.h" #include "mongo/stdx/functional.h" #include "mongo/stdx/memory.h" diff --git a/src/mongo/db/repl/task_runner_test_fixture.h b/src/mongo/db/repl/task_runner_test_fixture.h index 2787419a1e5..9076bea4135 100644 --- a/src/mongo/db/repl/task_runner_test_fixture.h +++ b/src/mongo/db/repl/task_runner_test_fixture.h @@ -31,7 +31,7 @@ #include <memory> #include "mongo/base/status.h" -#include "mongo/db/service_context.h" +#include "mongo/db/service_context_test_fixture.h" #include "mongo/unittest/unittest.h" #include "mongo/util/concurrency/thread_pool.h" @@ -48,7 +48,7 @@ class TaskRunner; * Test fixture for tests that require a TaskRunner and/or * ThreadPool. */ -class TaskRunnerTest : public unittest::Test { +class TaskRunnerTest : public ServiceContextTest { public: static Status getDetectableErrorStatus(); |