Skip to content

Commit

Permalink
base class for unsatisfiable queries in chunk test
Browse files Browse the repository at this point in the history
  • Loading branch information
astaple committed Feb 7, 2012
1 parent 96c7489 commit db19b88
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/mongo/dbtests/chunktests.cpp
Expand Up @@ -175,34 +175,35 @@ namespace ChunkTests {
}
};

/**
* SERVER-4554 For now the first shard is returned for unsatisfiable queries, as some
* clients of getShardsForQuery() expect at least one shard.
*/
BSONArray unsatisfiableShardNames() { return BSON_ARRAY( "0" ) /* BSONArray() */; }
template<class BASE>
class Unsatisfiable : public BASE {
/**
* SERVER-4554 For now the first shard is returned for unsatisfiable queries, as some
* clients of getShardsForQuery() expect at least one shard.
*/
virtual BSONArray expectedShardNames() const {
return BSON_ARRAY( "0" ) /* BSONArray() */;
}
};

class UnsatisfiableRangeSingleShard : public Base {
class UnsatisfiableRangeSingleShard : public Unsatisfiable<Base> {
virtual BSONObj query() const { return BSON( "a" << GT << "x" << LT << "x" ); }
virtual BSONArray expectedShardNames() const { return unsatisfiableShardNames(); }
};

class UnsatisfiableRangeMultiShard : public MultiShardBase {
class UnsatisfiableRangeMultiShard : public Unsatisfiable<MultiShardBase> {
virtual BSONObj query() const { return BSON( "a" << GT << "x" << LT << "x" ); }
virtual BSONArray expectedShardNames() const { return unsatisfiableShardNames(); }
};

class EqualityThenUnsatisfiable : public Base {
class EqualityThenUnsatisfiable : public Unsatisfiable<Base> {
virtual BSONObj shardKey() const { return BSON( "a" << 1 << "b" << 1 ); }
virtual BSONObj query() const { return BSON( "a" << 1 << "b" << GT << 4 << LT << 4 ); }
virtual BSONArray expectedShardNames() const { return unsatisfiableShardNames(); }
};

class InequalityThenUnsatisfiable : public Base {
class InequalityThenUnsatisfiable : public Unsatisfiable<Base> {
virtual BSONObj shardKey() const { return BSON( "a" << 1 << "b" << 1 ); }
virtual BSONObj query() const {
return BSON( "a" << GT << 1 << "b" << GT << 4 << LT << 4 );
}
virtual BSONArray expectedShardNames() const { return unsatisfiableShardNames(); }
};

class OrEqualityUnsatisfiableInequality : public MultiShardBase {
Expand Down

0 comments on commit db19b88

Please sign in to comment.