diff options
author | Blake Oler <blake.oler@mongodb.com> | 2020-04-14 12:23:43 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-24 14:47:56 +0000 |
commit | 3cc55fa1d000155d149662488257f226ea2b1820 (patch) | |
tree | b6d4f6467ba2b39bc718ac955576751347c65e28 /jstests/sharding/update_immutable_fields.js | |
parent | 3566db153ea61fb10d3ef11ea917fc7bc93eac4d (diff) | |
download | mongo-3cc55fa1d000155d149662488257f226ea2b1820.tar.gz |
SERVER-47426 Remove ShardedConnectionInfo and pare down SetShardVersion
Diffstat (limited to 'jstests/sharding/update_immutable_fields.js')
-rw-r--r-- | jstests/sharding/update_immutable_fields.js | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/jstests/sharding/update_immutable_fields.js b/jstests/sharding/update_immutable_fields.js index 8b5d4a02d9a..27a97fdbf82 100644 --- a/jstests/sharding/update_immutable_fields.js +++ b/jstests/sharding/update_immutable_fields.js @@ -7,36 +7,12 @@ var st = new ShardingTest({shards: 2, mongos: 1}); var mongos = st.s; var config = mongos.getDB("config"); var coll = mongos.getCollection(jsTestName() + ".coll1"); -var shard0 = st.shard0; assert.commandWorked(config.adminCommand({enableSharding: coll.getDB() + ""})); st.ensurePrimaryShard(coll.getDB().getName(), st.shard0.shardName); assert.commandWorked(config.adminCommand({shardCollection: "" + coll, key: {a: 1}})); -var getDirectShardedConn = function(st, collName) { - var shardConnWithVersion = new Mongo(st.shard0.host); - - var configConnStr = st._configDB; - - var maxChunk = - st.s0.getCollection("config.chunks").find({ns: collName}).sort({lastmod: -1}).next(); - - var ssvInitCmd = { - setShardVersion: collName, - authoritative: true, - configdb: configConnStr, - version: maxChunk.lastmod, - shard: st.shard0.shardName, - versionEpoch: maxChunk.lastmodEpoch - }; - - printjson(ssvInitCmd); - assert.commandWorked(shardConnWithVersion.getDB("admin").runCommand(ssvInitCmd)); - - return shardConnWithVersion; -}; - -var shard0Coll = getDirectShardedConn(st, coll.getFullName()).getCollection(coll.getFullName()); +const shard0Coll = st.shard0.getCollection(coll.getFullName()); // Full shard key in save assert.commandWorked(shard0Coll.save({_id: 1, a: 1})); @@ -55,11 +31,5 @@ assert.commandWorked(shard0Coll.update({_id: 1}, {a: 1})); // Update existing doc ($set), same shard key value assert.commandWorked(shard0Coll.update({_id: 1}, {$set: {a: 1}})); -// Error when trying to update a shard key outside of a transaction. -assert.commandFailedWithCode(shard0Coll.update({_id: 1, a: 1}, {_id: 1, a: 2}), - ErrorCodes.IllegalOperation); -assert.commandFailedWithCode(shard0Coll.update({_id: 1, a: 1}, {"$set": {a: 2}}), - ErrorCodes.IllegalOperation); - st.stop(); })(); |