summaryrefslogtreecommitdiff
path: root/jstests/sharding/coll_epoch_test2.js
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-06-04 20:41:38 -0400
committerGreg Studer <greg@10gen.com>2012-06-08 16:12:17 -0400
commite14233f0213fd446381bbccdbf9b9c63b485c1c1 (patch)
tree36ed540cfa6c4c7e87061df989c29658482afb74 /jstests/sharding/coll_epoch_test2.js
parent72853a054d26271cc10249a84f94aa5c6697c34f (diff)
downloadmongo-e14233f0213fd446381bbccdbf9b9c63b485c1c1.tar.gz
SERVER-4262 better commenting of coll_epoch_test1.js
Diffstat (limited to 'jstests/sharding/coll_epoch_test2.js')
-rw-r--r--jstests/sharding/coll_epoch_test2.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/jstests/sharding/coll_epoch_test2.js b/jstests/sharding/coll_epoch_test2.js
index 072633941f6..80895292e7b 100644
--- a/jstests/sharding/coll_epoch_test2.js
+++ b/jstests/sharding/coll_epoch_test2.js
@@ -1,4 +1,8 @@
// Tests that resharding a collection is detected correctly by all operation types
+//
+// The idea here is that a collection may be resharded / unsharded at any point, and any type of
+// operation on a mongos may be active when it happens. All operations should handle gracefully.
+//
var st = new ShardingTest({ shards : 2, mongos : 5, verbose : 1, separateConfig : 1 })
// Stop balancer, it'll interfere
@@ -21,6 +25,9 @@ config.shards.find().forEach( function( doc ){
shards[ doc._id ] = new Mongo( doc.host )
})
+//
+// Set up a sharded collection
+//
jsTest.log( "Enabling sharding for the first time..." )
@@ -44,6 +51,10 @@ printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 0 },
st.printShardingStatus()
+//
+// Force all mongoses to load the current status of the cluster
+//
+
jsTest.log( "Loading this status in all mongoses..." )
for( var i = 0; i < st._mongos.length; i++ ){
@@ -51,6 +62,11 @@ for( var i = 0; i < st._mongos.length; i++ ){
assert.neq( null, st._mongos[i].getCollection( coll + "" ).findOne() )
}
+//
+// Drop and recreate a new sharded collection in the same namespace, where the shard and collection
+// versions are the same, but the split is at a different point.
+//
+
jsTest.log( "Rebuilding sharded collection with different split..." )
coll.drop()
@@ -65,6 +81,10 @@ printjson( admin.runCommand({ split : coll + "", middle : { _id : 200 } }) )
printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 200 },
to : getOtherShard( config.databases.findOne({ _id : coll.getDB() + "" }).primary ) }) )
+//
+// Make sure all operations on mongoses aren't tricked by the change
+//
+
jsTest.log( "Checking other mongoses for detection of change..." )
jsTest.log( "Checking find..." )
@@ -87,9 +107,6 @@ jsTest.log( "Checking remove..." )
// Ensure that removing an element finds the right shard, verified by the mongos doing the sharding
removeMongos.getCollection( coll + "" ).remove({ _id : 2 })
assert.eq( null, removeMongos.getDB( coll.getDB() + "" ).getLastError() )
-
-sleep( 4000 )
-
assert.eq( null, coll.findOne({ _id : 2 }) )
coll.drop()