summaryrefslogtreecommitdiff
path: root/jstests/sharding/writeback_shard_version.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/writeback_shard_version.js')
-rw-r--r--jstests/sharding/writeback_shard_version.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/jstests/sharding/writeback_shard_version.js b/jstests/sharding/writeback_shard_version.js
new file mode 100644
index 0000000..34af1f0
--- /dev/null
+++ b/jstests/sharding/writeback_shard_version.js
@@ -0,0 +1,42 @@
+// Tests whether a newly sharded collection can be handled by the wbl
+
+jsTestLog( "Starting sharded cluster..." )
+
+// Need to start as a replica set here, just because there's no other way to trigger separate configs,
+// See SERVER-4222
+var st = new ShardingTest( { shards : 1, mongos : 2, verbose : 2, other : { rs : true } } )
+
+st.setBalancer( false )
+
+var mongosA = st.s0
+var mongosB = st.s1
+
+jsTestLog( "Adding new collections...")
+
+var collA = mongosA.getCollection( jsTestName() + ".coll" )
+collA.insert({ hello : "world" })
+assert.eq( null, collA.getDB().getLastError() )
+
+var collB = mongosB.getCollection( "" + collA )
+collB.insert({ hello : "world" })
+assert.eq( null, collB.getDB().getLastError() )
+
+jsTestLog( "Enabling sharding..." )
+
+printjson( mongosA.getDB( "admin" ).runCommand({ enableSharding : "" + collA.getDB() }) )
+printjson( mongosA.getDB( "admin" ).runCommand({ shardCollection : "" + collA, key : { _id : 1 } }) )
+
+// MongoD doesn't know about the config shard version *until* MongoS tells it
+collA.findOne()
+
+jsTestLog( "Trigger wbl..." )
+
+collB.insert({ goodbye : "world" })
+assert.eq( null, collB.getDB().getLastError() )
+
+print( "Inserted..." )
+
+assert.eq( 3, collA.find().itcount() )
+assert.eq( 3, collB.find().itcount() )
+
+st.stop() \ No newline at end of file