diff options
Diffstat (limited to 'src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp | 125 |
1 files changed, 36 insertions, 89 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp index 3ae9a91fce5..9b4e340e508 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp @@ -368,7 +368,6 @@ protected: ASSERT_EQUALS(expectedShard.getName(), foundShard.getName()); ASSERT_EQUALS(expectedShard.getHost(), foundShard.getHost()); - ASSERT_EQUALS(expectedShard.getMaxSizeMB(), foundShard.getMaxSizeMB()); ASSERT_EQUALS(expectedShard.getDraining(), foundShard.getDraining()); ASSERT_EQUALS((int)expectedShard.getState(), (int)foundShard.getState()); ASSERT_TRUE(foundShard.getTags().empty()); @@ -459,7 +458,6 @@ TEST_F(AddShardTest, StandaloneBasicSuccess) { ShardType expectedShard; expectedShard.setName(expectedShardName); expectedShard.setHost("StandaloneHost:12345"); - expectedShard.setMaxSizeMB(100); expectedShard.setState(ShardType::ShardState::kShardAware); DatabaseType discoveredDB1( @@ -477,8 +475,7 @@ TEST_F(AddShardTest, StandaloneBasicSuccess) { assertGet(ShardingCatalogManager::get(opCtx.get()) ->addShard(opCtx.get(), &expectedShardName, - assertGet(ConnectionString::parse("StandaloneHost:12345")), - 100)); + assertGet(ConnectionString::parse("StandaloneHost:12345")))); ASSERT_EQUALS(expectedShardName, shardName); }); @@ -535,7 +532,6 @@ TEST_F(AddShardTest, StandaloneGenerateName) { ShardType existingShard; existingShard.setName("shard0005"); existingShard.setHost("existingHost:12345"); - existingShard.setMaxSizeMB(100); existingShard.setState(ShardType::ShardState::kShardAware); // Add a pre-existing shard so when generating a name for the new shard it will have to go @@ -552,7 +548,6 @@ TEST_F(AddShardTest, StandaloneGenerateName) { ShardType expectedShard; expectedShard.setName(expectedShardName); expectedShard.setHost(shardTarget.toString()); - expectedShard.setMaxSizeMB(100); expectedShard.setState(ShardType::ShardState::kShardAware); DatabaseType discoveredDB1( @@ -565,7 +560,7 @@ TEST_F(AddShardTest, StandaloneGenerateName) { auto opCtx = Client::getCurrent()->makeOperationContext(); auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), nullptr, ConnectionString(shardTarget), 100)); + ->addShard(opCtx.get(), nullptr, ConnectionString(shardTarget))); ASSERT_EQUALS(expectedShardName, shardName); }); @@ -623,7 +618,7 @@ TEST_F(AddShardTest, AddSCCCConnectionStringAsShard) { auto opCtx = Client::getCurrent()->makeOperationContext(); const std::string shardName("StandaloneShard"); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &shardName, invalidConn, 100); + ->addShard(opCtx.get(), &shardName, invalidConn); ASSERT_EQUALS(ErrorCodes::BadValue, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "Invalid connection string"); }); @@ -642,8 +637,7 @@ TEST_F(AddShardTest, EmptyShardName) { auto status = ShardingCatalogManager::get(opCtx.get()) ->addShard(opCtx.get(), &expectedShardName, - assertGet(ConnectionString::parse("StandaloneHost:12345")), - 100); + assertGet(ConnectionString::parse("StandaloneHost:12345"))); ASSERT_EQUALS(ErrorCodes::BadValue, status); ASSERT_EQUALS("shard name cannot be empty", status.getStatus().reason()); }); @@ -667,7 +661,7 @@ TEST_F(AddShardTest, UnreachableHost) { auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget), 100); + ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget)); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "host unreachable"); }); @@ -694,7 +688,7 @@ TEST_F(AddShardTest, AddMongosAsShard) { auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget), 100); + ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget)); ASSERT_EQUALS(ErrorCodes::IllegalOperation, status); }); @@ -721,7 +715,7 @@ TEST_F(AddShardTest, AddReplicaSetShardAsStandalone) { auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget), 100); + ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget)); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "use replica set url format"); }); @@ -751,7 +745,7 @@ TEST_F(AddShardTest, AddStandaloneHostShardAsReplicaSet) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "host did not return a set name"); }); @@ -780,7 +774,7 @@ TEST_F(AddShardTest, ReplicaSetMistmatchedReplicaSetName) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "does not match the actual set name"); }); @@ -810,7 +804,7 @@ TEST_F(AddShardTest, ShardIsCSRSConfigServer) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "as a shard since it is a config server"); @@ -842,7 +836,7 @@ TEST_F(AddShardTest, ReplicaSetMissingHostsProvidedInSeedList) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS(status.getStatus().reason(), "host2:12345 does not belong to replica set"); @@ -876,7 +870,7 @@ TEST_F(AddShardTest, AddShardWithNameConfigFails) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::BadValue, status); ASSERT_EQUALS(status.getStatus().reason(), "use of shard replica set with name 'config' is not allowed"); @@ -921,7 +915,7 @@ TEST_F(AddShardTest, ShardContainsExistingDatabase) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto status = ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, connString, 100); + ->addShard(opCtx.get(), &expectedShardName, connString); ASSERT_EQUALS(ErrorCodes::OperationFailed, status); ASSERT_STRING_CONTAINS( status.getStatus().reason(), @@ -958,7 +952,6 @@ TEST_F(AddShardTest, SuccessfullyAddReplicaSet) { ShardType expectedShard; expectedShard.setName(expectedShardName); expectedShard.setHost(connString.toString()); - expectedShard.setMaxSizeMB(100); expectedShard.setState(ShardType::ShardState::kShardAware); DatabaseType discoveredDB( @@ -967,8 +960,8 @@ TEST_F(AddShardTest, SuccessfullyAddReplicaSet) { auto future = launchAsync([this, &expectedShardName, &connString] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), nullptr, connString, 100)); + auto shardName = assertGet( + ShardingCatalogManager::get(opCtx.get())->addShard(opCtx.get(), nullptr, connString)); ASSERT_EQUALS(expectedShardName, shardName); }); @@ -1030,7 +1023,6 @@ TEST_F(AddShardTest, ReplicaSetExtraHostsDiscovered) { ShardType expectedShard; expectedShard.setName(expectedShardName); expectedShard.setHost(fullConnString.toString()); - expectedShard.setMaxSizeMB(100); expectedShard.setState(ShardType::ShardState::kShardAware); DatabaseType discoveredDB( @@ -1039,8 +1031,8 @@ TEST_F(AddShardTest, ReplicaSetExtraHostsDiscovered) { auto future = launchAsync([this, &expectedShardName, &seedString] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), nullptr, seedString, 100)); + auto shardName = assertGet( + ShardingCatalogManager::get(opCtx.get())->addShard(opCtx.get(), nullptr, seedString)); ASSERT_EQUALS(expectedShardName, shardName); }); @@ -1103,7 +1095,6 @@ TEST_F(AddShardTest, AddShardSucceedsEvenIfAddingDBsFromNewShardFails) { ShardType expectedShard; expectedShard.setName(expectedShardName); expectedShard.setHost("StandaloneHost:12345"); - expectedShard.setMaxSizeMB(100); expectedShard.setState(ShardType::ShardState::kShardAware); DatabaseType discoveredDB1( @@ -1124,7 +1115,7 @@ TEST_F(AddShardTest, AddShardSucceedsEvenIfAddingDBsFromNewShardFails) { auto opCtx = Client::getCurrent()->makeOperationContext(); auto shardName = assertGet( ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget), 100)); + ->addShard(opCtx.get(), &expectedShardName, ConnectionString(shardTarget))); ASSERT_EQUALS(expectedShardName, shardName); }); @@ -1202,7 +1193,6 @@ TEST_F(AddShardTest, AddExistingShardStandalone) { ShardType existingShard; existingShard.setName(existingShardName); existingShard.setHost(shardTarget.toString()); - existingShard.setMaxSizeMB(100); existingShard.setState(ShardType::ShardState::kShardAware); // Make sure the shard already exists. @@ -1219,29 +1209,13 @@ TEST_F(AddShardTest, AddExistingShardStandalone) { auto opCtx = Client::getCurrent()->makeOperationContext(); ASSERT_EQUALS(ErrorCodes::IllegalOperation, ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), - &differentName, - ConnectionString(shardTarget), - existingShard.getMaxSizeMB())); + ->addShard(opCtx.get(), &differentName, ConnectionString(shardTarget))); }); future1.timed_get(kLongFutureTimeout); // Ensure that the shard document was unchanged. assertShardExists(existingShard); - // Adding the same standalone host with a different maxSize should fail. - auto future2 = launchAsync([&] { - ThreadClient tc(getServiceContext()); - auto opCtx = Client::getCurrent()->makeOperationContext(); - ASSERT_EQUALS(ErrorCodes::IllegalOperation, - ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), - nullptr, - ConnectionString(shardTarget), - existingShard.getMaxSizeMB() + 100)); - }); - future2.timed_get(kLongFutureTimeout); - // Adding the same standalone host but as part of a replica set should fail. // Ensures that even if the user changed the standalone shard to a single-node replica set, you // can't change the sharded cluster's notion of the shard from standalone to replica set just @@ -1253,8 +1227,7 @@ TEST_F(AddShardTest, AddExistingShardStandalone) { ShardingCatalogManager::get(opCtx.get()) ->addShard(opCtx.get(), nullptr, - ConnectionString::forReplicaSet("mySet", {shardTarget}), - existingShard.getMaxSizeMB())); + ConnectionString::forReplicaSet("mySet", {shardTarget}))); }); future3.timed_get(kLongFutureTimeout); @@ -1265,11 +1238,9 @@ TEST_F(AddShardTest, AddExistingShardStandalone) { auto future4 = launchAsync([&] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), - &existingShardName, - ConnectionString(shardTarget), - existingShard.getMaxSizeMB())); + auto shardName = assertGet( + ShardingCatalogManager::get(opCtx.get()) + ->addShard(opCtx.get(), &existingShardName, ConnectionString(shardTarget))); ASSERT_EQUALS(existingShardName, shardName); }); future4.timed_get(kLongFutureTimeout); @@ -1282,11 +1253,9 @@ TEST_F(AddShardTest, AddExistingShardStandalone) { auto future5 = launchAsync([&] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), - nullptr, - ConnectionString(shardTarget), - existingShard.getMaxSizeMB())); + auto shardName = + assertGet(ShardingCatalogManager::get(opCtx.get()) + ->addShard(opCtx.get(), nullptr, ConnectionString(shardTarget))); ASSERT_EQUALS(existingShardName, shardName); }); future5.timed_get(kLongFutureTimeout); @@ -1311,7 +1280,6 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { ShardType existingShard; existingShard.setName(existingShardName); existingShard.setHost(connString.toString()); - existingShard.setMaxSizeMB(100); existingShard.setState(ShardType::ShardState::kShardAware); // Make sure the shard already exists. @@ -1326,27 +1294,15 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { auto future1 = launchAsync([&] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - ASSERT_EQUALS( - ErrorCodes::IllegalOperation, - ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), &differentName, connString, existingShard.getMaxSizeMB())); + ASSERT_EQUALS(ErrorCodes::IllegalOperation, + ShardingCatalogManager::get(opCtx.get()) + ->addShard(opCtx.get(), &differentName, connString)); }); future1.timed_get(kLongFutureTimeout); // Ensure that the shard document was unchanged. assertShardExists(existingShard); - // Adding the same connection string with a different maxSize should fail. - auto future2 = launchAsync([&] { - ThreadClient tc(getServiceContext()); - auto opCtx = Client::getCurrent()->makeOperationContext(); - ASSERT_EQUALS( - ErrorCodes::IllegalOperation, - ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), nullptr, connString, existingShard.getMaxSizeMB() + 100)); - }); - future2.timed_get(kLongFutureTimeout); - // Ensure that the shard document was unchanged. assertShardExists(existingShard); @@ -1360,10 +1316,7 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { auto opCtx = Client::getCurrent()->makeOperationContext(); ASSERT_EQUALS(ErrorCodes::IllegalOperation, ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), - nullptr, - ConnectionString(shardTarget), - existingShard.getMaxSizeMB())); + ->addShard(opCtx.get(), nullptr, ConnectionString(shardTarget))); }); future3.timed_get(kLongFutureTimeout); @@ -1382,8 +1335,7 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { ->addShard(opCtx.get(), nullptr, ConnectionString::forReplicaSet(differentSetName, - connString.getServers()), - existingShard.getMaxSizeMB())); + connString.getServers()))); }); future4.timed_get(kLongFutureTimeout); @@ -1394,10 +1346,8 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { auto future5 = launchAsync([&] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet( - ShardingCatalogManager::get(opCtx.get()) - ->addShard( - opCtx.get(), &existingShardName, connString, existingShard.getMaxSizeMB())); + auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) + ->addShard(opCtx.get(), &existingShardName, connString)); ASSERT_EQUALS(existingShardName, shardName); }); future5.timed_get(kLongFutureTimeout); @@ -1408,8 +1358,7 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); auto shardName = assertGet( - ShardingCatalogManager::get(opCtx.get()) - ->addShard(opCtx.get(), nullptr, connString, existingShard.getMaxSizeMB())); + ShardingCatalogManager::get(opCtx.get())->addShard(opCtx.get(), nullptr, connString)); ASSERT_EQUALS(existingShardName, shardName); }); future6.timed_get(kLongFutureTimeout); @@ -1432,10 +1381,8 @@ TEST_F(AddShardTest, AddExistingShardReplicaSet) { auto future7 = launchAsync([&] { ThreadClient tc(getServiceContext()); auto opCtx = Client::getCurrent()->makeOperationContext(); - auto shardName = assertGet( - ShardingCatalogManager::get(opCtx.get()) - ->addShard( - opCtx.get(), nullptr, otherHostConnString, existingShard.getMaxSizeMB())); + auto shardName = assertGet(ShardingCatalogManager::get(opCtx.get()) + ->addShard(opCtx.get(), nullptr, otherHostConnString)); ASSERT_EQUALS(existingShardName, shardName); }); future7.timed_get(kLongFutureTimeout); |