summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/chunktests.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2012-02-09 20:57:36 -0500
committerSpencer T Brody <spencer@10gen.com>2012-02-09 20:57:36 -0500
commit550c8441917b58b5f09367ee28765c5bf6c0ec0a (patch)
tree609c1501554bb5f6215793dab0dceb3b319389da /src/mongo/dbtests/chunktests.cpp
parent0e11df0b41db7802dc3565a7a666f6af1a9e4b93 (diff)
downloadmongo-550c8441917b58b5f09367ee28765c5bf6c0ec0a.tar.gz
Add unit test for SERVER-4745.
Diffstat (limited to 'src/mongo/dbtests/chunktests.cpp')
-rw-r--r--src/mongo/dbtests/chunktests.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mongo/dbtests/chunktests.cpp b/src/mongo/dbtests/chunktests.cpp
index 7943e38d078..822046a6a15 100644
--- a/src/mongo/dbtests/chunktests.cpp
+++ b/src/mongo/dbtests/chunktests.cpp
@@ -214,6 +214,27 @@ namespace ChunkTests {
virtual BSONArray expectedShardNames() const { return BSON_ARRAY( "1" << "2" << "3" ); }
};
+ class CompoundKeyBase : public Base {
+ virtual BSONObj shardKey() const {
+ return BSON( "a" << 1 << "b" << 1 );
+ }
+ virtual BSONArray splitPoints() const {
+ return BSON_ARRAY( BSON( "a" << 5 << "b" << 10 ) << BSON ( "a" << 5 << "b" << 20 ) );
+ }
+ };
+
+ class InMultiShard : public CompoundKeyBase {
+ virtual BSONObj query() const {
+ return BSON( "a" << BSON( "$in" << BSON_ARRAY( 0 << 5 << 10 ) ) <<
+ "b" << BSON( "$in" << BSON_ARRAY( 0 << 5 << 25 ) ) );
+ }
+ // If we were to send this query to just the shards it actually needed to hit, it would only hit shards 0 and 2
+ // Because of the optimization from SERVER-4745, however, we'll also hit shard 1.
+ virtual BSONArray expectedShardNames() const {
+ return BSON_ARRAY( "0" << "1" << "2" );
+ }
+ };
+
} // namespace ChunkManagerTests
class All : public Suite {
@@ -241,6 +262,7 @@ namespace ChunkTests {
add<ChunkManagerTests::EqualityThenUnsatisfiable>();
add<ChunkManagerTests::InequalityThenUnsatisfiable>();
add<ChunkManagerTests::OrEqualityUnsatisfiableInequality>();
+ add<ChunkManagerTests::InMultiShard>();
}
} myall;