diff options
Diffstat (limited to 'jstests/sharding/inserts_consistent.js')
-rw-r--r-- | jstests/sharding/inserts_consistent.js | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/jstests/sharding/inserts_consistent.js b/jstests/sharding/inserts_consistent.js index 86db9ae4e82..4bea7d95474 100644 --- a/jstests/sharding/inserts_consistent.js +++ b/jstests/sharding/inserts_consistent.js @@ -1,71 +1,71 @@ // Test write re-routing on version mismatch. (function() { - 'use strict'; +'use strict'; - var st = new ShardingTest({shards: 2, mongos: 2}); +var st = new ShardingTest({shards: 2, mongos: 2}); - var mongos = st.s; - var admin = mongos.getDB("admin"); - var config = mongos.getDB("config"); - var coll = st.s.getCollection('TestDB.coll'); +var mongos = st.s; +var admin = mongos.getDB("admin"); +var config = mongos.getDB("config"); +var coll = st.s.getCollection('TestDB.coll'); - assert.commandWorked(mongos.adminCommand({enableSharding: 'TestDB'})); - st.ensurePrimaryShard('TestDB', st.shard0.shardName); - assert.commandWorked(mongos.adminCommand({shardCollection: 'TestDB.coll', key: {_id: 1}})); +assert.commandWorked(mongos.adminCommand({enableSharding: 'TestDB'})); +st.ensurePrimaryShard('TestDB', st.shard0.shardName); +assert.commandWorked(mongos.adminCommand({shardCollection: 'TestDB.coll', key: {_id: 1}})); - jsTest.log("Refreshing second mongos..."); +jsTest.log("Refreshing second mongos..."); - var mongosB = st.s1; - var adminB = mongosB.getDB("admin"); - var collB = mongosB.getCollection(coll + ""); +var mongosB = st.s1; +var adminB = mongosB.getDB("admin"); +var collB = mongosB.getCollection(coll + ""); - // Make sure mongosB knows about the coll - assert.eq(0, collB.find().itcount()); +// Make sure mongosB knows about the coll +assert.eq(0, collB.find().itcount()); - jsTest.log("Moving chunk to create stale mongos..."); - assert.commandWorked( - admin.runCommand({moveChunk: coll + "", find: {_id: 0}, to: st.shard1.shardName})); +jsTest.log("Moving chunk to create stale mongos..."); +assert.commandWorked( + admin.runCommand({moveChunk: coll + "", find: {_id: 0}, to: st.shard1.shardName})); - jsTest.log("Inserting docs that needs to be retried..."); +jsTest.log("Inserting docs that needs to be retried..."); - var nextId = -1; - for (var i = 0; i < 2; i++) { - printjson("Inserting " + nextId); - assert.writeOK(collB.insert({_id: nextId--, hello: "world"})); - } +var nextId = -1; +for (var i = 0; i < 2; i++) { + printjson("Inserting " + nextId); + assert.writeOK(collB.insert({_id: nextId--, hello: "world"})); +} - jsTest.log("Inserting doc which successfully goes through..."); +jsTest.log("Inserting doc which successfully goes through..."); - // Do second write - assert.writeOK(collB.insert({_id: nextId--, goodbye: "world"})); +// Do second write +assert.writeOK(collB.insert({_id: nextId--, goodbye: "world"})); - // Assert that write went through - assert.eq(coll.find().itcount(), 3); +// Assert that write went through +assert.eq(coll.find().itcount(), 3); - jsTest.log("Now try moving the actual chunk we're writing to..."); +jsTest.log("Now try moving the actual chunk we're writing to..."); - // Now move the actual chunk we're writing to - printjson(admin.runCommand({moveChunk: coll + "", find: {_id: -1}, to: st.shard1.shardName})); +// Now move the actual chunk we're writing to +printjson(admin.runCommand({moveChunk: coll + "", find: {_id: -1}, to: st.shard1.shardName})); - jsTest.log("Inserting second docs to get written back..."); +jsTest.log("Inserting second docs to get written back..."); - // Will fail entirely if too many of these, waiting for write to get applied can get too long. - for (var i = 0; i < 2; i++) { - collB.insert({_id: nextId--, hello: "world"}); - } +// Will fail entirely if too many of these, waiting for write to get applied can get too long. +for (var i = 0; i < 2; i++) { + collB.insert({_id: nextId--, hello: "world"}); +} - // Refresh server - printjson(adminB.runCommand({flushRouterConfig: 1})); +// Refresh server +printjson(adminB.runCommand({flushRouterConfig: 1})); - jsTest.log("Inserting second doc which successfully goes through..."); +jsTest.log("Inserting second doc which successfully goes through..."); - // Do second write - assert.writeOK(collB.insert({_id: nextId--, goodbye: "world"})); +// Do second write +assert.writeOK(collB.insert({_id: nextId--, goodbye: "world"})); - jsTest.log("All docs written this time!"); +jsTest.log("All docs written this time!"); - // Assert that writes went through. - assert.eq(coll.find().itcount(), 6); +// Assert that writes went through. +assert.eq(coll.find().itcount(), 6); - st.stop(); +st.stop(); })(); |