void run() { extractkeytest(); ShardKeyPattern k( BSON( "key" << 1 ) ); BSONObj min = k.globalMin(); // cout << min.jsonString(TenGen) << endl; BSONObj max = k.globalMax(); BSONObj k1 = BSON( "key" << 5 ); verify( min < max ); verify( min < k.extractKeyFromQueryOrDoc( k1 ) ); verify( max > min ); hasshardkeytest(); verify( k.hasShardKey( k1 ) ); verify( ! k.hasShardKey( BSON( "key2" << 1 ) ) ); BSONObj a = k1; BSONObj b = BSON( "key" << 999 ); verify( k.extractKeyFromQueryOrDoc( a ) < k.extractKeyFromQueryOrDoc( b ) ); // add middle multitype tests uniqueIndexCompatibleTest(); LOG(1) << "shardKeyTest passed" << endl; }
void run(){ extractkeytest(); ShardKeyPattern k( BSON( "key" << 1 ) ); BSONObj min = k.globalMin(); // cout << min.jsonString(TenGen) << endl; BSONObj max = k.globalMax(); BSONObj k1 = BSON( "key" << 5 ); assert( k.compare( min , max ) < 0 ); assert( k.compare( min , k1 ) < 0 ); assert( k.compare( max , min ) > 0 ); assert( k.compare( min , min ) == 0 ); hasshardkeytest(); assert( k.hasShardKey( k1 ) ); assert( ! k.hasShardKey( BSON( "key2" << 1 ) ) ); BSONObj a = k1; BSONObj b = BSON( "key" << 999 ); assert( k.compare(a,b) < 0 ); testIsPrefixOf(); // add middle multitype tests log(1) << "shardKeyTest passed" << endl; }