diff options
Diffstat (limited to 'src/mongo/s/request_types')
10 files changed, 263 insertions, 503 deletions
diff --git a/src/mongo/s/request_types/add_shard_request_test.cpp b/src/mongo/s/request_types/add_shard_request_test.cpp index 87ae164f2a7..8b28a1921b5 100644 --- a/src/mongo/s/request_types/add_shard_request_test.cpp +++ b/src/mongo/s/request_types/add_shard_request_test.cpp @@ -66,9 +66,8 @@ TEST(AddShardRequest, ParseInternalFieldsInvalidConnectionString) { TEST(AddShardRequest, ParseInternalFieldsMissingMaxSize) { { - BSONObj obj = - BSON(AddShardRequest::mongosAddShard << kConnString << AddShardRequest::shardName - << kShardName); + BSONObj obj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::shardName << kShardName); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(obj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -81,9 +80,8 @@ TEST(AddShardRequest, ParseInternalFieldsMissingMaxSize) { } { - BSONObj obj = - BSON(AddShardRequest::configsvrAddShard << kConnString << AddShardRequest::shardName - << kShardName); + BSONObj obj = BSON(AddShardRequest::configsvrAddShard + << kConnString << AddShardRequest::shardName << kShardName); auto swAddShardRequest = AddShardRequest::parseFromConfigCommand(obj); @@ -99,9 +97,8 @@ TEST(AddShardRequest, ParseInternalFieldsMissingMaxSize) { TEST(AddShardRequest, ParseInternalFieldsMissingName) { { - BSONObj obj = - BSON(AddShardRequest::mongosAddShard << kConnString << AddShardRequest::maxSizeMB - << kMaxSizeMB); + BSONObj obj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(obj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -114,9 +111,8 @@ TEST(AddShardRequest, ParseInternalFieldsMissingName) { } { - BSONObj obj = - BSON(AddShardRequest::configsvrAddShard << kConnString << AddShardRequest::maxSizeMB - << kMaxSizeMB); + BSONObj obj = BSON(AddShardRequest::configsvrAddShard + << kConnString << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromConfigCommand(obj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -131,11 +127,9 @@ TEST(AddShardRequest, ParseInternalFieldsMissingName) { TEST(AddShardRequest, ParseInternalFieldsAllFieldsPresent) { { - BSONObj obj = - BSON(AddShardRequest::mongosAddShard << kConnString << AddShardRequest::shardName - << kShardName - << AddShardRequest::maxSizeMB - << kMaxSizeMB); + BSONObj obj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::shardName << kShardName + << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(obj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -149,11 +143,9 @@ TEST(AddShardRequest, ParseInternalFieldsAllFieldsPresent) { } { - BSONObj obj = - BSON(AddShardRequest::configsvrAddShard << kConnString << AddShardRequest::shardName - << kShardName - << AddShardRequest::maxSizeMB - << kMaxSizeMB); + BSONObj obj = BSON(AddShardRequest::configsvrAddShard + << kConnString << AddShardRequest::shardName << kShardName + << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromConfigCommand(obj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -170,10 +162,9 @@ TEST(AddShardRequest, ParseInternalFieldsAllFieldsPresent) { // Test converting a valid AddShardRequest to the internal config version of the command. TEST(AddShardRequest, ToCommandForConfig) { - BSONObj mongosCmdObj = BSON( - AddShardRequest::mongosAddShard << kConnString << AddShardRequest::shardName << kShardName - << AddShardRequest::maxSizeMB - << kMaxSizeMB); + BSONObj mongosCmdObj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::shardName << kShardName + << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(mongosCmdObj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -186,8 +177,8 @@ TEST(AddShardRequest, ToCommandForConfig) { } TEST(AddShardRequest, ToCommandForConfigMissingName) { - BSONObj mongosCmdObj = BSON( - AddShardRequest::mongosAddShard << kConnString << AddShardRequest::maxSizeMB << kMaxSizeMB); + BSONObj mongosCmdObj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::maxSizeMB << kMaxSizeMB); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(mongosCmdObj); ASSERT_OK(swAddShardRequest.getStatus()); @@ -200,8 +191,8 @@ TEST(AddShardRequest, ToCommandForConfigMissingName) { } TEST(AddShardRequest, ToCommandForConfigMissingMaxSize) { - BSONObj mongosCmdObj = BSON( - AddShardRequest::mongosAddShard << kConnString << AddShardRequest::shardName << kShardName); + BSONObj mongosCmdObj = BSON(AddShardRequest::mongosAddShard + << kConnString << AddShardRequest::shardName << kShardName); auto swAddShardRequest = AddShardRequest::parseFromMongosCommand(mongosCmdObj); ASSERT_OK(swAddShardRequest.getStatus()); diff --git a/src/mongo/s/request_types/add_shard_to_zone_request_test.cpp b/src/mongo/s/request_types/add_shard_to_zone_request_test.cpp index 277302c3c0c..7a9b2b8141e 100644 --- a/src/mongo/s/request_types/add_shard_to_zone_request_test.cpp +++ b/src/mongo/s/request_types/add_shard_to_zone_request_test.cpp @@ -92,8 +92,7 @@ TEST(AddShardToZoneRequest, WrongShardNameTypeErrors) { TEST(AddShardToZoneRequest, WrongZoneNameTypeErrors) { auto request = AddShardToZoneRequest::parseFromMongosCommand(BSON("addShardToZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } @@ -141,25 +140,23 @@ TEST(CfgAddShardToZoneRequest, MissingShardNameErrors) { } TEST(CfgAddShardToZoneRequest, WrongShardNameTypeErrors) { - auto request = AddShardToZoneRequest::parseFromConfigCommand( - BSON("_configsvrAddShardToZone" << 1234 << "zone" - << "z")); + auto request = AddShardToZoneRequest::parseFromConfigCommand(BSON("_configsvrAddShardToZone" + << 1234 << "zone" + << "z")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(CfgAddShardToZoneRequest, WrongZoneNameTypeErrors) { auto request = AddShardToZoneRequest::parseFromConfigCommand(BSON("_configsvrAddShardToZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(CfgAddShardToZoneRequest, CannotUseConfigToParseMongosCommand) { auto request = AddShardToZoneRequest::parseFromConfigCommand(BSON("addShardToZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } diff --git a/src/mongo/s/request_types/balance_chunk_request_test.cpp b/src/mongo/s/request_types/balance_chunk_request_test.cpp index f3f0a14b320..df15b79669d 100644 --- a/src/mongo/s/request_types/balance_chunk_request_test.cpp +++ b/src/mongo/s/request_types/balance_chunk_request_test.cpp @@ -45,18 +45,13 @@ using unittest::assertGet; TEST(BalanceChunkRequest, ParseFromConfigCommandNoSecondaryThrottle) { const ChunkVersion version(1, 0, OID::gen()); auto request = assertGet(BalanceChunkRequest::parseFromConfigCommand( - BSON("_configsvrMoveChunk" << 1 << "ns" - << "TestDB.TestColl" - << "min" - << BSON("a" << -100LL) - << "max" - << BSON("a" << 100LL) - << "shard" - << "TestShard0000" - << "lastmod" - << Date_t::fromMillisSinceEpoch(version.toLong()) - << "lastmodEpoch" - << version.epoch()))); + BSON("_configsvrMoveChunk" + << 1 << "ns" + << "TestDB.TestColl" + << "min" << BSON("a" << -100LL) << "max" << BSON("a" << 100LL) << "shard" + << "TestShard0000" + << "lastmod" << Date_t::fromMillisSinceEpoch(version.toLong()) << "lastmodEpoch" + << version.epoch()))); const auto& chunk = request.getChunk(); ASSERT_EQ("TestDB.TestColl", chunk.getNS().ns()); ASSERT_BSONOBJ_EQ(BSON("a" << -100LL), chunk.getMin()); @@ -72,21 +67,14 @@ TEST(BalanceChunkRequest, ParseFromConfigCommandNoSecondaryThrottle) { TEST(BalanceChunkRequest, ParseFromConfigCommandWithSecondaryThrottle) { const ChunkVersion version(1, 0, OID::gen()); auto request = assertGet(BalanceChunkRequest::parseFromConfigCommand( - BSON("_configsvrMoveChunk" << 1 << "ns" - << "TestDB.TestColl" - << "min" - << BSON("a" << -100LL) - << "max" - << BSON("a" << 100LL) - << "shard" - << "TestShard0000" - << "lastmod" - << Date_t::fromMillisSinceEpoch(version.toLong()) - << "lastmodEpoch" - << version.epoch() - << "secondaryThrottle" - << BSON("_secondaryThrottle" << true << "writeConcern" - << BSON("w" << 2))))); + BSON("_configsvrMoveChunk" + << 1 << "ns" + << "TestDB.TestColl" + << "min" << BSON("a" << -100LL) << "max" << BSON("a" << 100LL) << "shard" + << "TestShard0000" + << "lastmod" << Date_t::fromMillisSinceEpoch(version.toLong()) << "lastmodEpoch" + << version.epoch() << "secondaryThrottle" + << BSON("_secondaryThrottle" << true << "writeConcern" << BSON("w" << 2))))); const auto& chunk = request.getChunk(); ASSERT_EQ("TestDB.TestColl", chunk.getNS().ns()); ASSERT_BSONOBJ_EQ(BSON("a" << -100LL), chunk.getMin()); diff --git a/src/mongo/s/request_types/merge_chunk_request_test.cpp b/src/mongo/s/request_types/merge_chunk_request_test.cpp index 7a300c5e813..94a7bf68511 100644 --- a/src/mongo/s/request_types/merge_chunk_request_test.cpp +++ b/src/mongo/s/request_types/merge_chunk_request_test.cpp @@ -42,11 +42,8 @@ TEST(MergeChunkRequest, BasicValidConfigCommand) { auto request = assertGet(MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << "shard0000"))); ASSERT_EQ(NamespaceString("TestDB", "TestColl"), request.getNamespace()); ASSERT_EQ(OID("7fffffff0000000000000001"), request.getEpoch()); @@ -60,14 +57,10 @@ TEST(MergeChunkRequest, ConfigCommandtoBSON) { BSONObj serializedRequest = BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << "shard0000" - << "validAfter" - << Timestamp{100}); + << "validAfter" << Timestamp{100}); BSONObj writeConcernObj = BSON("writeConcern" << BSON("w" << "majority")); @@ -84,11 +77,10 @@ TEST(MergeChunkRequest, ConfigCommandtoBSON) { } TEST(MergeChunkRequest, MissingNameSpaceErrors) { - auto request = MergeChunkRequest::parseFromConfigCommand( - BSON("collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" - << "shard0000")); + auto request = MergeChunkRequest::parseFromConfigCommand(BSON( + "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } @@ -96,20 +88,18 @@ TEST(MergeChunkRequest, MissingCollEpochErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) + << "chunkBoundaries" << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(MergeChunkRequest, MissingChunkBoundariesErrors) { - auto request = MergeChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkMerge" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "shard" - << "shard0000")); + auto request = MergeChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkMerge" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } @@ -117,21 +107,17 @@ TEST(MergeChunkRequest, MissingShardNameErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)))); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(MergeChunkRequest, WrongNamespaceTypeErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( - BSON("_configsvrCommitChunkMerge" << 1234 << "collEpoch" << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) - << BSON("a" << 10)) - << "shard" - << "shard0000")); + BSON("_configsvrCommitChunkMerge" + << 1234 << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } @@ -139,37 +125,27 @@ TEST(MergeChunkRequest, WrongCollEpochTypeErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "collEpoch" - << 1234 - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" + << "collEpoch" << 1234 << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(MergeChunkRequest, WrongChunkBoundariesTypeErrors) { - auto request = MergeChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkMerge" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << 1234 - << "shard" - << "shard0000")); + auto request = MergeChunkRequest::parseFromConfigCommand(BSON( + "_configsvrCommitChunkMerge" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" << 1234 << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(MergeChunkRequest, WrongShardNameTypeErrors) { - auto request = MergeChunkRequest::parseFromConfigCommand( - BSON("_configsvrCommitChunkMerge" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" - << 1234)); + auto request = MergeChunkRequest::parseFromConfigCommand(BSON( + "_configsvrCommitChunkMerge" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } @@ -177,24 +153,19 @@ TEST(MergeChunkRequest, InvalidNamespaceErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) - << "shard" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 5) << BSON("a" << 10)) << "shard" << "shard0000")); ASSERT_EQ(ErrorCodes::InvalidNamespace, request.getStatus()); } TEST(MergeChunkRequest, EmptyChunkBoundariesErrors) { - auto request = MergeChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkMerge" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSONArray() - << "shard" - << "shard0000")); + auto request = MergeChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkMerge" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" << BSONArray() + << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::InvalidOptions, request.getStatus()); } @@ -202,11 +173,8 @@ TEST(MergeChunkRequest, TooFewChunkBoundariesErrors) { auto request = MergeChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkMerge" << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "chunkBoundaries" - << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 10)) - << "shard" + << "collEpoch" << OID("7fffffff0000000000000001") << "chunkBoundaries" + << BSON_ARRAY(BSON("a" << 1) << BSON("a" << 10)) << "shard" << "shard0000")); ASSERT_EQ(ErrorCodes::InvalidOptions, request.getStatus()); } diff --git a/src/mongo/s/request_types/migration_secondary_throttle_options_test.cpp b/src/mongo/s/request_types/migration_secondary_throttle_options_test.cpp index 49332950329..b295e3f0b3d 100644 --- a/src/mongo/s/request_types/migration_secondary_throttle_options_test.cpp +++ b/src/mongo/s/request_types/migration_secondary_throttle_options_test.cpp @@ -178,8 +178,9 @@ TEST(MigrationSecondaryThrottleOptions, ParseFailsDisabledInCommandBSONWriteConc TEST(MigrationSecondaryThrottleOptions, ParseFailsNotSpecifiedInCommandBSONWriteConcernSpecified) { auto status = MigrationSecondaryThrottleOptions::createFromCommand( - BSON("someOtherField" << 1 << "writeConcern" << BSON("w" - << "majority"))); + BSON("someOtherField" << 1 << "writeConcern" + << BSON("w" + << "majority"))); ASSERT_EQ(ErrorCodes::UnsupportedFormat, status.getStatus().code()); } diff --git a/src/mongo/s/request_types/remove_shard_from_zone_request_test.cpp b/src/mongo/s/request_types/remove_shard_from_zone_request_test.cpp index d8b6c94c61e..67981bd7f67 100644 --- a/src/mongo/s/request_types/remove_shard_from_zone_request_test.cpp +++ b/src/mongo/s/request_types/remove_shard_from_zone_request_test.cpp @@ -85,17 +85,16 @@ TEST(RemoveShardFromZoneRequest, MissingShardNameErrors) { } TEST(RemoveShardFromZoneRequest, WrongShardNameTypeErrors) { - auto request = RemoveShardFromZoneRequest::parseFromMongosCommand( - BSON("removeShardFromZone" << 1234 << "zone" - << "z")); + auto request = RemoveShardFromZoneRequest::parseFromMongosCommand(BSON("removeShardFromZone" + << 1234 << "zone" + << "z")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(RemoveShardFromZoneRequest, WrongZoneNameTypeErrors) { auto request = RemoveShardFromZoneRequest::parseFromMongosCommand(BSON("removeShardFromZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } @@ -155,16 +154,14 @@ TEST(CfgRemoveShardFromZoneRequest, WrongZoneNameTypeErrors) { auto request = RemoveShardFromZoneRequest::parseFromConfigCommand(BSON("_configsvrRemoveShardFromZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(CfgRemoveShardFromZoneRequest, CannotUseConfigToParseMongosCommand) { auto request = RemoveShardFromZoneRequest::parseFromConfigCommand(BSON("removeShardFromZone" << "a" - << "zone" - << 1234)); + << "zone" << 1234)); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } diff --git a/src/mongo/s/request_types/set_shard_version_request_test.cpp b/src/mongo/s/request_types/set_shard_version_request_test.cpp index fb1052cc48d..59003730f98 100644 --- a/src/mongo/s/request_types/set_shard_version_request_test.cpp +++ b/src/mongo/s/request_types/set_shard_version_request_test.cpp @@ -47,15 +47,12 @@ const ConnectionString shardCS = ConnectionString::forReplicaSet( "ShardRS", {HostAndPort{"shardHost1:12345"}, HostAndPort{"shardHost2:12345"}}); TEST(SetShardVersionRequest, ParseInitMissingAuthoritative) { - SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "" - << "init" - << true - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString()))); + SetShardVersionRequest request = assertGet( + SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" + << "" + << "init" << true << "shard" + << "TestShard" + << "shardHost" << shardCS.toString()))); ASSERT(request.isInit()); ASSERT(!request.isAuthoritative()); @@ -66,16 +63,12 @@ TEST(SetShardVersionRequest, ParseInitMissingAuthoritative) { TEST(SetShardVersionRequest, ParseInitWithAuthoritative) { SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "" - << "init" - << true - << "authoritative" - << true - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString()))); + assertGet(SetShardVersionRequest::parseFromBSON( + BSON("setShardVersion" + << "" + << "init" << true << "authoritative" << true << "shard" + << "TestShard" + << "shardHost" << shardCS.toString()))); ASSERT(request.isInit()); ASSERT(request.isAuthoritative()); @@ -86,18 +79,12 @@ TEST(SetShardVersionRequest, ParseInitWithAuthoritative) { TEST(SetShardVersionRequest, ParseInitNoConnectionVersioning) { SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "" - << "init" - << true - << "authoritative" - << true - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "noConnectionVersioning" - << true))); + assertGet(SetShardVersionRequest::parseFromBSON( + BSON("setShardVersion" + << "" + << "init" << true << "authoritative" << true << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "noConnectionVersioning" << true))); ASSERT(request.isInit()); ASSERT(request.isAuthoritative()); @@ -110,16 +97,13 @@ TEST(SetShardVersionRequest, ParseFull) { const ChunkVersion chunkVersion(1, 2, OID::gen()); SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "db.coll" - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch()))); + assertGet(SetShardVersionRequest::parseFromBSON( + BSON("setShardVersion" + << "db.coll" + << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch()))); ASSERT(!request.isInit()); ASSERT(!request.shouldForceRefresh()); @@ -137,18 +121,14 @@ TEST(SetShardVersionRequest, ParseFullWithAuthoritative) { const ChunkVersion chunkVersion(1, 2, OID::gen()); SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "db.coll" - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch() - << "authoritative" - << true))); + assertGet(SetShardVersionRequest::parseFromBSON( + BSON("setShardVersion" + << "db.coll" + << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch() + << "authoritative" << true))); ASSERT(!request.isInit()); ASSERT(!request.shouldForceRefresh()); @@ -166,18 +146,14 @@ TEST(SetShardVersionRequest, ParseFullNoConnectionVersioning) { const ChunkVersion chunkVersion(1, 2, OID::gen()); SetShardVersionRequest request = - assertGet(SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "db.coll" - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch() - << "noConnectionVersioning" - << true))); + assertGet(SetShardVersionRequest::parseFromBSON( + BSON("setShardVersion" + << "db.coll" + << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch() + << "noConnectionVersioning" << true))); ASSERT(!request.isInit()); ASSERT(!request.shouldForceRefresh()); @@ -194,16 +170,14 @@ TEST(SetShardVersionRequest, ParseFullNoConnectionVersioning) { TEST(SetShardVersionRequest, ParseFullNoNS) { const ChunkVersion chunkVersion(1, 2, OID::gen()); - auto ssvStatus = SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "" - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch())); + auto ssvStatus = + SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" + << "" + << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) + << "versionEpoch" << chunkVersion.epoch())); ASSERT_EQ(ErrorCodes::InvalidNamespace, ssvStatus.getStatus().code()); } @@ -211,16 +185,14 @@ TEST(SetShardVersionRequest, ParseFullNoNS) { TEST(SetShardVersionRequest, ParseFullNSContainsDBOnly) { const ChunkVersion chunkVersion(1, 2, OID::gen()); - auto ssvStatus = SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" - << "dbOnly" - << "shard" - << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch())); + auto ssvStatus = + SetShardVersionRequest::parseFromBSON(BSON("setShardVersion" + << "dbOnly" + << "shard" + << "TestShard" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) + << "versionEpoch" << chunkVersion.epoch())); ASSERT_EQ(ErrorCodes::InvalidNamespace, ssvStatus.getStatus().code()); } @@ -239,20 +211,10 @@ TEST(SetShardVersionRequest, ToSSVCommandInit) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "" - << "init" - << true - << "forceRefresh" - << false - << "authoritative" - << true - << "configdb" - << configCS.toString() - << "shard" + << "init" << true << "forceRefresh" << false << "authoritative" << true + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "maxTimeMS" - << 30000)); + << "shardHost" << shardCS.toString() << "maxTimeMS" << 30000)); } TEST(SetShardVersionRequest, ToSSVCommandFull) { @@ -273,21 +235,11 @@ TEST(SetShardVersionRequest, ToSSVCommandFull) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "init" - << false - << "forceRefresh" - << false - << "authoritative" - << false - << "configdb" - << configCS.toString() - << "shard" + << "init" << false << "forceRefresh" << false << "authoritative" << false + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } @@ -309,21 +261,11 @@ TEST(SetShardVersionRequest, ToSSVCommandFullAuthoritative) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "init" - << false - << "forceRefresh" - << false - << "authoritative" - << true - << "configdb" - << configCS.toString() - << "shard" + << "init" << false << "forceRefresh" << false << "authoritative" << true + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } @@ -351,21 +293,11 @@ TEST(SetShardVersionRequest, ToSSVCommandFullForceRefresh) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "init" - << false - << "forceRefresh" - << true - << "authoritative" - << false - << "configdb" - << configCS.toString() - << "shard" + << "init" << false << "forceRefresh" << true << "authoritative" << false + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } @@ -387,24 +319,12 @@ TEST(SetShardVersionRequest, ToSSVCommandFullNoConnectionVersioning) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "init" - << false - << "forceRefresh" - << false - << "authoritative" - << true - << "configdb" - << configCS.toString() - << "shard" + << "init" << false << "forceRefresh" << false << "authoritative" << true + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch() - << "noConnectionVersioning" - << true)); + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" + << chunkVersion.epoch() << "noConnectionVersioning" << true)); } TEST(SetShardVersionRequest, ToSSVCommandFullNoConnectionVersioningForceRefresh) { @@ -431,24 +351,12 @@ TEST(SetShardVersionRequest, ToSSVCommandFullNoConnectionVersioningForceRefresh) ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "init" - << false - << "forceRefresh" - << true - << "authoritative" - << false - << "configdb" - << configCS.toString() - << "shard" + << "init" << false << "forceRefresh" << true << "authoritative" << false + << "configdb" << configCS.toString() << "shard" << "TestShard" - << "shardHost" - << shardCS.toString() - << "version" - << Timestamp(chunkVersion.toLong()) - << "versionEpoch" - << chunkVersion.epoch() - << "noConnectionVersioning" - << true)); + << "shardHost" << shardCS.toString() << "version" + << Timestamp(chunkVersion.toLong()) << "versionEpoch" + << chunkVersion.epoch() << "noConnectionVersioning" << true)); } diff --git a/src/mongo/s/request_types/split_chunk_request_test.cpp b/src/mongo/s/request_types/split_chunk_request_test.cpp index d73f6c96591..1727c3aa792 100644 --- a/src/mongo/s/request_types/split_chunk_request_test.cpp +++ b/src/mongo/s/request_types/split_chunk_request_test.cpp @@ -41,19 +41,12 @@ namespace { using unittest::assertGet; TEST(SplitChunkRequest, BasicValidConfigCommand) { - auto request = - assertGet(SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000"))); + auto request = assertGet(SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000"))); ASSERT_EQ(NamespaceString("TestDB", "TestColl"), request.getNamespace()); ASSERT_EQ(OID("7fffffff0000000000000001"), request.getEpoch()); ASSERT(ChunkRange(BSON("a" << 1), BSON("a" << 10)) == request.getChunkRange()); @@ -65,14 +58,8 @@ TEST(SplitChunkRequest, ValidWithMultipleSplits) { auto request = assertGet(SplitChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkSplit" << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5) << BSON("a" << 7)) + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5) << BSON("a" << 7)) << "shard" << "shard0000"))); ASSERT_EQ(NamespaceString("TestDB", "TestColl"), request.getNamespace()); @@ -84,18 +71,12 @@ TEST(SplitChunkRequest, ValidWithMultipleSplits) { } TEST(SplitChunkRequest, ConfigCommandtoBSON) { - BSONObj serializedRequest = BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000"); + BSONObj serializedRequest = + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000"); BSONObj writeConcernObj = BSON("writeConcern" << BSON("w" << "majority")); @@ -112,197 +93,129 @@ TEST(SplitChunkRequest, ConfigCommandtoBSON) { } TEST(SplitChunkRequest, MissingNamespaceErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand( - BSON("collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand(BSON( + "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(SplitChunkRequest, MissingCollEpochErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "min" << BSON("a" << 1) << "max" << BSON("a" << 10) << "splitPoints" + << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(SplitChunkRequest, MissingChunkToSplitErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "max" << BSON("a" << 10) + << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(SplitChunkRequest, MissingSplitPointErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(SplitChunkRequest, MissingShardNameErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)))); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)))); ASSERT_EQ(ErrorCodes::NoSuchKey, request.getStatus()); } TEST(SplitChunkRequest, WrongNamespaceTypeErrors) { auto request = SplitChunkRequest::parseFromConfigCommand( BSON("_configsvrCommitChunkSplit" << 1234 << "collEpoch" << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" + << "min" << BSON("a" << 1) << "max" << BSON("a" << 10) + << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(SplitChunkRequest, WrongCollEpochTypeErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << 1234 - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << 1234 << "min" << BSON("a" << 1) << "max" << BSON("a" << 10) + << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(SplitChunkRequest, WrongChunkToSplitTypeErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << 1234 - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << 1234 << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(SplitChunkRequest, WrongSplitPointTypeErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << 1234 - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << 1234 << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(SplitChunkRequest, WrongShardNameTypeErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << 1234)); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" << 1234)); ASSERT_EQ(ErrorCodes::TypeMismatch, request.getStatus()); } TEST(SplitChunkRequest, InvalidNamespaceErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::InvalidNamespace, request.getStatus()); } TEST(SplitChunkRequest, EmptyChunkToSplitErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSONObj() - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSON_ARRAY(BSON("a" << 5)) - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSONObj() << "max" + << BSON("a" << 10) << "splitPoints" << BSON_ARRAY(BSON("a" << 5)) << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::BadValue, request.getStatus()); } TEST(SplitChunkRequest, EmptySplitPointsErrors) { - auto request = SplitChunkRequest::parseFromConfigCommand(BSON("_configsvrCommitChunkSplit" - << "TestDB.TestColl" - << "collEpoch" - << OID("7fffffff0000000000000001") - << "min" - << BSON("a" << 1) - << "max" - << BSON("a" << 10) - << "splitPoints" - << BSONArray() - << "shard" - << "shard0000")); + auto request = SplitChunkRequest::parseFromConfigCommand( + BSON("_configsvrCommitChunkSplit" + << "TestDB.TestColl" + << "collEpoch" << OID("7fffffff0000000000000001") << "min" << BSON("a" << 1) << "max" + << BSON("a" << 10) << "splitPoints" << BSONArray() << "shard" + << "shard0000")); ASSERT_EQ(ErrorCodes::InvalidOptions, request.getStatus()); } -} +} // namespace } // namespace mongo diff --git a/src/mongo/s/request_types/split_chunk_request_type.cpp b/src/mongo/s/request_types/split_chunk_request_type.cpp index 8993efac965..6773e413197 100644 --- a/src/mongo/s/request_types/split_chunk_request_type.cpp +++ b/src/mongo/s/request_types/split_chunk_request_type.cpp @@ -161,8 +161,8 @@ const string& SplitChunkRequest::getShardName() const { Status SplitChunkRequest::_validate() { if (!getNamespace().isValid()) { return Status(ErrorCodes::InvalidNamespace, - str::stream() << "invalid namespace '" << _nss.ns() - << "' specified for request"); + str::stream() + << "invalid namespace '" << _nss.ns() << "' specified for request"); } if (getSplitPoints().empty()) { diff --git a/src/mongo/s/request_types/update_zone_key_range_request_type.cpp b/src/mongo/s/request_types/update_zone_key_range_request_type.cpp index 350489aa242..cfbce859483 100644 --- a/src/mongo/s/request_types/update_zone_key_range_request_type.cpp +++ b/src/mongo/s/request_types/update_zone_key_range_request_type.cpp @@ -107,10 +107,7 @@ StatusWith<UpdateZoneKeyRangeRequest> UpdateZoneKeyRangeRequest::_parseFromComma } else { return {ErrorCodes::TypeMismatch, str::stream() << "\"" << kZoneName << "\" had the wrong type. Expected " - << typeName(String) - << " or " - << typeName(jstNULL) - << ", found " + << typeName(String) << " or " << typeName(jstNULL) << ", found " << typeName(zoneElem.type())}; } |