summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/SConscript1
-rw-r--r--src/mongo/db/s/active_migrations_registry_test.cpp25
-rw-r--r--src/mongo/db/s/active_move_primaries_registry_test.cpp25
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp2
-rw-r--r--src/mongo/db/s/namespace_metadata_change_notifications_test.cpp29
-rw-r--r--src/mongo/db/s/sharding_state.cpp3
6 files changed, 21 insertions, 64 deletions
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index cb57c8b8456..0af63a22dc6 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -306,6 +306,7 @@ env.CppUnitTest(
'sharding_runtime_d',
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/query/query_request',
+ '$BUILD_DIR/mongo/db/service_context_d_test_fixture',
'$BUILD_DIR/mongo/s/catalog/dist_lock_manager_mock',
'$BUILD_DIR/mongo/s/catalog/sharding_catalog_client_impl',
'$BUILD_DIR/mongo/s/catalog/sharding_catalog_client_mock',
diff --git a/src/mongo/db/s/active_migrations_registry_test.cpp b/src/mongo/db/s/active_migrations_registry_test.cpp
index 5450296d505..ba0d148b863 100644
--- a/src/mongo/db/s/active_migrations_registry_test.cpp
+++ b/src/mongo/db/s/active_migrations_registry_test.cpp
@@ -32,7 +32,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/client.h"
#include "mongo/db/s/active_migrations_registry.h"
-#include "mongo/db/service_context_noop.h"
+#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/s/request_types/move_chunk_request.h"
#include "mongo/unittest/unittest.h"
@@ -41,26 +41,8 @@ namespace {
using unittest::assertGet;
-class MoveChunkRegistration : public unittest::Test {
+class MoveChunkRegistration : public ServiceContextMongoDTest {
protected:
- void setUp() override {
- _client = _serviceContext.makeClient("MoveChunkRegistrationTest");
- _opCtx = _serviceContext.makeOperationContext(_client.get());
- }
-
- void tearDown() override {
- _opCtx.reset();
- _client.reset();
- }
-
- OperationContext* getTxn() const {
- return _opCtx.get();
- }
-
- ServiceContextNoop _serviceContext;
- ServiceContext::UniqueClient _client;
- ServiceContext::UniqueOperationContext _opCtx;
-
ActiveMigrationsRegistry _registry;
};
@@ -133,8 +115,9 @@ TEST_F(MoveChunkRegistration, SecondMigrationWithSameArgumentsJoinsFirst) {
ASSERT(!secondScopedDonateChunk.mustExecute());
originalScopedDonateChunk.signalComplete({ErrorCodes::InternalError, "Test error"});
+ auto opCtx = makeOperationContext();
ASSERT_EQ(Status(ErrorCodes::InternalError, "Test error"),
- secondScopedDonateChunk.waitForCompletion(getTxn()));
+ secondScopedDonateChunk.waitForCompletion(opCtx.get()));
}
} // namespace
diff --git a/src/mongo/db/s/active_move_primaries_registry_test.cpp b/src/mongo/db/s/active_move_primaries_registry_test.cpp
index b196fdc2621..25c028e3b48 100644
--- a/src/mongo/db/s/active_move_primaries_registry_test.cpp
+++ b/src/mongo/db/s/active_move_primaries_registry_test.cpp
@@ -29,7 +29,7 @@
#include "mongo/db/s/active_move_primaries_registry.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/client.h"
-#include "mongo/db/service_context_noop.h"
+#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/s/request_types/move_primary_gen.h"
#include "mongo/unittest/unittest.h"
@@ -38,26 +38,8 @@ namespace {
using unittest::assertGet;
-class MovePrimaryRegistration : public unittest::Test {
+class MovePrimaryRegistration : public ServiceContextMongoDTest {
protected:
- void setUp() override {
- _client = _serviceContext.makeClient("MovePrimaryRegistrationTest");
- _opCtx = _serviceContext.makeOperationContext(_client.get());
- }
-
- void tearDown() override {
- _opCtx.reset();
- _client.reset();
- }
-
- OperationContext* getTxn() const {
- return _opCtx.get();
- }
-
- ServiceContextNoop _serviceContext;
- ServiceContext::UniqueClient _client;
- ServiceContext::UniqueOperationContext _opCtx;
-
ActiveMovePrimariesRegistry _registry;
};
@@ -120,8 +102,9 @@ TEST_F(MovePrimaryRegistration, SecondMovePrimaryWithSameArgumentsJoinsFirst) {
ASSERT(!secondScopedMovePrimary.mustExecute());
originalScopedMovePrimary.signalComplete({ErrorCodes::InternalError, "Test error"});
+ auto opCtx = makeOperationContext();
ASSERT_EQ(Status(ErrorCodes::InternalError, "Test error"),
- secondScopedMovePrimary.waitForCompletion(getTxn()));
+ secondScopedMovePrimary.waitForCompletion(opCtx.get()));
}
} // namespace
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
index be6aafbe27f..43144f59b99 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
@@ -557,7 +557,7 @@ StatusWith<BSONObj> MigrationChunkClonerSourceLegacy::_callRecipient(const BSONO
executor::RemoteCommandResponse responseStatus(
Status{ErrorCodes::InternalError, "Uninitialized value"});
- auto executor = grid.getExecutorPool()->getFixedExecutor();
+ auto executor = Grid::get(getGlobalServiceContext())->getExecutorPool()->getFixedExecutor();
auto scheduleStatus = executor->scheduleRemoteCommand(
executor::RemoteCommandRequest(_recipientHost, "admin", cmdObj, nullptr),
[&responseStatus](const executor::TaskExecutor::RemoteCommandCallbackArgs& args) {
diff --git a/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp b/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
index 155eed7cae3..5e4cde64b6e 100644
--- a/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
+++ b/src/mongo/db/s/namespace_metadata_change_notifications_test.cpp
@@ -30,7 +30,8 @@
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/s/namespace_metadata_change_notifications.h"
-#include "mongo/db/service_context_noop.h"
+#include "mongo/db/service_context.h"
+#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/thread.h"
#include "mongo/unittest/unittest.h"
@@ -41,23 +42,11 @@ namespace {
const NamespaceString kNss("foo.bar");
-class NamespaceMetadataChangeNotificationsTest : public unittest::Test {
+class NamespaceMetadataChangeNotificationsTest : public ServiceContextMongoDTest {
protected:
NamespaceMetadataChangeNotificationsTest() {
- _serviceCtx.setTickSource(stdx::make_unique<TickSourceMock>());
+ getServiceContext()->setTickSource(stdx::make_unique<TickSourceMock>());
}
-
- void setUp() override {
- _client = _serviceCtx.makeClient("Test");
- }
-
- Client* client() const {
- return _client.get();
- }
-
-private:
- ServiceContextNoop _serviceCtx;
- ServiceContext::UniqueClient _client;
};
TEST_F(NamespaceMetadataChangeNotificationsTest, WaitForNotify) {
@@ -66,7 +55,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, WaitForNotify) {
auto scopedNotif = notifications.createNotification(kNss);
{
- auto opCtx = client()->makeOperationContext();
+ auto opCtx = getClient()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
scopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
@@ -75,7 +64,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, WaitForNotify) {
notifications.notifyChange(kNss);
{
- auto opCtx = client()->makeOperationContext();
+ auto opCtx = getClient()->makeOperationContext();
scopedNotif.get(opCtx.get());
}
}
@@ -86,7 +75,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, GiveUpWaitingForNotify) {
{
auto scopedNotif = notifications.createNotification(kNss);
- auto opCtx = client()->makeOperationContext();
+ auto opCtx = getClient()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
scopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
@@ -102,7 +91,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, MoveConstructionWaitForNotify)
auto movedScopedNotif = std::move(scopedNotif);
{
- auto opCtx = client()->makeOperationContext();
+ auto opCtx = getClient()->makeOperationContext();
opCtx->setDeadlineAfterNowBy(Milliseconds{0});
ASSERT_THROWS_CODE(
movedScopedNotif.get(opCtx.get()), AssertionException, ErrorCodes::ExceededTimeLimit);
@@ -111,7 +100,7 @@ TEST_F(NamespaceMetadataChangeNotificationsTest, MoveConstructionWaitForNotify)
notifications.notifyChange(kNss);
{
- auto opCtx = client()->makeOperationContext();
+ auto opCtx = getClient()->makeOperationContext();
movedScopedNotif.get(opCtx.get());
}
}
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index c45ddb1e71d..d7843fcac26 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -79,7 +79,8 @@ const auto getShardingState = ServiceContext::declareDecoration<ShardingState>()
*/
void updateShardIdentityConfigStringCB(const std::string& setName,
const std::string& newConnectionString) {
- auto configsvrConnStr = grid.shardRegistry()->getConfigServerConnectionString();
+ auto configsvrConnStr =
+ Grid::get(getGlobalServiceContext())->shardRegistry()->getConfigServerConnectionString();
if (configsvrConnStr.getSetName() != setName) {
// Ignore all change notification for other sets that are not the config server.
return;