diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2020-09-03 04:51:07 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-03 16:37:23 +0000 |
commit | 3df9c61b7747058cd84edd7a875b1524db57dd1d (patch) | |
tree | 64f914b41ba79c59022eed074ffaa7ddbf6741b5 /src/mongo/db/s/collection_metadata_test.cpp | |
parent | 58bc5d187eb30270353f68eef3977c5be57e4eb8 (diff) | |
download | mongo-3df9c61b7747058cd84edd7a875b1524db57dd1d.tar.gz |
SERVER-46199 Make the RoutingTableHistory movable
Diffstat (limited to 'src/mongo/db/s/collection_metadata_test.cpp')
-rw-r--r-- | src/mongo/db/s/collection_metadata_test.cpp | 198 |
1 files changed, 102 insertions, 96 deletions
diff --git a/src/mongo/db/s/collection_metadata_test.cpp b/src/mongo/db/s/collection_metadata_test.cpp index c26be5b2795..0c343a5ed37 100644 --- a/src/mongo/db/s/collection_metadata_test.cpp +++ b/src/mongo/db/s/collection_metadata_test.cpp @@ -29,13 +29,12 @@ #include "mongo/platform/basic.h" -#include <memory> - #include "mongo/base/status.h" #include "mongo/db/range_arithmetic.h" #include "mongo/db/s/collection_metadata.h" #include "mongo/s/catalog/type_chunk.h" #include "mongo/s/chunk_version.h" +#include "mongo/s/sharding_test_fixture_common.h" #include "mongo/unittest/unittest.h" namespace mongo { @@ -43,7 +42,7 @@ namespace { using unittest::assertGet; -std::unique_ptr<CollectionMetadata> makeCollectionMetadataImpl( +CollectionMetadata makeCollectionMetadataImpl( const KeyPattern& shardKeyPattern, const std::vector<std::pair<BSONObj, BSONObj>>& thisShardsChunks, bool staleChunkManager) { @@ -73,17 +72,27 @@ std::unique_ptr<CollectionMetadata> makeCollectionMetadataImpl( version.incMajor(); nextMinKey = myNextChunk.second; } + if (SimpleBSONObjComparator::kInstance.evaluate(nextMinKey < shardKeyPattern.globalMax())) { allChunks.emplace_back( kNss, ChunkRange{nextMinKey, shardKeyPattern.globalMax()}, version, kOtherShard); allChunks.back().setHistory({ChunkHistory(kRouting, kOtherShard)}); } - UUID uuid(UUID::gen()); - auto rt = RoutingTableHistory::makeNew( - kNss, uuid, shardKeyPattern, nullptr, false, epoch, boost::none, allChunks); - return std::make_unique<CollectionMetadata>( - ChunkManager(kThisShard, DatabaseVersion(UUID::gen(), 1), rt, kChunkManager), kThisShard); + return CollectionMetadata( + ChunkManager(kThisShard, + DatabaseVersion(UUID::gen(), 1), + ShardingTestFixtureCommon::makeStandaloneRoutingTableHistory( + RoutingTableHistory::makeNew(kNss, + UUID::gen(), + shardKeyPattern, + nullptr, + false, + epoch, + boost::none, + allChunks)), + kChunkManager), + kThisShard); } struct ConstructedRangeMap : public RangeMap { @@ -93,38 +102,38 @@ struct ConstructedRangeMap : public RangeMap { class NoChunkFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { + CollectionMetadata makeCollectionMetadata() const { return makeCollectionMetadataImpl(KeyPattern(BSON("a" << 1)), {}, false); } }; TEST_F(NoChunkFixture, KeyBelongsToMe) { - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MINKEY))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 10))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MINKEY))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MINKEY))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 10))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MINKEY))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSONObj())); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSONObj())); } TEST_F(NoChunkFixture, IsValidKey) { - ASSERT(makeCollectionMetadata()->isValidKey(BSON("a" + ASSERT(makeCollectionMetadata().isValidKey(BSON("a" + << "abcde"))); + ASSERT(makeCollectionMetadata().isValidKey(BSON("a" << 3))); + ASSERT(!makeCollectionMetadata().isValidKey(BSON("a" + << "abcde" + << "b" << 1))); + ASSERT(!makeCollectionMetadata().isValidKey(BSON("c" << "abcde"))); - ASSERT(makeCollectionMetadata()->isValidKey(BSON("a" << 3))); - ASSERT(!makeCollectionMetadata()->isValidKey(BSON("a" - << "abcde" - << "b" << 1))); - ASSERT(!makeCollectionMetadata()->isValidKey(BSON("c" - << "abcde"))); } TEST_F(NoChunkFixture, GetNextChunk) { ChunkType nextChunk; ASSERT( - !makeCollectionMetadata()->getNextChunk(makeCollectionMetadata()->getMinKey(), &nextChunk)); + !makeCollectionMetadata().getNextChunk(makeCollectionMetadata().getMinKey(), &nextChunk)); } TEST_F(NoChunkFixture, RangeOverlapsChunk) { - ASSERT(!makeCollectionMetadata()->rangeOverlapsChunk( + ASSERT(!makeCollectionMetadata().rangeOverlapsChunk( ChunkRange{BSON("a" << 100), BSON("a" << 200)})); } @@ -132,15 +141,15 @@ TEST_F(NoChunkFixture, OrphanedDataRangeBegin) { auto metadata(makeCollectionMetadata()); ConstructedRangeMap pending; - BSONObj lookupKey = metadata->getMinKey(); - auto keyRange = metadata->getNextOrphanRange(pending, lookupKey); + BSONObj lookupKey = metadata.getMinKey(); + auto keyRange = metadata.getNextOrphanRange(pending, lookupKey); ASSERT(keyRange); - ASSERT(keyRange->getMin().woCompare(metadata->getMinKey()) == 0); - ASSERT(keyRange->getMax().woCompare(metadata->getMaxKey()) == 0); + ASSERT(keyRange->getMin().woCompare(metadata.getMinKey()) == 0); + ASSERT(keyRange->getMax().woCompare(metadata.getMaxKey()) == 0); // Make sure we don't have any more ranges - ASSERT(!metadata->getNextOrphanRange(pending, keyRange->getMax())); + ASSERT(!metadata.getNextOrphanRange(pending, keyRange->getMax())); } TEST_F(NoChunkFixture, OrphanedDataRangeMiddle) { @@ -148,21 +157,21 @@ TEST_F(NoChunkFixture, OrphanedDataRangeMiddle) { ConstructedRangeMap pending; BSONObj lookupKey = BSON("a" << 20); - auto keyRange = metadata->getNextOrphanRange(pending, lookupKey); + auto keyRange = metadata.getNextOrphanRange(pending, lookupKey); ASSERT(keyRange); - ASSERT(keyRange->getMin().woCompare(metadata->getMinKey()) == 0); - ASSERT(keyRange->getMax().woCompare(metadata->getMaxKey()) == 0); + ASSERT(keyRange->getMin().woCompare(metadata.getMinKey()) == 0); + ASSERT(keyRange->getMax().woCompare(metadata.getMaxKey()) == 0); // Make sure we don't have any more ranges - ASSERT(!metadata->getNextOrphanRange(pending, keyRange->getMax())); + ASSERT(!metadata.getNextOrphanRange(pending, keyRange->getMax())); } TEST_F(NoChunkFixture, OrphanedDataRangeEnd) { auto metadata(makeCollectionMetadata()); ConstructedRangeMap pending; - ASSERT(!metadata->getNextOrphanRange(pending, metadata->getMaxKey())); + ASSERT(!metadata.getNextOrphanRange(pending, metadata.getMaxKey())); } /** @@ -171,31 +180,30 @@ TEST_F(NoChunkFixture, OrphanedDataRangeEnd) { */ class SingleChunkFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { + CollectionMetadata makeCollectionMetadata() const { return makeCollectionMetadataImpl( KeyPattern(BSON("a" << 1)), {std::make_pair(BSON("a" << 10), BSON("a" << 20))}, false); } }; TEST_F(SingleChunkFixture, KeyBelongsToMe) { - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 10))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 15))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 19))); - - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 0))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 9))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 20))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 1234))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MINKEY))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MAXKEY))); - - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSONObj())); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 10))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 15))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 19))); + + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 0))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 9))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 20))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 1234))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MINKEY))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MAXKEY))); + + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSONObj())); } TEST_F(SingleChunkFixture, GetNextChunk) { ChunkType nextChunk; - ASSERT( - makeCollectionMetadata()->getNextChunk(makeCollectionMetadata()->getMinKey(), &nextChunk)); + ASSERT(makeCollectionMetadata().getNextChunk(makeCollectionMetadata().getMinKey(), &nextChunk)); ASSERT_EQUALS(0, nextChunk.getMin().woCompare(BSON("a" << 10))); ASSERT_EQUALS(0, nextChunk.getMax().woCompare(BSON("a" << 20))); } @@ -203,37 +211,37 @@ TEST_F(SingleChunkFixture, GetNextChunk) { TEST_F(SingleChunkFixture, GetNextChunkShouldFindNothing) { ChunkType nextChunk; ASSERT( - !makeCollectionMetadata()->getNextChunk(makeCollectionMetadata()->getMaxKey(), &nextChunk)); + !makeCollectionMetadata().getNextChunk(makeCollectionMetadata().getMaxKey(), &nextChunk)); } TEST_F(SingleChunkFixture, RangeOverlapsChunk) { - ASSERT(!makeCollectionMetadata()->rangeOverlapsChunk( - ChunkRange{BSON("a" << 20), BSON("a" << 30)})); - ASSERT(!makeCollectionMetadata()->rangeOverlapsChunk( + ASSERT( + !makeCollectionMetadata().rangeOverlapsChunk(ChunkRange{BSON("a" << 20), BSON("a" << 30)})); + ASSERT(!makeCollectionMetadata().rangeOverlapsChunk( ChunkRange{BSON("a" << 100), BSON("a" << 200)})); ASSERT( - !makeCollectionMetadata()->rangeOverlapsChunk(ChunkRange{BSON("a" << 0), BSON("a" << 10)})); + !makeCollectionMetadata().rangeOverlapsChunk(ChunkRange{BSON("a" << 0), BSON("a" << 10)})); ASSERT( - makeCollectionMetadata()->rangeOverlapsChunk(ChunkRange{BSON("a" << 11), BSON("a" << 19)})); + makeCollectionMetadata().rangeOverlapsChunk(ChunkRange{BSON("a" << 11), BSON("a" << 19)})); ASSERT( - makeCollectionMetadata()->rangeOverlapsChunk(ChunkRange{BSON("a" << 19), BSON("a" << 20)})); + makeCollectionMetadata().rangeOverlapsChunk(ChunkRange{BSON("a" << 19), BSON("a" << 20)})); } TEST_F(SingleChunkFixture, ChunkOrphanedDataRanges) { ConstructedRangeMap pending; - auto keyRange = makeCollectionMetadata()->getNextOrphanRange( - pending, makeCollectionMetadata()->getMinKey()); + auto keyRange = + makeCollectionMetadata().getNextOrphanRange(pending, makeCollectionMetadata().getMinKey()); ASSERT(keyRange); - ASSERT(keyRange->getMin().woCompare(makeCollectionMetadata()->getMinKey()) == 0); + ASSERT(keyRange->getMin().woCompare(makeCollectionMetadata().getMinKey()) == 0); ASSERT(keyRange->getMax().woCompare(BSON("a" << 10)) == 0); - keyRange = makeCollectionMetadata()->getNextOrphanRange(pending, keyRange->getMax()); + keyRange = makeCollectionMetadata().getNextOrphanRange(pending, keyRange->getMax()); ASSERT(keyRange); ASSERT(keyRange->getMin().woCompare(BSON("a" << 20)) == 0); - ASSERT(keyRange->getMax().woCompare(makeCollectionMetadata()->getMaxKey()) == 0); + ASSERT(keyRange->getMax().woCompare(makeCollectionMetadata().getMaxKey()) == 0); - ASSERT(!makeCollectionMetadata()->getNextOrphanRange(pending, keyRange->getMax())); + ASSERT(!makeCollectionMetadata().getNextOrphanRange(pending, keyRange->getMax())); } /** @@ -242,7 +250,7 @@ TEST_F(SingleChunkFixture, ChunkOrphanedDataRanges) { */ class SingleChunkMinMaxCompoundKeyFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { + CollectionMetadata makeCollectionMetadata() const { const KeyPattern shardKeyPattern(BSON("a" << 1 << "b" << 1)); return makeCollectionMetadataImpl( shardKeyPattern, @@ -252,13 +260,13 @@ protected: }; TEST_F(SingleChunkMinMaxCompoundKeyFixture, KeyBelongsToMe) { - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MINKEY << "b" << MINKEY))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MINKEY << "b" << 10))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 10 << "b" << 20))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << MINKEY << "b" << MINKEY))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << MINKEY << "b" << 10))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 10 << "b" << 20))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MAXKEY << "b" << MAXKEY))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MAXKEY << "b" << MAXKEY))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSONObj())); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSONObj())); } /** @@ -267,7 +275,7 @@ TEST_F(SingleChunkMinMaxCompoundKeyFixture, KeyBelongsToMe) { */ class TwoChunksWithGapCompoundKeyFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { + CollectionMetadata makeCollectionMetadata() const { return makeCollectionMetadataImpl( KeyPattern(BSON("a" << 1 << "b" << 1)), {std::make_pair(BSON("a" << 10 << "b" << 0), BSON("a" << 20 << "b" << 0)), @@ -279,23 +287,23 @@ protected: TEST_F(TwoChunksWithGapCompoundKeyFixture, ChunkGapOrphanedDataRanges) { ConstructedRangeMap pending; - auto keyRange = makeCollectionMetadata()->getNextOrphanRange( - pending, makeCollectionMetadata()->getMinKey()); + auto keyRange = + makeCollectionMetadata().getNextOrphanRange(pending, makeCollectionMetadata().getMinKey()); ASSERT(keyRange); - ASSERT(keyRange->getMin().woCompare(makeCollectionMetadata()->getMinKey()) == 0); + ASSERT(keyRange->getMin().woCompare(makeCollectionMetadata().getMinKey()) == 0); ASSERT(keyRange->getMax().woCompare(BSON("a" << 10 << "b" << 0)) == 0); - keyRange = makeCollectionMetadata()->getNextOrphanRange(pending, keyRange->getMax()); + keyRange = makeCollectionMetadata().getNextOrphanRange(pending, keyRange->getMax()); ASSERT(keyRange); ASSERT(keyRange->getMin().woCompare(BSON("a" << 20 << "b" << 0)) == 0); ASSERT(keyRange->getMax().woCompare(BSON("a" << 30 << "b" << 0)) == 0); - keyRange = makeCollectionMetadata()->getNextOrphanRange(pending, keyRange->getMax()); + keyRange = makeCollectionMetadata().getNextOrphanRange(pending, keyRange->getMax()); ASSERT(keyRange); ASSERT(keyRange->getMin().woCompare(BSON("a" << 40 << "b" << 0)) == 0); - ASSERT(keyRange->getMax().woCompare(makeCollectionMetadata()->getMaxKey()) == 0); + ASSERT(keyRange->getMax().woCompare(makeCollectionMetadata().getMaxKey()) == 0); - ASSERT(!makeCollectionMetadata()->getNextOrphanRange(pending, keyRange->getMax())); + ASSERT(!makeCollectionMetadata().getNextOrphanRange(pending, keyRange->getMax())); } /** @@ -304,8 +312,7 @@ TEST_F(TwoChunksWithGapCompoundKeyFixture, ChunkGapOrphanedDataRanges) { */ class ThreeChunkWithRangeGapFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { - + CollectionMetadata makeCollectionMetadata() const { return makeCollectionMetadataImpl(KeyPattern(BSON("a" << 1)), {std::make_pair(BSON("a" << MINKEY), BSON("a" << 10)), std::make_pair(BSON("a" << 10), BSON("a" << 20)), @@ -319,52 +326,51 @@ TEST_F(ThreeChunkWithRangeGapFixture, GetNextChunkMatch) { ChunkType chunk; - ASSERT(metadata->getNextChunk(BSON("a" << MINKEY), &chunk)); - ASSERT_BSONOBJ_EQ(metadata->getMinKey(), chunk.getMin()); + ASSERT(metadata.getNextChunk(BSON("a" << MINKEY), &chunk)); + ASSERT_BSONOBJ_EQ(metadata.getMinKey(), chunk.getMin()); ASSERT_BSONOBJ_EQ(BSON("a" << MINKEY), chunk.getMin()); ASSERT_BSONOBJ_EQ(BSON("a" << 10), chunk.getMax()); - ASSERT(metadata->getNextChunk(BSON("a" << 10), &chunk)); + ASSERT(metadata.getNextChunk(BSON("a" << 10), &chunk)); ASSERT_BSONOBJ_EQ(BSON("a" << 10), chunk.getMin()); ASSERT_BSONOBJ_EQ(BSON("a" << 20), chunk.getMax()); - ASSERT(metadata->getNextChunk(BSON("a" << 30), &chunk)); + ASSERT(metadata.getNextChunk(BSON("a" << 30), &chunk)); ASSERT_BSONOBJ_EQ(BSON("a" << 30), chunk.getMin()); - ASSERT_BSONOBJ_EQ(metadata->getMaxKey(), chunk.getMax()); + ASSERT_BSONOBJ_EQ(metadata.getMaxKey(), chunk.getMax()); ASSERT_BSONOBJ_EQ(BSON("a" << MAXKEY), chunk.getMax()); } TEST_F(ThreeChunkWithRangeGapFixture, KeyBelongsToMe) { - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 5))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 10))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 30))); - ASSERT(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 40))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 5))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 10))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 30))); + ASSERT(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 40))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 20))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 25))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSON("a" << MAXKEY))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 20))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << 25))); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSON("a" << MAXKEY))); - ASSERT(!makeCollectionMetadata()->keyBelongsToMe(BSONObj())); + ASSERT(!makeCollectionMetadata().keyBelongsToMe(BSONObj())); } TEST_F(ThreeChunkWithRangeGapFixture, GetNextChunkFromBeginning) { ChunkType nextChunk; - ASSERT( - makeCollectionMetadata()->getNextChunk(makeCollectionMetadata()->getMinKey(), &nextChunk)); + ASSERT(makeCollectionMetadata().getNextChunk(makeCollectionMetadata().getMinKey(), &nextChunk)); ASSERT_EQUALS(0, nextChunk.getMin().woCompare(BSON("a" << MINKEY))); ASSERT_EQUALS(0, nextChunk.getMax().woCompare(BSON("a" << 10))); } TEST_F(ThreeChunkWithRangeGapFixture, GetNextChunkFromMiddle) { ChunkType nextChunk; - ASSERT(makeCollectionMetadata()->getNextChunk(BSON("a" << 20), &nextChunk)); + ASSERT(makeCollectionMetadata().getNextChunk(BSON("a" << 20), &nextChunk)); ASSERT_EQUALS(0, nextChunk.getMin().woCompare(BSON("a" << 30))); ASSERT_EQUALS(0, nextChunk.getMax().woCompare(BSON("a" << MAXKEY))); } TEST_F(ThreeChunkWithRangeGapFixture, GetNextChunkFromLast) { ChunkType nextChunk; - ASSERT(makeCollectionMetadata()->getNextChunk(BSON("a" << 30), &nextChunk)); + ASSERT(makeCollectionMetadata().getNextChunk(BSON("a" << 30), &nextChunk)); ASSERT_EQUALS(0, nextChunk.getMin().woCompare(BSON("a" << 30))); ASSERT_EQUALS(0, nextChunk.getMax().woCompare(BSON("a" << MAXKEY))); } @@ -375,18 +381,18 @@ TEST_F(ThreeChunkWithRangeGapFixture, GetNextChunkFromLast) { */ class StaleChunkFixture : public unittest::Test { protected: - std::unique_ptr<CollectionMetadata> makeCollectionMetadata() const { + CollectionMetadata makeCollectionMetadata() const { return makeCollectionMetadataImpl( KeyPattern(BSON("a" << 1)), {std::make_pair(BSON("a" << 10), BSON("a" << 20))}, true); } }; TEST_F(StaleChunkFixture, KeyBelongsToMe) { - ASSERT_THROWS_CODE(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 10)), + ASSERT_THROWS_CODE(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 10)), AssertionException, ErrorCodes::StaleChunkHistory); - ASSERT_THROWS_CODE(makeCollectionMetadata()->keyBelongsToMe(BSON("a" << 0)), + ASSERT_THROWS_CODE(makeCollectionMetadata().keyBelongsToMe(BSON("a" << 0)), AssertionException, ErrorCodes::StaleChunkHistory); } |