summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Fuschetto <antonio.fuschetto@mongodb.com>2021-10-20 09:48:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-20 10:14:05 +0000
commit2b6d2336bd88f61d30875be434ab178a209ff271 (patch)
tree8381a1a70e4c520acc068b2a769dd12d596caf57
parent80362db4494daa116f21e19c4c263621b897aead (diff)
downloadmongo-2b6d2336bd88f61d30875be434ab178a209ff271.tar.gz
SERVER-60713 Remove unused namespace argument from setUpChunk function
-rw-r--r--src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp62
-rw-r--r--src/mongo/db/s/balancer/migration_manager_test.cpp68
-rw-r--r--src/mongo/db/s/balancer/migration_test_fixture.cpp3
-rw-r--r--src/mongo/db/s/balancer/migration_test_fixture.h3
4 files changed, 66 insertions, 70 deletions
diff --git a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp
index 6996a495003..a4efe1ca6f2 100644
--- a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp
+++ b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp
@@ -133,8 +133,8 @@ TEST_F(BalancerChunkSelectionTest, TagRangesOverlap) {
setUpCollection(kNamespace, collUUID, version);
// Set up one chunk for the collection in the metadata.
- ChunkType chunk = setUpChunk(
- kNamespace, collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
+ ChunkType chunk =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
auto assertRangeOverlapConflictWhenMoveChunk =
[this, &chunk](const StringMap<ChunkRange>& tagChunkRanges) {
@@ -192,38 +192,37 @@ TEST_F(BalancerChunkSelectionTest, TagRangeMaxNotAlignedWithChunkMax) {
// Set up the zone.
setUpTags(kNamespace, {{"A", {kKeyPattern.globalMin(), BSON(kPattern << -10)}}});
- auto assertErrorWhenMoveChunk = [this, &version, &collUUID](
- const std::vector<ChunkRange>& chunkRanges) {
- // Give shard0 all the chunks so the cluster is imbalanced.
- for (const auto& chunkRange : chunkRanges) {
- setUpChunk(
- kNamespace, collUUID, chunkRange.getMin(), chunkRange.getMax(), kShardId0, version);
- version.incMinor();
- }
+ auto assertErrorWhenMoveChunk =
+ [this, &version, &collUUID](const std::vector<ChunkRange>& chunkRanges) {
+ // Give shard0 all the chunks so the cluster is imbalanced.
+ for (const auto& chunkRange : chunkRanges) {
+ setUpChunk(collUUID, chunkRange.getMin(), chunkRange.getMax(), kShardId0, version);
+ version.incMinor();
+ }
- auto future = launchAsync([this] {
- ThreadClient tc(getServiceContext());
- auto opCtx = Client::getCurrent()->makeOperationContext();
+ auto future = launchAsync([this] {
+ ThreadClient tc(getServiceContext());
+ auto opCtx = Client::getCurrent()->makeOperationContext();
- // Requests chunks to be relocated requires running commands on each shard to
- // get shard statistics. Set up dummy hosts for the source shards.
- shardTargeterMock(opCtx.get(), kShardId0)->setFindHostReturnValue(kShardHost0);
- shardTargeterMock(opCtx.get(), kShardId1)->setFindHostReturnValue(kShardHost1);
+ // Requests chunks to be relocated requires running commands on each shard to
+ // get shard statistics. Set up dummy hosts for the source shards.
+ shardTargeterMock(opCtx.get(), kShardId0)->setFindHostReturnValue(kShardHost0);
+ shardTargeterMock(opCtx.get(), kShardId1)->setFindHostReturnValue(kShardHost1);
- auto candidateChunksStatus =
- _chunkSelectionPolicy.get()->selectChunksToMove(opCtx.get());
- ASSERT_OK(candidateChunksStatus.getStatus());
+ auto candidateChunksStatus =
+ _chunkSelectionPolicy.get()->selectChunksToMove(opCtx.get());
+ ASSERT_OK(candidateChunksStatus.getStatus());
- // The balancer does not bubble up the IllegalOperation error, but it is expected
- // to postpone the balancing work for the zones with the error until the chunks
- // are split appropriately.
- ASSERT_EQUALS(0U, candidateChunksStatus.getValue().size());
- });
+ // The balancer does not bubble up the IllegalOperation error, but it is expected
+ // to postpone the balancing work for the zones with the error until the chunks
+ // are split appropriately.
+ ASSERT_EQUALS(0U, candidateChunksStatus.getValue().size());
+ });
- expectGetStatsCommands(2);
- future.default_timed_get();
- removeAllChunks(kNamespace, collUUID);
- };
+ expectGetStatsCommands(2);
+ future.default_timed_get();
+ removeAllChunks(kNamespace, collUUID);
+ };
assertErrorWhenMoveChunk({{kKeyPattern.globalMin(), BSON(kPattern << -5)},
{BSON(kPattern << -5), kKeyPattern.globalMax()}});
@@ -259,8 +258,7 @@ TEST_F(BalancerChunkSelectionTest, ShardedTimeseriesCollectionsCanBeAutoSplitted
});
// Create just one chunk covering the whole space
- setUpChunk(
- kNamespace, collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
+ setUpChunk(collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
auto future = launchAsync([this] {
ThreadClient tc(getServiceContext());
@@ -298,7 +296,7 @@ TEST_F(BalancerChunkSelectionTest, ShardedTimeseriesCollectionsCanBeBalanced) {
setUpCollection(kNamespace, collUUID, version, std::move(tsFields));
auto addChunk = [&](const BSONObj& min, const BSONObj& max) {
- setUpChunk(kNamespace, collUUID, min, max, kShardId0, version);
+ setUpChunk(collUUID, min, max, kShardId0, version);
version.incMinor();
};
diff --git a/src/mongo/db/s/balancer/migration_manager_test.cpp b/src/mongo/db/s/balancer/migration_manager_test.cpp
index d310a2c6c75..ed04770685e 100644
--- a/src/mongo/db/s/balancer/migration_manager_test.cpp
+++ b/src/mongo/db/s/balancer/migration_manager_test.cpp
@@ -123,11 +123,11 @@ TEST_F(MigrationManagerTest, OneCollectionTwoMigrations) {
setUpCollection(collName, collUUID, version);
// Set up two chunks in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
version.incMinor();
- ChunkType chunk2 = setUpChunk(
- collName, collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
+ ChunkType chunk2 =
+ setUpChunk(collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
// Going to request that these two chunks get migrated.
const std::vector<MigrateInfo> migrationRequests{{kShardId1,
@@ -187,17 +187,17 @@ TEST_F(MigrationManagerTest, TwoCollectionsTwoMigrationsEach) {
setUpCollection(collName2, collUUID2, version2);
// Set up two chunks in the metadata for each collection.
- ChunkType chunk1coll1 = setUpChunk(
- collName1, collUUID1, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version1);
+ ChunkType chunk1coll1 =
+ setUpChunk(collUUID1, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version1);
version1.incMinor();
- ChunkType chunk2coll1 = setUpChunk(
- collName1, collUUID1, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version1);
+ ChunkType chunk2coll1 =
+ setUpChunk(collUUID1, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version1);
- ChunkType chunk1coll2 = setUpChunk(
- collName2, collUUID2, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version2);
+ ChunkType chunk1coll2 =
+ setUpChunk(collUUID2, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version2);
version2.incMinor();
- ChunkType chunk2coll2 = setUpChunk(
- collName2, collUUID2, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version2);
+ ChunkType chunk2coll2 =
+ setUpChunk(collUUID2, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version2);
// Going to request that these four chunks get migrated.
const std::vector<MigrateInfo> migrationRequests{{kShardId1,
@@ -267,11 +267,11 @@ TEST_F(MigrationManagerTest, SourceShardNotFound) {
setUpCollection(collName, collUUID, version);
// Set up two chunks in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
version.incMinor();
- ChunkType chunk2 = setUpChunk(
- collName, collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
+ ChunkType chunk2 =
+ setUpChunk(collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
// Going to request that these two chunks get migrated.
const std::vector<MigrateInfo> migrationRequests{{kShardId1,
@@ -327,8 +327,8 @@ TEST_F(MigrationManagerTest, JumboChunkResponseBackwardsCompatibility) {
setUpCollection(collName, collUUID, version);
// Set up a single chunk in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
// Going to request that this chunk gets migrated.
const std::vector<MigrateInfo> migrationRequests{{kShardId1,
@@ -374,8 +374,8 @@ TEST_F(MigrationManagerTest, InterruptMigration) {
setUpCollection(collName, collUUID, version);
// Set up a single chunk in the metadata.
- ChunkType chunk = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
+ ChunkType chunk =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
auto future = launchAsync([&] {
ThreadClient tc("Test", getServiceContext());
@@ -473,8 +473,8 @@ TEST_F(MigrationManagerTest, RestartMigrationManager) {
setUpCollection(collName, collUUID, version);
// Set up a single chunk in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), kKeyPattern.globalMax(), kShardId0, version);
// Go through the lifecycle of the migration manager
_migrationManager->interruptAndDisableMigrations();
@@ -527,11 +527,11 @@ TEST_F(MigrationManagerTest, MigrationRecovery) {
// Set up two chunks in the metadata and set up two fake active migrations by writing documents
// to the config.migrations collection.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
version.incMinor();
- ChunkType chunk2 = setUpChunk(
- collName, collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
+ ChunkType chunk2 =
+ setUpChunk(collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
_migrationManager->interruptAndDisableMigrations();
_migrationManager->drainActiveMigrations();
@@ -581,11 +581,11 @@ TEST_F(MigrationManagerTest, FailMigrationRecovery) {
setUpCollection(collName, collUUID, version);
// Set up two chunks in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
version.incMinor();
- ChunkType chunk2 = setUpChunk(
- collName, collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
+ ChunkType chunk2 =
+ setUpChunk(collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
_migrationManager->interruptAndDisableMigrations();
_migrationManager->drainActiveMigrations();
@@ -640,11 +640,11 @@ TEST_F(MigrationManagerTest, RemoteCallErrorConversionToOperationFailed) {
setUpCollection(collName, collUUID, version);
// Set up two chunks in the metadata.
- ChunkType chunk1 = setUpChunk(
- collName, collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
+ ChunkType chunk1 =
+ setUpChunk(collUUID, kKeyPattern.globalMin(), BSON(kPattern << 49), kShardId0, version);
version.incMinor();
- ChunkType chunk2 = setUpChunk(
- collName, collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
+ ChunkType chunk2 =
+ setUpChunk(collUUID, BSON(kPattern << 49), kKeyPattern.globalMax(), kShardId2, version);
// Going to request that these two chunks get migrated.
const std::vector<MigrateInfo> migrationRequests{{kShardId1,
diff --git a/src/mongo/db/s/balancer/migration_test_fixture.cpp b/src/mongo/db/s/balancer/migration_test_fixture.cpp
index 6a913f0c45d..b970710cbe2 100644
--- a/src/mongo/db/s/balancer/migration_test_fixture.cpp
+++ b/src/mongo/db/s/balancer/migration_test_fixture.cpp
@@ -66,8 +66,7 @@ void MigrationTestFixture::setUpCollection(
operationContext(), CollectionType::ConfigNS, coll.toBSON(), kMajorityWriteConcern));
}
-ChunkType MigrationTestFixture::setUpChunk(const NamespaceString& collName,
- const UUID& collUUID,
+ChunkType MigrationTestFixture::setUpChunk(const UUID& collUUID,
const BSONObj& chunkMin,
const BSONObj& chunkMax,
const ShardId& shardId,
diff --git a/src/mongo/db/s/balancer/migration_test_fixture.h b/src/mongo/db/s/balancer/migration_test_fixture.h
index 5583728faeb..699355cce27 100644
--- a/src/mongo/db/s/balancer/migration_test_fixture.h
+++ b/src/mongo/db/s/balancer/migration_test_fixture.h
@@ -83,8 +83,7 @@ protected:
* Inserts a document into the config.chunks collection so that the chunk defined by the
* parameters exists. Returns a ChunkType defined by the parameters.
*/
- ChunkType setUpChunk(const NamespaceString& collName,
- const UUID& collUUID,
+ ChunkType setUpChunk(const UUID& collUUID,
const BSONObj& chunkMin,
const BSONObj& chunkMax,
const ShardId& shardId,