diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-12-12 16:26:42 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-12-12 16:30:45 -0500 |
commit | 725f626aae2c2701ded3c0f97e7b5aa4c0b65979 (patch) | |
tree | 92335eee6a8f2fc39f64f563d46f61ad7715b9ea /src/mongo/s/balancer_policy_tests.cpp | |
parent | 4002de8b2265cffe10cce8e7a70e756ad0f01c49 (diff) | |
download | mongo-725f626aae2c2701ded3c0f97e7b5aa4c0b65979.tar.gz |
SERVER-7866 balancer shouldn't ignore jumbo chunks, just not try and move them
Diffstat (limited to 'src/mongo/s/balancer_policy_tests.cpp')
-rw-r--r-- | src/mongo/s/balancer_policy_tests.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mongo/s/balancer_policy_tests.cpp b/src/mongo/s/balancer_policy_tests.cpp index 1980bb89f23..df1d22d9b64 100644 --- a/src/mongo/s/balancer_policy_tests.cpp +++ b/src/mongo/s/balancer_policy_tests.cpp @@ -65,6 +65,42 @@ namespace mongo { ASSERT( c ); } + + TEST( BalancerPolicyTests , BalanceJumbo ) { + // 2 chunks and 0 chunk shards + ShardToChunksMap chunkMap; + vector<BSONObj> chunks; + chunks.push_back(BSON(ChunkFields::min(BSON("x" << BSON("$minKey"<<1))) << + ChunkFields::max(BSON("x" << 10)) << + ChunkFields::jumbo(true))); + chunks.push_back(BSON(ChunkFields::min(BSON("x" << 10)) << + ChunkFields::max(BSON("x" << 20)) << + ChunkFields::jumbo(true))); + chunks.push_back(BSON(ChunkFields::min(BSON("x" << 20)) << + ChunkFields::max(BSON("x" << 30)))); + chunks.push_back(BSON(ChunkFields::min(BSON("x" << 30)) << + ChunkFields::max(BSON("x" << 40)) << + ChunkFields::jumbo(true))); + chunks.push_back(BSON(ChunkFields::min(BSON("x" << 40)) << + ChunkFields::max(BSON("x" << BSON("$maxkey"<<1))) << + ChunkFields::jumbo(true))); + chunkMap["shard0"] = chunks; + chunks.clear(); + chunkMap["shard1"] = chunks; + + // no limits + ShardInfoMap info; + info["shard0"] = ShardInfo( 0, 2, false, false ); + info["shard1"] = ShardInfo( 0, 0, false, false ); + + MigrateInfo* c = NULL; + DistributionStatus status( info, chunkMap ); + c = BalancerPolicy::balance( "ns", status, 1 ); + ASSERT( c ); + ASSERT_EQUALS( 30, c->chunk.max["x"].numberInt() ); + } + + TEST( BalanceNormalTests , BalanceDrainingTest ) { // one normal, one draining // 2 chunks and 0 chunk shards |