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 | |
parent | 3566db153ea61fb10d3ef11ea917fc7bc93eac4d (diff) | |
download | mongo-3cc55fa1d000155d149662488257f226ea2b1820.tar.gz |
SERVER-47426 Remove ShardedConnectionInfo and pare down SetShardVersion
Diffstat (limited to 'jstests/sharding')
-rw-r--r-- | jstests/sharding/ssv_config_check.js | 16 | ||||
-rw-r--r-- | jstests/sharding/update_immutable_fields.js | 32 | ||||
-rw-r--r-- | jstests/sharding/version2.js | 32 |
3 files changed, 3 insertions, 77 deletions
diff --git a/jstests/sharding/ssv_config_check.js b/jstests/sharding/ssv_config_check.js index 48d7f2eac70..0163e521c65 100644 --- a/jstests/sharding/ssv_config_check.js +++ b/jstests/sharding/ssv_config_check.js @@ -1,6 +1,5 @@ /** - * Test that setShardVersion should not reject a configdb string with the same - * replica set name, but with a member list that is not strictly the same. + * Test that setShardVersion fails if sent to the config server. */ (function() { "use strict"; @@ -17,19 +16,6 @@ var directConn = new Mongo(st.rs0.getPrimary().host); var adminDB = directConn.getDB('admin'); var configStr = adminDB.runCommand({getShardVersion: 'test.user'}).configServer; -var alternateConfigStr = configStr.substring(0, configStr.lastIndexOf(',')); - -var shardDoc = st.s.getDB('config').shards.findOne(); - -jsTest.log("Verify that the obsolete init form of setShardVersion succeeds on shards."); -assert.commandWorked(adminDB.runCommand({ - setShardVersion: '', - init: true, - authoritative: true, - configdb: alternateConfigStr, - shard: shardDoc._id, - shardHost: shardDoc.host -})); var configAdmin = st.c0.getDB('admin'); 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(); })(); diff --git a/jstests/sharding/version2.js b/jstests/sharding/version2.js index 87a4eb9915a..74880d8ccfd 100644 --- a/jstests/sharding/version2.js +++ b/jstests/sharding/version2.js @@ -26,7 +26,7 @@ assert.commandWorked(a.runCommand({ printjson(s.config.chunks.findOne()); -assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).mine.t, 1); +assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).mine.t, 0); assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).global.t, 1); // From a different client @@ -39,35 +39,5 @@ assert.eq(a2.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._con 0, "a2 mine 1"); -function simpleFindOne() { - return a2.getMongo().getDB("alleyinsider").foo.findOne(); -} - -var barEpoch = s.getDB('config').chunks.findOne({ns: 'alleyinsider.bar'}).lastmodEpoch; -assert.commandWorked(a2.runCommand({ - setShardVersion: "alleyinsider.bar", - configdb: s._configDB, - version: new Timestamp(1, 0), - versionEpoch: barEpoch, - shard: s.shard0.shardName, - authoritative: true -}), - "setShardVersion bar temp"); - -assert.throws(simpleFindOne, [], "should complain about not in sharded mode 1"); - -// the only way that setSharVersion passes is if the shard agrees with the version -// the shard takes its version from config directly -// TODO bump timestamps in config -// assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: -// 2 }).ok == 1, "setShardVersion a2-1"); - -// simpleFindOne(); // now should run ok - -// assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: -// 3 }).ok == 1, "setShardVersion a2-2"); - -// simpleFindOne(); // newer version is ok - s.stop(); })(); |