diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-03-31 17:27:11 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-04-04 11:34:47 -0400 |
commit | b1fd308ad04a5a6719fe72bcd23b10f1b8266097 (patch) | |
tree | 119e63854bb0a6669bd6c3084225ca6578f315d7 /src/mongo/s/sharding_test_fixture.cpp | |
parent | 034d01df1ee4c8f56b2dc181e21abf6ac0a80ee0 (diff) | |
download | mongo-b1fd308ad04a5a6719fe72bcd23b10f1b8266097.tar.gz |
SERVER-22611 Get rid of ChunkDiff and add more CatalogCache tests
This change gets rid of the "chunk differ" which was previously shared
between mongos and mongod. Instead its relatively simple logic has been
moved inside the CatalogCache.
Diffstat (limited to 'src/mongo/s/sharding_test_fixture.cpp')
-rw-r--r-- | src/mongo/s/sharding_test_fixture.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/s/sharding_test_fixture.cpp b/src/mongo/s/sharding_test_fixture.cpp index f912196e595..d2cbad585a1 100644 --- a/src/mongo/s/sharding_test_fixture.cpp +++ b/src/mongo/s/sharding_test_fixture.cpp @@ -94,16 +94,23 @@ ShardingTestFixture::~ShardingTestFixture() = default; const Seconds ShardingTestFixture::kFutureTimeout{5}; void ShardingTestFixture::setUp() { - _service = stdx::make_unique<ServiceContextNoop>(); - _service->setFastClockSource(stdx::make_unique<ClockSourceMock>()); - _service->setPreciseClockSource(stdx::make_unique<ClockSourceMock>()); - _service->setTickSource(stdx::make_unique<TickSourceMock>()); - auto tlMock = stdx::make_unique<transport::TransportLayerMock>(); - _transportLayer = tlMock.get(); - _service->addAndStartTransportLayer(std::move(tlMock)); - CollatorFactoryInterface::set(_service.get(), stdx::make_unique<CollatorFactoryMock>()); + { + auto service = stdx::make_unique<ServiceContextNoop>(); + service->setFastClockSource(stdx::make_unique<ClockSourceMock>()); + service->setPreciseClockSource(stdx::make_unique<ClockSourceMock>()); + service->setTickSource(stdx::make_unique<TickSourceMock>()); + auto tlMock = stdx::make_unique<transport::TransportLayerMock>(); + _transportLayer = tlMock.get(); + service->addAndStartTransportLayer(std::move(tlMock)); + + // Set the newly created service context to be the current global context so that tests, + // which invoke code still referencing getGlobalServiceContext will work properly. + setGlobalServiceContext(std::move(service)); + } + + CollatorFactoryInterface::set(serviceContext(), stdx::make_unique<CollatorFactoryMock>()); _transportSession = transport::MockSession::create(_transportLayer); - _client = _service->makeClient("ShardingTestFixture", _transportSession); + _client = serviceContext()->makeClient("ShardingTestFixture", _transportSession); _opCtx = _client->makeOperationContext(); // Set up executor pool used for most operations. @@ -174,7 +181,7 @@ void ShardingTestFixture::setUp() { nullptr, stdx::make_unique<CatalogCache>(), std::move(shardRegistry), - stdx::make_unique<ClusterCursorManager>(_service->getPreciseClockSource()), + stdx::make_unique<ClusterCursorManager>(serviceContext()->getPreciseClockSource()), stdx::make_unique<BalancerConfiguration>(), std::move(executorPool), _mockNetwork); @@ -188,7 +195,6 @@ void ShardingTestFixture::tearDown() { _transportSession.reset(); _opCtx.reset(); _client.reset(); - _service.reset(); } void ShardingTestFixture::shutdownExecutor() { @@ -239,9 +245,7 @@ DistLockManagerMock* ShardingTestFixture::distLock() const { } ServiceContext* ShardingTestFixture::serviceContext() const { - invariant(_service); - - return _service.get(); + return getGlobalServiceContext(); } OperationContext* ShardingTestFixture::operationContext() const { |