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_sharding_runtime_test.cpp | |
parent | 58bc5d187eb30270353f68eef3977c5be57e4eb8 (diff) | |
download | mongo-3df9c61b7747058cd84edd7a875b1524db57dd1d.tar.gz |
SERVER-46199 Make the RoutingTableHistory movable
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime_test.cpp')
-rw-r--r-- | src/mongo/db/s/collection_sharding_runtime_test.cpp | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime_test.cpp b/src/mongo/db/s/collection_sharding_runtime_test.cpp index 0ea329db1b9..952924bf6f9 100644 --- a/src/mongo/db/s/collection_sharding_runtime_test.cpp +++ b/src/mongo/db/s/collection_sharding_runtime_test.cpp @@ -45,34 +45,39 @@ const NamespaceString kTestNss("TestDB", "TestColl"); const std::string kShardKey = "_id"; const BSONObj kShardKeyPattern = BSON(kShardKey << 1); -using CollectionShardingRuntimeTest = ShardServerTestFixture; - -CollectionMetadata makeShardedMetadata(OperationContext* opCtx, UUID uuid = UUID::gen()) { - const OID epoch = OID::gen(); - auto range = ChunkRange(BSON(kShardKey << MINKEY), BSON(kShardKey << MAXKEY)); - auto chunk = ChunkType(kTestNss, std::move(range), ChunkVersion(1, 0, epoch), ShardId("other")); - ChunkManager cm(ShardId("0"), - DatabaseVersion(UUID::gen(), 1), - RoutingTableHistory::makeNew(kTestNss, - uuid, - kShardKeyPattern, - nullptr, - false, - epoch, - boost::none, - {std::move(chunk)}), - boost::none); - - if (!OperationShardingState::isOperationVersioned(opCtx)) { - const auto version = cm.getVersion(ShardId("0")); - BSONObjBuilder builder; - version.appendToCommand(&builder); - - auto& oss = OperationShardingState::get(opCtx); - oss.initializeClientRoutingVersionsFromCommand(kTestNss, builder.obj()); +class CollectionShardingRuntimeTest : public ShardServerTestFixture { +protected: + static CollectionMetadata makeShardedMetadata(OperationContext* opCtx, + UUID uuid = UUID::gen()) { + const OID epoch = OID::gen(); + auto range = ChunkRange(BSON(kShardKey << MINKEY), BSON(kShardKey << MAXKEY)); + auto chunk = + ChunkType(kTestNss, std::move(range), ChunkVersion(1, 0, epoch), ShardId("other")); + ChunkManager cm( + ShardId("0"), + DatabaseVersion(UUID::gen(), 1), + makeStandaloneRoutingTableHistory(RoutingTableHistory::makeNew(kTestNss, + uuid, + kShardKeyPattern, + nullptr, + false, + epoch, + boost::none, + {std::move(chunk)})), + boost::none); + + if (!OperationShardingState::isOperationVersioned(opCtx)) { + const auto version = cm.getVersion(ShardId("0")); + BSONObjBuilder builder; + version.appendToCommand(&builder); + + auto& oss = OperationShardingState::get(opCtx); + oss.initializeClientRoutingVersionsFromCommand(kTestNss, builder.obj()); + } + + return CollectionMetadata(std::move(cm), ShardId("0")); } - return CollectionMetadata(std::move(cm), ShardId("0")); -} +}; TEST_F(CollectionShardingRuntimeTest, GetCollectionDescriptionThrowsStaleConfigBeforeSetFilteringMetadataIsCalledAndNoOSSSet) { @@ -175,7 +180,7 @@ TEST_F(CollectionShardingRuntimeTest, /** * Fixture for when range deletion functionality is required in CollectionShardingRuntime tests. */ -class CollectionShardingRuntimeWithRangeDeleterTest : public ShardServerTestFixture { +class CollectionShardingRuntimeWithRangeDeleterTest : public CollectionShardingRuntimeTest { public: void setUp() override { ShardServerTestFixture::setUp(); |