diff options
author | Haley Connelly <haley.connelly@10gen.com> | 2019-12-05 17:13:57 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-05 17:13:57 +0000 |
commit | 4e707f244d88b112b15080afa2361210715b12d2 (patch) | |
tree | 0a7906e14b3faefb7600ab3b7cf2594090401af8 /src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp | |
parent | 60f700791f65ca676da5e4f0fada421958a8b709 (diff) | |
download | mongo-4e707f244d88b112b15080afa2361210715b12d2.tar.gz |
SERVER-44283 Change removeKeyRangeFromZone to use the bounds found from the fully extended shard key.
Diffstat (limited to 'src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp | 72 |
1 files changed, 10 insertions, 62 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp index 6eabe85a358..e524713c11e 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp @@ -717,7 +717,7 @@ TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveWithInvalidMaxShardKeyShouldFail assertOnlyZone(shardedNS(), getExistingRange(), zoneName()); } -TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveThatIsOnlyMinPrefixOfExistingShouldNotRemoveRange) { +TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveWithPartialMinPrefixShouldRemoveRange) { NamespaceString ns("compound.shard"); CollectionType shardedCollection; shardedCollection.setNs(ns); @@ -737,39 +737,13 @@ TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveThatIsOnlyMinPrefixOfExistingSho ->removeKeyRangeFromZone( operationContext(), ns, ChunkRange(BSON("x" << 0), BSON("x" << 10 << "y" << 10)))); - { - auto findStatus = findOneOnConfigCollection( - operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); - ASSERT_OK(findStatus); - - auto tagDocStatus = TagsType::fromBSON(findStatus.getValue()); - ASSERT_OK(tagDocStatus.getStatus()); - - auto tagDoc = tagDocStatus.getValue(); - ASSERT_EQ(ns, tagDoc.getNS()); - ASSERT_BSONOBJ_EQ(existingRange.getMin(), tagDoc.getMinKey()); - ASSERT_BSONOBJ_EQ(existingRange.getMax(), tagDoc.getMaxKey()); - ASSERT_EQ(zoneName(), tagDoc.getTag()); - } - - { - const auto existingRange = getExistingRange(); - auto findStatus = findOneOnConfigCollection( - operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); - ASSERT_OK(findStatus); - - auto tagDocStatus = TagsType::fromBSON(findStatus.getValue()); - ASSERT_OK(tagDocStatus.getStatus()); - - auto tagDoc = tagDocStatus.getValue(); - ASSERT_EQ(shardedNS(), tagDoc.getNS()); - ASSERT_BSONOBJ_EQ(existingRange.getMin(), tagDoc.getMinKey()); - ASSERT_BSONOBJ_EQ(existingRange.getMax(), tagDoc.getMaxKey()); - ASSERT_EQ(zoneName(), tagDoc.getTag()); - } + // Check that zone range removal targets a shard key in its refined (expanded) state. + auto findStatus = findOneOnConfigCollection( + operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); + ASSERT_EQUALS(ErrorCodes::NoMatchingDocument, findStatus); } -TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveThatIsOnlyMaxPrefixOfExistingShouldNotRemoveRange) { +TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveWithPartialMaxPrefixShouldRemoveRange) { NamespaceString ns("compound.shard"); CollectionType shardedCollection; shardedCollection.setNs(ns); @@ -789,36 +763,10 @@ TEST_F(AssignKeyRangeWithOneRangeFixture, RemoveThatIsOnlyMaxPrefixOfExistingSho ->removeKeyRangeFromZone( operationContext(), ns, ChunkRange(BSON("x" << 0 << "y" << 0), BSON("x" << 10)))); - { - auto findStatus = findOneOnConfigCollection( - operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); - ASSERT_OK(findStatus); - - auto tagDocStatus = TagsType::fromBSON(findStatus.getValue()); - ASSERT_OK(tagDocStatus.getStatus()); - - auto tagDoc = tagDocStatus.getValue(); - ASSERT_EQ(ns, tagDoc.getNS()); - ASSERT_BSONOBJ_EQ(existingRange.getMin(), tagDoc.getMinKey()); - ASSERT_BSONOBJ_EQ(existingRange.getMax(), tagDoc.getMaxKey()); - ASSERT_EQ(zoneName(), tagDoc.getTag()); - } - - { - const auto existingRange = getExistingRange(); - auto findStatus = findOneOnConfigCollection( - operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); - ASSERT_OK(findStatus); - - auto tagDocStatus = TagsType::fromBSON(findStatus.getValue()); - ASSERT_OK(tagDocStatus.getStatus()); - - auto tagDoc = tagDocStatus.getValue(); - ASSERT_EQ(shardedNS(), tagDoc.getNS()); - ASSERT_BSONOBJ_EQ(existingRange.getMin(), tagDoc.getMinKey()); - ASSERT_BSONOBJ_EQ(existingRange.getMax(), tagDoc.getMaxKey()); - ASSERT_EQ(zoneName(), tagDoc.getTag()); - } + // Check that zone range removal targets a shard key in its refined (expanded) state. + auto findStatus = findOneOnConfigCollection( + operationContext(), TagsType::ConfigNS, BSON("min" << existingRange.getMin())); + ASSERT_EQUALS(ErrorCodes::NoMatchingDocument, findStatus); } } // namespace |