diff options
Diffstat (limited to 'jstests/sharding/migrate_overwrite_id.js')
-rw-r--r-- | jstests/sharding/migrate_overwrite_id.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/jstests/sharding/migrate_overwrite_id.js b/jstests/sharding/migrate_overwrite_id.js index 1d5bc2f3236..8060a2de8b4 100644 --- a/jstests/sharding/migrate_overwrite_id.js +++ b/jstests/sharding/migrate_overwrite_id.js @@ -6,17 +6,14 @@ var st = new ShardingTest({shards: 2, mongos: 1}); st.stopBalancer(); var mongos = st.s0; -var shards = mongos.getDB("config").shards.find().toArray(); -shards[0].conn = st.shard0; -shards[1].conn = st.shard1; var admin = mongos.getDB("admin"); var coll = mongos.getCollection("foo.bar"); assert(admin.runCommand({enableSharding: coll.getDB() + ""}).ok); -printjson(admin.runCommand({movePrimary: coll.getDB() + "", to: shards[0]._id})); +printjson(admin.runCommand({movePrimary: coll.getDB() + "", to: st.shard0.shardName})); assert(admin.runCommand({shardCollection: coll + "", key: {skey: 1}}).ok); assert(admin.runCommand({split: coll + "", middle: {skey: 0}}).ok); -assert(admin.runCommand({moveChunk: coll + "", find: {skey: 0}, to: shards[1]._id}).ok); +assert(admin.runCommand({moveChunk: coll + "", find: {skey: 0}, to: st.shard1.shardName}).ok); var id = 12345; @@ -25,17 +22,17 @@ jsTest.log("Inserting a document with id : 12345 into both shards with diff shar assert.writeOK(coll.insert({_id: id, skey: -1})); assert.writeOK(coll.insert({_id: id, skey: 1})); -printjson(shards[0].conn.getCollection(coll + "").find({_id: id}).toArray()); -printjson(shards[1].conn.getCollection(coll + "").find({_id: id}).toArray()); +printjson(st.shard0.getCollection(coll + "").find({_id: id}).toArray()); +printjson(st.shard1.getCollection(coll + "").find({_id: id}).toArray()); assert.eq(2, coll.find({_id: id}).itcount()); jsTest.log("Moving both chunks to same shard..."); -var result = admin.runCommand({moveChunk: coll + "", find: {skey: -1}, to: shards[1]._id}); +var result = admin.runCommand({moveChunk: coll + "", find: {skey: -1}, to: st.shard1.shardName}); printjson(result); -printjson(shards[0].conn.getCollection(coll + "").find({_id: id}).toArray()); -printjson(shards[1].conn.getCollection(coll + "").find({_id: id}).toArray()); +printjson(st.shard0.getCollection(coll + "").find({_id: id}).toArray()); +printjson(st.shard1.getCollection(coll + "").find({_id: id}).toArray()); assert.eq(2, coll.find({_id: id}).itcount()); st.stop(); |