diff options
author | Randolph Tan <randolph@10gen.com> | 2014-05-06 10:43:19 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-06-06 10:31:49 -0400 |
commit | 0d5acb0e3a6b0f1cdf7f252aa9a13afb1e884848 (patch) | |
tree | 761487842572c5f02b40cd0c7cdd1cf63aa596c3 /jstests/sharding/multi_write_target.js | |
parent | 2453cec627bb8f6100980dea273ac9eb54ecd645 (diff) | |
download | mongo-0d5acb0e3a6b0f1cdf7f252aa9a13afb1e884848.tar.gz |
SERVER-11256 improve handling of empty vs nonexistent CollectionMetadata
Diffstat (limited to 'jstests/sharding/multi_write_target.js')
-rw-r--r-- | jstests/sharding/multi_write_target.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/jstests/sharding/multi_write_target.js b/jstests/sharding/multi_write_target.js index 3fc528293c8..8796a6ea6b4 100644 --- a/jstests/sharding/multi_write_target.js +++ b/jstests/sharding/multi_write_target.js @@ -4,7 +4,7 @@ var options = { separateConfig : true }; -var st = new ShardingTest({ shards : 3, mongos : 1, other : options }); +var st = new ShardingTest({ shards : 3, mongos : 2, other : options }); st.stopBalancer(); var mongos = st.s0; @@ -16,19 +16,22 @@ assert( admin.runCommand({ enableSharding : coll.getDB() + "" }).ok ); printjson( admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }) ); assert( admin.runCommand({ shardCollection : coll + "", key : { skey : 1 } }).ok ); assert( admin.runCommand({ split : coll + "", middle : { skey : 0 } }).ok ); +assert( admin.runCommand({ split : coll + "", middle : { skey : 100 } }).ok ); assert( admin.runCommand({ moveChunk : coll + "", find : { skey : 0 }, to : shards[1]._id }).ok ); +assert( admin.runCommand({ moveChunk : coll + "", + find : { skey : 100 }, + to : shards[2]._id }).ok ); st.printShardingStatus(); jsTest.log("Testing multi-update..."); // Put data on all shards -assert.writeOK(st.shard0.getCollection(coll.toString()).insert({ _id : 0, skey : -1, x : 1 })); -assert.writeOK(st.shard1.getCollection(coll.toString()).insert({ _id : 1, skey : 1, x : 1 })); -// Data not in chunks -assert.writeOK(st.shard2.getCollection(coll.toString()).insert({ _id : 0, x : 1 })); +assert.writeOK(st.s0.getCollection(coll.toString()).insert({ _id : 0, skey : -1, x : 1 })); +assert.writeOK(st.s0.getCollection(coll.toString()).insert({ _id : 1, skey : 1, x : 1 })); +assert.writeOK(st.s0.getCollection(coll.toString()).insert({ _id: 0, skey: 100, x: 1 })); // Non-multi-update doesn't work without shard key assert.writeError(coll.update({ x : 1 }, { $set : { updated : true } }, { multi : false })); @@ -40,8 +43,9 @@ assert.neq(null, st.shard0.getCollection(coll.toString()).findOne({ updated : tr assert.neq(null, st.shard1.getCollection(coll.toString()).findOne({ updated : true })); assert.neq(null, st.shard2.getCollection(coll.toString()).findOne({ updated : true })); -// _id update works, and goes to all shards -assert.writeOK(coll.update({ _id : 0 }, { $set : { updatedById : true } }, { multi : false })); +// _id update works, and goes to all shards even on the stale mongos +var staleColl = st.s1.getCollection('foo.bar'); +assert.writeOK(staleColl.update({ _id : 0 }, { $set : { updatedById : true } }, { multi : false })); // Ensure _id update goes to *all* shards assert.neq(null, st.shard0.getCollection(coll.toString()).findOne({ updatedById : true })); |