summaryrefslogtreecommitdiff
path: root/jstests/sharding/bouncing_count.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-12-15 10:02:19 +0100
committerAntonin Kral <a.kral@bobek.cz>2011-12-15 10:02:46 +0100
commit0b48f8ada2acb0de830b23f8cefc8e3fea28d915 (patch)
treef7c2811269b6b53199412be2dd5ec02eea15d55d /jstests/sharding/bouncing_count.js
parent85f1cd56145b90a32b7ccdc750000deeed54fe22 (diff)
parentf0d9a01bccdaeb466c12c92057914bbfef59526c (diff)
downloadmongodb-0b48f8ada2acb0de830b23f8cefc8e3fea28d915.tar.gz
Merge branch 'upstream/2.0.2'
Diffstat (limited to 'jstests/sharding/bouncing_count.js')
-rw-r--r--jstests/sharding/bouncing_count.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/sharding/bouncing_count.js b/jstests/sharding/bouncing_count.js
new file mode 100644
index 0000000..d9630a4
--- /dev/null
+++ b/jstests/sharding/bouncing_count.js
@@ -0,0 +1,49 @@
+// Tests whether new sharding is detected on insert by mongos
+
+var st = new ShardingTest( name = "test", shards = 10, verbose = 0, mongos = 3 )
+
+var mongosA = st.s0
+var mongosB = st.s1
+var mongosC = st.s2
+
+var admin = mongosA.getDB("admin")
+var config = mongosA.getDB("config")
+
+var collA = mongosA.getCollection( "foo.bar" )
+var collB = mongosB.getCollection( "" + collA )
+var collC = mongosB.getCollection( "" + collA )
+
+admin.runCommand({ enableSharding : "" + collA.getDB() })
+admin.runCommand({ shardCollection : "" + collA, key : { _id : 1 } })
+
+var shards = config.shards.find().sort({ _id : 1 }).toArray()
+
+jsTestLog( "Splitting up the collection..." )
+
+// Split up the collection
+for( var i = 0; i < shards.length; i++ ){
+ printjson( admin.runCommand({ split : "" + collA, middle : { _id : i } }) )
+ printjson( admin.runCommand({ moveChunk : "" + collA, find : { _id : i }, to : shards[i]._id }) )
+}
+
+mongosB.getDB("admin").runCommand({ flushRouterConfig : 1 })
+mongosC.getDB("admin").runCommand({ flushRouterConfig : 1 })
+printjson( collB.count() )
+printjson( collC.count() )
+
+// Change up all the versions...
+for( var i = 0; i < shards.length; i++ ){
+ printjson( admin.runCommand({ moveChunk : "" + collA, find : { _id : i }, to : shards[ (i + 1) % shards.length ]._id }) )
+}
+
+// Make sure mongos A is up-to-date
+mongosA.getDB("admin").runCommand({ flushRouterConfig : 1 })
+
+config.printShardingStatus( true )
+
+jsTestLog( "Running count!" )
+
+printjson( collB.count() )
+printjson( collC.find().toArray() )
+
+st.stop() \ No newline at end of file