public class ShardedReplicaSetsAcceptanceTest extends BasicAcceptanceTestCases
These are not meant to be exhaustive tests of the driver but instead attempt to demonstrate that interactions with the MongoDB processes work.
BasicAcceptanceTestCases.DocumentCallback
GEO_TEST_COLLECTION_NAME, GRIDFS_COLLECTION_ROOT_NAME, LARGE_COLLECTION_COUNT, myCollection, myConfig, myDb, myGeoCollection, myGeoSphereCollection, myMongo, myRandom, ourUniqueId, SMALL_COLLECTION_COUNT, TEST_COLLECTION_NAME, TEST_DB_NAME
ADMIN_USER_NAME, DEFAULT_PORT, ourClusterTestSupport, PASSWORD, USER_DB, USER_NAME
Constructor and Description |
---|
ShardedReplicaSetsAcceptanceTest() |
Modifier and Type | Method and Description |
---|---|
void |
connect()
Sets up to create a connection to MongoDB.
|
protected int |
countPrimaryCommands()
Returns the number of commands seen on secondaries.
|
protected int |
countSecondaryCommands()
Returns the number of commands seen on secondaries.
|
protected MongoCollection |
getGeoCollection()
Returns a collection with a geospatial 2D index on the 'p' field.
|
protected boolean |
isReplicaSetConfiguration()
Returns true when running against a replica set configuration (may be
shards of replica sets.
|
protected boolean |
isShardedConfiguration()
Returns true when running against a sharded configuration.
|
static void |
startServer()
Starts the sharded server before the tests.
|
static void |
stopServer()
Stops the servers running in a sharded mode.
|
void |
testAggregationOnSecondaries()
Test that a aggregate command for a secondary runs on the secondary.
|
void |
testCountOnSecondaries()
Verifies counting the number of documents in the collection.
|
void |
testDistinctOnSecondaries()
Verifies running a distinct command.
|
void |
testExplain()
Verifies the ability to get a query plan via explain.
|
void |
testGroupBy()
Verifies the function of a GroupBy command.
|
void |
testGroupByOnSecondaries()
Verifies the function of a GroupBy command.
|
void |
testMapReduceOnSecondaries()
Verifies the function of MapReduce via a sample Map/Reduce
|
void |
testQueryWithNearDoubleDouble()
Test method for
ConditionBuilder.near(double, double) . |
void |
testQueryWithNearDoubleDoubleDouble()
Test method for
ConditionBuilder.near(double, double, double) . |
void |
testQueryWithNearIntInt()
Test method for
ConditionBuilder.near(int, int) . |
void |
testQueryWithNearIntIntInt()
Test method for
ConditionBuilder.near(int, int, int) . |
void |
testQueryWithNearLongLong()
Test method for
ConditionBuilder.near(long, long) . |
void |
testQueryWithNearLongLongLong()
Test method for
ConditionBuilder.near(long, long, long) . |
void |
testQueryWithNearSphereDoubleDouble()
Test method for
ConditionBuilder.nearSphere(double, double) . |
void |
testQueryWithNearSphereDoubleDoubleDouble()
Test method for
ConditionBuilder.nearSphere(double, double, double) . |
void |
testQueryWithNearSphereIntInt()
Test method for
ConditionBuilder.nearSphere(int, int) . |
void |
testQueryWithNearSphereIntIntInt()
Test method for
ConditionBuilder.nearSphere(int, int, int) . |
void |
testQueryWithNearSphereLongLong()
Test method for
ConditionBuilder.nearSphere(long, long) . |
void |
testQueryWithNearSphereLongLongLong()
Test method for
ConditionBuilder.nearSphere(long, long, long) . |
buildLargeCollection, createAddress, disableBalancer, disconnect, distance, fatal, getGeoSphereCollection, largeCollection, shardCollection, shardCollection, testAggregate, testAggregateCursor, testAggregateExplain, testAggregateStream, testAggregateTimeout, testAggregateWithGeoNear, testBatchedOperations, testBatchedWriteReordered, testBatchedWriteSerialized, testBatchedWriteSerializedAndStop, testCollectionStats, testCount, testCountDocumentToLarge, testCountTimeout, testCreateCappedCollection, testCreateCollection, testCreateIndex, testDatabaseStats, testDelete, testDeleteDocumentToLarge, testDistinct, testDistinctTimeout, testDropCollection, testDropDatabase, testDropIndex, testFindAndModify, testFindAndModifyTimeout, testFindAndModifyWithNonExistantDocumentAndNoUpsert, testFindAndModifyWithUpsert, testFindOneWithSubsetOfFields, testFindTimeout, testFindWithComment, testFindWithCommentInProfile, testFindWithSubsetOfFields, testGridFs, testGridFsFsck, testGridFsVerify, testGroupByTimeout, testInsertAlreadyExists, testInsertAndFindOne, testInsertDocumentToLarge, testIteratorAsync, testIteratorAsyncRead, testJournalDurabilityThrows, testListCollections, testListDatabases, testMapReduce, testMapReduceTimeout, testMultiFetchIterator, testMultiFetchIteratorWithLimit, testMultiFetchIteratorWithLimitRestart, testParallelScan, testParallelScanOnSecondary, testProfilingStatus, testQueryDocumentToLarge, testQueryWithAll, testQueryWithAnd, testQueryWithElementMatches, testQueryWithEqualsBoolean, testQueryWithEqualsByteArray, testQueryWithEqualsByteByteArray, testQueryWithEqualsDocumentAssignable, testQueryWithEqualsDoubleCloseToInteger, testQueryWithEqualsDoubleNotCloseToInt, testQueryWithEqualsInt, testQueryWithEqualsJavaScriptString, testQueryWithEqualsJavaScriptStringDocument, testQueryWithEqualsLong, testQueryWithEqualsMaxKey, testQueryWithEqualsMinKey, testQueryWithEqualsMongoTimestamp, testQueryWithEqualsMongoTimestampFailsWhenEncountersATimestamp, testQueryWithEqualsNull, testQueryWithEqualsObjectId, testQueryWithEqualsPattern, testQueryWithEqualsString, testQueryWithEqualsSymbol, testQueryWithEqualsTimestamp, testQueryWithExists, testQueryWithGeoWithinDocumentAssignable, testQueryWithGeoWithinUniqueDocsFalse, testQueryWithGeoWithinWithMultiPointField, testQueryWithGreaterThanByteArray, testQueryWithGreaterThanByteByteArray, testQueryWithGreaterThanDouble, testQueryWithGreaterThanInt, testQueryWithGreaterThanLong, testQueryWithGreaterThanMongoTimestamp, testQueryWithGreaterThanObjectId, testQueryWithGreaterThanOrEqualToByteArray, testQueryWithGreaterThanOrEqualToByteByteArray, testQueryWithGreaterThanOrEqualToDouble, testQueryWithGreaterThanOrEqualToInt, testQueryWithGreaterThanOrEqualToLong, testQueryWithGreaterThanOrEqualToMongoTimestamp, testQueryWithGreaterThanOrEqualToObjectId, testQueryWithGreaterThanOrEqualToString, testQueryWithGreaterThanOrEqualToSymbol, testQueryWithGreaterThanOrEqualToTimestamp, testQueryWithGreaterThanString, testQueryWithGreaterThanSymbol, testQueryWithGreaterThanTimestamp, testQueryWithIn, testQueryWithInstanceOf, testQueryWithIntersectsDocumentAssignable, testQueryWithLessThanByteArray, testQueryWithLessThanByteByteArray, testQueryWithLessThanDouble, testQueryWithLessThanInt, testQueryWithLessThanLong, testQueryWithLessThanMongoTimestamp, testQueryWithLessThanObjectId, testQueryWithLessThanOrEqualToByteArray, testQueryWithLessThanOrEqualToByteByteArray, testQueryWithLessThanOrEqualToDouble, testQueryWithLessThanOrEqualToInt, testQueryWithLessThanOrEqualToLong, testQueryWithLessThanOrEqualToMongoTimestamp, testQueryWithLessThanOrEqualToObjectId, testQueryWithLessThanOrEqualToString, testQueryWithLessThanOrEqualToSymbol, testQueryWithLessThanOrEqualToTimestamp, testQueryWithLessThanString, testQueryWithLessThanSymbol, testQueryWithLessThanTimestamp, testQueryWithMatches, testQueryWithModWithInt, testQueryWithModWithLong, testQueryWithNearDocumentAssignable, testQueryWithNearDocumentAssignableDouble, testQueryWithNearSphereDocumentAssignable, testQueryWithNearSphereDocumentAssignableDouble, testQueryWithNotEqualToBoolean, testQueryWithNotEqualToByteArray, testQueryWithNotEqualToByteByteArray, testQueryWithNotEqualToDocumentAssignable, testQueryWithNotEqualToDouble, testQueryWithNotEqualToInt, testQueryWithNotEqualToJavaScriptString, testQueryWithNotEqualToJavaScriptStringDocument, testQueryWithNotEqualToLong, testQueryWithNotEqualToMaxKey, testQueryWithNotEqualToMinKey, testQueryWithNotEqualToMongoTimestamp, testQueryWithNotEqualToNull, testQueryWithNotEqualToObjectId, testQueryWithNotEqualToPattern, testQueryWithNotEqualToString, testQueryWithNotEqualToSymbol, testQueryWithNotEqualToTimestamp, testQueryWithNotIn, testQueryWithSize, testQueryWithWhere, testQueryWithWithinBooleanPoint2DPoint2DPoint2DPoint2DArray, testQueryWithWithinDocumentAssignable, testQueryWithWithinDocumentAssignableBoolean, testQueryWithWithinDoubleDoubleDouble, testQueryWithWithinDoubleDoubleDoubleBoolean, testQueryWithWithinDoubleDoubleDoubleDouble, testQueryWithWithinDoubleDoubleDoubleDoubleBoolean, testQueryWithWithinIntIntInt, testQueryWithWithinIntIntIntBoolean, testQueryWithWithinIntIntIntInt, testQueryWithWithinIntIntIntIntBoolean, testQueryWithWithinLongLongLong, testQueryWithWithinLongLongLongBoolean, testQueryWithWithinLongLongLongLong, testQueryWithWithinLongLongLongLongBoolean, testQueryWithWithinOnSphereDoubleDoubleDouble, testQueryWithWithinOnSphereDoubleDoubleDoubleBoolean, testQueryWithWithinOnSphereIntIntInt, testQueryWithWithinOnSphereIntIntIntBoolean, testQueryWithWithinOnSphereLongLongLong, testQueryWithWithinOnSphereLongLongLongBoolean, testQueryWithWithinOnSphereWrapDoesNotWork, testQueryWithWithinPoint2DPoint2DPoint2DPoint2DArray, testRestartWithBadCursorIdFails, testSaveWithId, testSaveWithoutId, testStreamingFind, testStreamingFindLegacy, testTextSearch, testUpdate, testUpdateDocumentToLarge, testUpdateDurabilityFails, testUpdateOptions, testUpdateQueryToLarge, testUpdateWithSetAndUnset, testValidate
repairReplicaSet, startAuthenticated, startReplicaSet, startSharded, startShardedReplicaSets, startStandAlone, stopReplicaSet, stopSharded, stopShardedReplicaSets, stopStandAlone
public static void startServer()
public static void stopServer()
public void connect()
connect
in class BasicAcceptanceTestCases
public void testAggregationOnSecondaries()
public void testCountOnSecondaries()
public void testDistinctOnSecondaries()
db.addresses.insert({"zip-code": 10010}) db.addresses.insert({"zip-code": 10010}) db.addresses.insert({"zip-code": 99701}) db.addresses.distinct("zip-code"); [ 10010, 99701 ]
public void testExplain()
Overridden to adjust the expectations for the command due to delta's in responses for sharded collections.
testExplain
in class BasicAcceptanceTestCases
public void testGroupBy()
{ domain: "www.mongodb.org" , invoked_at: {d:"2009-11-03", t:"17:14:05"} , response_time: 0.05 , http_action: "GET /display/DOCS/Aggregate" } db.test.group( { cond: {"invoked_at.d": {$gte: "2009-11", $lt: "2009-12"}} , key: {http_action: true} , initial: {count: 0, total_time:0} , reduce: function(doc, out){ out.count++; out.total_time+=doc.response_time } , finalize: function(out){ out.avg_time = out.total_time / out.count } } ); [ { "http_action" : "GET /display/DOCS/Aggregate", "count" : 1, "total_time" : 0.05, "avg_time" : 0.05 } ]
Overridden to adjust the expectations for the command to fail due to the group command not being supported on sharded collections.
testGroupBy
in class BasicAcceptanceTestCases
public void testGroupByOnSecondaries()
{ domain: "www.mongodb.org" , invoked_at: {d:"2009-11-03", t:"17:14:05"} , response_time: 0.05 , http_action: "GET /display/DOCS/Aggregate" } db.test.group( { cond: {"invoked_at.d": {$gte: "2009-11", $lt: "2009-12"}} , key: {http_action: true} , initial: {count: 0, total_time:0} , reduce: function(doc, out){ out.count++; out.total_time+=doc.response_time } , finalize: function(out){ out.avg_time = out.total_time / out.count } } ); [ { "http_action" : "GET /display/DOCS/Aggregate", "count" : 1, "total_time" : 0.05, "avg_time" : 0.05 } ]
public void testMapReduceOnSecondaries()
> db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); > db.things.insert( { _id : 2, tags : ['cat'] } ); > db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); > db.things.insert( { _id : 4, tags : [] } ); > // map function > m = function(){ ... this.tags.forEach( ... function(z){ ... emit( z , { count : 1 } ); ... } ... ); ...}; > // reduce function > r = function( key , values ){ ... var total = 0; ... for ( var i=0; i
res = db.things.mapReduce(m, r, { out : "inline" } ); > res { "result" : "myoutput", "timeMillis" : 12, "counts" : { "input" : 4, "emit" : 6, "output" : 3 }, "ok" : 1, } > db.myoutput.find() {"_id" : "cat" , "value" : {"count" : 3}} {"_id" : "dog" , "value" : {"count" : 2}} {"_id" : "mouse" , "value" : {"count" : 1}}
public void testQueryWithNearDoubleDouble()
ConditionBuilder.near(double, double)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearDoubleDouble
in class BasicAcceptanceTestCases
public void testQueryWithNearDoubleDoubleDouble()
ConditionBuilder.near(double, double, double)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearDoubleDoubleDouble
in class BasicAcceptanceTestCases
public void testQueryWithNearIntInt()
ConditionBuilder.near(int, int)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearIntInt
in class BasicAcceptanceTestCases
public void testQueryWithNearIntIntInt()
ConditionBuilder.near(int, int, int)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearIntIntInt
in class BasicAcceptanceTestCases
public void testQueryWithNearLongLong()
ConditionBuilder.near(long, long)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearLongLong
in class BasicAcceptanceTestCases
public void testQueryWithNearLongLongLong()
ConditionBuilder.near(long, long, long)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearLongLongLong
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereDoubleDouble()
ConditionBuilder.nearSphere(double, double)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereDoubleDouble
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereDoubleDoubleDouble()
ConditionBuilder.nearSphere(double, double, double)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereDoubleDoubleDouble
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereIntInt()
ConditionBuilder.nearSphere(int, int)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereIntInt
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereIntIntInt()
ConditionBuilder.nearSphere(int, int, int)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereIntIntInt
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereLongLong()
ConditionBuilder.nearSphere(long, long)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereLongLong
in class BasicAcceptanceTestCases
public void testQueryWithNearSphereLongLongLong()
ConditionBuilder.nearSphere(long, long, long)
.
Overridden to expect the query to fail on the sharded collection.
testQueryWithNearSphereLongLongLong
in class BasicAcceptanceTestCases
protected int countPrimaryCommands()
protected int countSecondaryCommands()
protected MongoCollection getGeoCollection()
getGeoCollection
in class BasicAcceptanceTestCases
protected boolean isReplicaSetConfiguration()
Overridden to return true.
isReplicaSetConfiguration
in class BasicAcceptanceTestCases
protected boolean isShardedConfiguration()
Overridden to return true.
isShardedConfiguration
in class BasicAcceptanceTestCases
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.