summaryrefslogtreecommitdiff
path: root/src/mongo/s/config_server_test_fixture.cpp
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2016-06-24 11:12:39 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2016-07-11 14:36:41 -0400
commit2155b293eaf4264dee1bdf68022b66e636a20a63 (patch)
tree1b125b5abf8c08a923b57fc98d4740065074123b /src/mongo/s/config_server_test_fixture.cpp
parent6dc25f703227ae486fdc8201ccfeb64e1db5c752 (diff)
downloadmongo-2155b293eaf4264dee1bdf68022b66e636a20a63.tar.gz
SERVER-24532 adding MigrationManager to manage parallel migrations
Diffstat (limited to 'src/mongo/s/config_server_test_fixture.cpp')
-rw-r--r--src/mongo/s/config_server_test_fixture.cpp48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/mongo/s/config_server_test_fixture.cpp b/src/mongo/s/config_server_test_fixture.cpp
index c04d0df2a06..4fc75f50c94 100644
--- a/src/mongo/s/config_server_test_fixture.cpp
+++ b/src/mongo/s/config_server_test_fixture.cpp
@@ -52,7 +52,8 @@
#include "mongo/rpc/metadata/server_selection_metadata.h"
#include "mongo/s/balancer/balancer_configuration.h"
#include "mongo/s/catalog/catalog_cache.h"
-#include "mongo/s/catalog/dist_lock_manager_mock.h"
+#include "mongo/s/catalog/replset/dist_lock_catalog_impl.h"
+#include "mongo/s/catalog/replset/replset_dist_lock_manager.h"
#include "mongo/s/catalog/replset/sharding_catalog_client_impl.h"
#include "mongo/s/catalog/replset/sharding_catalog_manager_impl.h"
#include "mongo/s/catalog/type_changelog.h"
@@ -104,8 +105,23 @@ void ConfigServerTestFixture::setUp() {
_opCtx = cc().makeOperationContext();
repl::ReplSettings replSettings;
- repl::ReplicationCoordinator::set(
- serviceContext, stdx::make_unique<repl::ReplicationCoordinatorMock>(replSettings));
+ auto replCoord = stdx::make_unique<repl::ReplicationCoordinatorMock>(replSettings);
+ repl::ReplicaSetConfig config;
+ config.initialize(BSON("_id"
+ << "mySet"
+ << "protocolVersion"
+ << 1
+ << "version"
+ << 3
+ << "members"
+ << BSON_ARRAY(BSON("host"
+ << "node2:12345"
+ << "_id"
+ << 1))));
+ replCoord->setGetConfigReturnValue(config);
+ repl::ReplicationCoordinator::set(serviceContext, std::move(replCoord));
+
+ serverGlobalParams.clusterRole = ClusterRole::ConfigServer;
// Set up executor pool used for most operations.
auto fixedNet = stdx::make_unique<executor::NetworkInterfaceMock>();
@@ -131,17 +147,9 @@ void ConfigServerTestFixture::setUp() {
_addShardNetworkTestEnv = stdx::make_unique<NetworkTestEnv>(specialExec.get(), specialMockNet);
_executorForAddShard = specialExec.get();
- auto uniqueDistLockManager = stdx::make_unique<DistLockManagerMock>();
- _distLockManager = uniqueDistLockManager.get();
- std::unique_ptr<ShardingCatalogClientImpl> catalogClient(
- stdx::make_unique<ShardingCatalogClientImpl>(std::move(uniqueDistLockManager)));
- _catalogClient = catalogClient.get();
- catalogClient->startup();
-
std::unique_ptr<ShardingCatalogManagerImpl> catalogManager(
stdx::make_unique<ShardingCatalogManagerImpl>(_catalogClient, std::move(specialExec)));
_catalogManager = catalogManager.get();
- catalogManager->startup();
auto targeterFactory(stdx::make_unique<RemoteCommandTargeterFactoryMock>());
auto targeterFactoryPtr = targeterFactory.get();
@@ -177,6 +185,19 @@ void ConfigServerTestFixture::setUp() {
stdx::make_unique<ShardRegistry>(std::move(shardFactory), ConnectionString::forLocal()));
executorPool->startup();
+ auto distLockCatalog = stdx::make_unique<DistLockCatalogImpl>(shardRegistry.get());
+
+ auto uniqueDistLockManager =
+ stdx::make_unique<ReplSetDistLockManager>(serviceContext,
+ "distLockProcessId",
+ std::move(distLockCatalog),
+ ReplSetDistLockManager::kDistLockPingInterval,
+ ReplSetDistLockManager::kDistLockExpirationTime);
+ _distLockManager = uniqueDistLockManager.get();
+ std::unique_ptr<ShardingCatalogClientImpl> catalogClient(
+ stdx::make_unique<ShardingCatalogClientImpl>(std::move(uniqueDistLockManager)));
+ _catalogClient = catalogClient.get();
+
// For now initialize the global grid object. All sharding objects will be accessible from there
// until we get rid of it.
grid.init(std::move(catalogClient),
@@ -187,6 +208,9 @@ void ConfigServerTestFixture::setUp() {
stdx::make_unique<BalancerConfiguration>(),
std::move(executorPool),
_mockNetwork);
+
+ _catalogClient->startup();
+ _catalogManager->startup();
}
void ConfigServerTestFixture::tearDown() {
@@ -255,7 +279,7 @@ MessagingPortMock* ConfigServerTestFixture::getMessagingPort() const {
return _messagePort.get();
}
-DistLockManagerMock* ConfigServerTestFixture::distLock() const {
+ReplSetDistLockManager* ConfigServerTestFixture::distLock() const {
invariant(_distLockManager);
return _distLockManager;
}