summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2014-12-16 19:06:19 -0500
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2014-12-23 12:28:20 -0500
commitc4691732d3a7cdcdff2a28c970f89c06d3c428b6 (patch)
tree2f0203b5632fa7f424ffae796259b5072bbd6107 /jstests
parent4790d61d2151aac7f026a817a2ce17a2be890bc9 (diff)
downloadmongo-c4691732d3a7cdcdff2a28c970f89c06d3c428b6.tar.gz
SERVER-16498 d_migrate.cpp should not rely on system.namespaces
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/sharding_system_namespaces.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/jstests/sharding/sharding_system_namespaces.js b/jstests/sharding/sharding_system_namespaces.js
new file mode 100644
index 00000000000..150f3bfd730
--- /dev/null
+++ b/jstests/sharding/sharding_system_namespaces.js
@@ -0,0 +1,57 @@
+// SERVER-16498 d_migrate.cpp should not rely on system.namespaces
+//
+// This test create a sharded collection with wiredtiger options.
+// When the chunks of this collection get migrated to the other shard,
+// the other shard should create the collection with the same options.
+// However, before SERVER-16498, the receiver relies on checking
+// system.namespaces on the donor, which is empty on wiredtiger.
+// As a result, the new collection created on receiver has different
+// options.
+//
+// P.S. wiredtiger options are not valid for MMAPv1, but MMAPv1 will
+// keep and ignore them.
+
+var st = new ShardingTest({ shards : 2 });
+
+var db = st.s.getDB("test");
+var coll = db.sharding_system_namespaces;
+
+function checkCollectionOptions(database) {
+ var collectionsInfos = database.runCommand("listCollections");
+ printjson(collectionsInfos);
+ var info = collectionsInfos.collections.filter(function(c) {
+ return c.name == "sharding_system_namespaces";
+ })[0];
+ assert.eq(info.options.storageEngine.wiredTiger.configString, "block_compressor=zlib");
+}
+
+db.createCollection("sharding_system_namespaces",
+{
+ storageEngine: {
+ wiredTiger: { configString: "block_compressor=zlib" }
+ }
+});
+
+checkCollectionOptions(db);
+
+assert.commandWorked(db.adminCommand({ enableSharding: 'test' }));
+assert.commandWorked(db.adminCommand({ shardCollection: coll + '', key: { x: 1 }}));
+
+coll.insert({x: 0});
+coll.insert({x: 10});
+
+assert.commandWorked(db.adminCommand({ split: coll + '', middle: { x: 5 }}));
+
+printShardingStatus();
+
+var primaryShard = st.getServer("test");
+anotherShard = st.getOther( primaryShard );
+assert.commandWorked(db.adminCommand({
+ movechunk: coll + '',
+ find: { x: 5 },
+ to: anotherShard.name
+}));
+
+printShardingStatus();
+
+checkCollectionOptions(anotherShard.getDB("test"));