diff options
author | Enrico Golfieri <enrico.golfieri@mongodb.com> | 2022-09-01 11:59:40 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-01 15:03:59 +0000 |
commit | 22f21e6e5a8086b3766485cc323ce9673587f30c (patch) | |
tree | 47cb614c3f778d643b60b89a93d58d930eba2b62 /jstests | |
parent | ab2d5005886706ebcb3f267181328f00f1707ceb (diff) | |
download | mongo-22f21e6e5a8086b3766485cc323ce9673587f30c.tar.gz |
SERVER-66297 get rid of maxSize
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/addshard1.js | 9 | ||||
-rw-r--r-- | jstests/sharding/shard_max_size.js | 82 | ||||
-rw-r--r-- | jstests/sharding/top_chunk_autosplit.js | 60 |
3 files changed, 7 insertions, 144 deletions
diff --git a/jstests/sharding/addshard1.js b/jstests/sharding/addshard1.js index 81a161fcc84..2ca178282f8 100644 --- a/jstests/sharding/addshard1.js +++ b/jstests/sharding/addshard1.js @@ -22,14 +22,19 @@ var configDB = s.s.getDB('config'); assert.eq(null, configDB.databases.findOne({_id: 'testDB'})); var newShard = "myShard"; -assert.commandWorked(s.admin.runCommand({addShard: rs1.getURL(), name: newShard, maxSize: 1024})); +assert.commandWorked(s.admin.runCommand({addShard: rs1.getURL(), name: newShard})); assert.neq(null, configDB.databases.findOne({_id: 'testDB'})); var newShardDoc = configDB.shards.findOne({_id: newShard}); -assert.eq(1024, newShardDoc.maxSize); assert(newShardDoc.topologyTime instanceof Timestamp); +// maxSize field is no longer supported +var newShardMaxSize = "myShardMaxSize"; +assert.commandFailedWithCode( + s.admin.runCommand({addShard: rs1.getURL(), name: newShardMaxSize, maxSize: 1024}), + ErrorCodes.InvalidOptions); + // a mongod with an existing database name should not be allowed to become a shard var rs2 = new ReplSetTest({name: "addshard1-2", nodes: 1}); rs2.startSet({shardsvr: ""}); diff --git a/jstests/sharding/shard_max_size.js b/jstests/sharding/shard_max_size.js deleted file mode 100644 index 35d4fa70e22..00000000000 --- a/jstests/sharding/shard_max_size.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Test the maxSize setting for the addShard command. - * - * @tags: [does_not_support_stepdowns] - */ -(function() { -'use strict'; - -load("jstests/sharding/libs/find_chunks_util.js"); -load("jstests/libs/feature_flag_util.js"); - -var MaxSizeMB = 1; - -var s = new ShardingTest({ - shards: 2, - other: { - chunkSize: 1, - manualAddShard: true, - shardOptions: - {setParameter: {internalQueryMaxBlockingSortMemoryUsageBytes: 32 * 1024 * 1024}} - } -}); - -var db = s.getDB("test"); - -var names = s.getConnNames(); -assert.eq(2, names.length); -assert.commandWorked(s.s0.adminCommand({addshard: names[0]})); -assert.commandWorked(s.s0.adminCommand({addshard: names[1], maxSize: MaxSizeMB})); -assert.commandWorked(s.s0.adminCommand({enablesharding: "test"})); -s.ensurePrimaryShard('test', names[0]); - -var bigString = ""; -while (bigString.length < 10000) - bigString += "asdasdasdasdadasdasdasdasdasdasdasdasda"; - -var inserted = 0; -var num = 0; -var bulk = db.foo.initializeUnorderedBulkOp(); -while (inserted < (40 * 1024 * 1024)) { - bulk.insert({_id: num++, s: bigString}); - inserted += bigString.length; -} -assert.commandWorked(bulk.execute()); - -assert.commandWorked(s.s0.adminCommand({shardcollection: "test.foo", key: {_id: 1}})); - -var getShardSize = function(conn) { - var listDatabases = conn.getDB('admin').runCommand({listDatabases: 1}); - return listDatabases.totalSize; -}; - -var shardConn = new Mongo(names[1]); - -// Make sure that shard doesn't have any documents. -assert.eq(0, shardConn.getDB('test').foo.find().itcount()); - -var maxSizeBytes = MaxSizeMB * 1024 * 1024; - -// Fill the shard with documents to exceed the max size so the balancer won't move -// chunks to this shard. -var localColl = shardConn.getDB('local').padding; -while (getShardSize(shardConn) < maxSizeBytes) { - var localBulk = localColl.initializeUnorderedBulkOp(); - - for (var x = 0; x < 20; x++) { - localBulk.insert({x: x, val: bigString}); - } - assert.commandWorked(localBulk.execute()); - - // Force the storage engine to flush files to disk so shardSize will get updated. - assert.commandWorked(shardConn.getDB('admin').runCommand({fsync: 1})); -} - -s.startBalancer(); -s.awaitBalancerRound(); - -var chunkCounts = s.chunkCounts('foo', 'test'); -assert.eq(0, chunkCounts[s.rs1.name]); - -s.stop(); -})(); diff --git a/jstests/sharding/top_chunk_autosplit.js b/jstests/sharding/top_chunk_autosplit.js index 44f617adf78..629f9635352 100644 --- a/jstests/sharding/top_chunk_autosplit.js +++ b/jstests/sharding/top_chunk_autosplit.js @@ -333,64 +333,4 @@ for (var i = 0; i < singleNodeTests.length; i++) { } st.stop(); - -// maxSize test -// To set maxSize, must manually add the shards -st = shardSetup({ - name: "maxSize", - shards: 2, - chunkSize: 1, - other: {manualAddShard: true, enableAutoSplit: true} -}, - dbName, - collName); -db = st.getDB(dbName); -coll = db[collName]; -configDB = st.s.getDB('config'); - -var maxSizeTests = [ - { - // Test auto-split on the "low" top chunk with maxSize on destination shard - name: "maxSize - low top chunk", - lowOrHigh: lowChunk, - movedToShard: st.rs0.name, - shards: [ - {name: st.rs0.name, range: lowChunkRange, chunks: 10}, - {name: st.rs1.name, range: highChunkRange, chunks: 1} - ], - inserts: lowChunkInserts - }, - { - // Test auto-split on the "high" top chunk with maxSize on destination shard - name: "maxSize - high top chunk", - lowOrHigh: highChunk, - movedToShard: st.rs0.name, - shards: [ - {name: st.rs0.name, range: highChunkRange, chunks: 10}, - {name: st.rs1.name, range: lowChunkRange, chunks: 1} - ], - inserts: highChunkInserts - }, -]; - -// maxSize on st.rs0.name - 5MB, on st.rs1.name - 1MB -assert.commandWorked(db.adminCommand({addshard: st.getConnNames()[0], maxSize: 5})); -assert.commandWorked(db.adminCommand({addshard: st.getConnNames()[1], maxSize: 1})); - -// SERVER-17070 Auto split moves to shard node running WiredTiger, if exceeding maxSize -var unsupported = ["wiredTiger", "rocksdb", "inMemory"]; -if (unsupported.indexOf(st.rs0.getPrimary().adminCommand({serverStatus: 1}).storageEngine.name) == - -1 && - unsupported.indexOf(st.rs1.getPrimary().adminCommand({serverStatus: 1}).storageEngine.name) == - -1) { - assert.commandWorked(db.adminCommand({enableSharding: dbName})); - st.ensurePrimaryShard(dbName, st.rs0.name); - - // Execute all test objects - for (var i = 0; i < maxSizeTests.length; i++) { - runTest(maxSizeTests[i]); - } -} - -st.stop(); })(); |