diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/auth/lib/commands_lib.js | 62 | ||||
-rw-r--r-- | jstests/libs/override_methods/multiversion_override_balancer_control.js | 26 | ||||
-rw-r--r-- | jstests/noPassthroughWithMongod/no_balance_collection.js | 2 | ||||
-rw-r--r-- | jstests/sharding/sharding_balance2.js | 21 | ||||
-rw-r--r-- | jstests/sharding/top_chunk_autosplit.js | 7 |
5 files changed, 82 insertions, 36 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index f92d2664cca..74ad1256dab 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -722,19 +722,67 @@ var authCommandsLib = { ] }, { - testname: "controlBalancer", - command: {controlBalancer: "x"}, + testname: "balancerStart", + command: {balancerStart: 1}, skipStandalone: true, testcases: [ { runOnDb: adminDbName, privileges: [{resource: {db: 'config', collection: 'settings'}, actions: ['update']}], - expectFail: true // 'x' is not a vaild parameter + expectFail: true // Command cannot be run on non-config server }, ] }, { + testname: "_configsvrBalancerStart", + command: {_configsvrBalancerStart: 1}, + skipSharded: true, + testcases: [ + {runOnDb: adminDbName, roles: {__system: 1}, expectFail: true}, + ] + }, + { + testname: "balancerStop", + command: {balancerStop: 1}, + skipStandalone: true, + testcases: [ + { + runOnDb: adminDbName, + privileges: + [{resource: {db: 'config', collection: 'settings'}, actions: ['update']}], + expectFail: true // Command cannot be run on non-config server + }, + ] + }, + { + testname: "_configsvrBalancerStop", + command: {_configsvrBalancerStop: 1}, + skipSharded: true, + testcases: [ + {runOnDb: adminDbName, roles: {__system: 1}, expectFail: true}, + ] + }, + { + testname: "balancerStatus", + command: {balancerStatus: 1}, + skipStandalone: true, + testcases: [ + { + runOnDb: adminDbName, + privileges: [{resource: {db: 'config', collection: 'settings'}, actions: ['find']}], + }, + ] + }, + { + testname: "_configsvrBalancerStatus", + command: {_configsvrBalancerStatus: 1}, + skipSharded: true, + testcases: [ + {runOnDb: adminDbName, roles: {__system: 1}, expectFail: true}, + ] + }, + { testname: "count", command: {count: "x"}, testcases: [ @@ -2636,14 +2684,6 @@ var authCommandsLib = { ] }, { - testname: "_configsvrControlBalancer", - command: {_configsvrControlBalancer: "x"}, - skipSharded: true, - testcases: [ - {runOnDb: adminDbName, roles: {__system: 1}, expectFail: true}, - ] - }, - { testname: "addShardToZone", command: {addShardToZone: shard0name, zone: 'z'}, skipStandalone: true, diff --git a/jstests/libs/override_methods/multiversion_override_balancer_control.js b/jstests/libs/override_methods/multiversion_override_balancer_control.js index 0d4c1cf3003..aa4c27a9fde 100644 --- a/jstests/libs/override_methods/multiversion_override_balancer_control.js +++ b/jstests/libs/override_methods/multiversion_override_balancer_control.js @@ -1,8 +1,9 @@ /** * This test overrides the ShardingTest start/stopBalancer methods to go directly against the config * server. The reason is that tests with 3.2 mongos and 3.4 mongod are failing because in that - * intermediate state neither the new shell is able to stop the balancer (missing controlBalancer - * command on mongos), nor the old shell works (because the balancer lock session id never changes). + * intermediate state neither the new shell is able to stop the balancer (missing balancerStart/Stop + * commands on mongos), nor the old shell works (because the balancer lock session id does not + * change since the balancer lock is held permanently). */ (function() { 'use strict'; @@ -37,16 +38,14 @@ var controlMongoSConn = MongoRunner.runMongos(controlMongoSStartupOptions); // Override the start/stopBalancer methods - function _controlBalancerFn(action, timeoutMs) { - return controlMongoSConn.adminCommand({controlBalancer: action, maxTimeMS: timeoutMs}); - } var originalStartBalancer = this.startBalancer; this.startBalancer = function(timeoutMs, interval) { timeoutMs = timeoutMs || 60000; var result; - var fn = _controlBalancerFn.bind(this, 'start', timeoutMs); + var fn = controlMongoSConn.adminCommand.bind(controlMongoSConn, + {balancerStart: 1, maxTimeMS: timeoutMs}); if (controlMongoSStartupOptions.keyFile) { result = authutil.asCluster(controlMongoSConn, controlMongoSStartupOptions.keyFile, fn); @@ -67,7 +66,8 @@ timeoutMs = timeoutMs || 60000; var result; - var fn = _controlBalancerFn.bind(this, 'stop', timeoutMs); + var fn = controlMongoSConn.adminCommand.bind(controlMongoSConn, + {balancerStop: 1, maxTimeMS: timeoutMs}); if (controlMongoSStartupOptions.keyFile) { result = authutil.asCluster(controlMongoSConn, controlMongoSStartupOptions.keyFile, fn); @@ -83,6 +83,18 @@ return assert.commandWorked(result); }; + var originalAwaitBalancerRound = this.awaitBalancerRound; + this.awaitBalancerRound = function(timeoutMs) { + timeoutMs = timeoutMs || 60000; + + var fn = originalAwaitBalancerRound.bind(this, timeoutMs, controlMongoSConn); + if (controlMongoSStartupOptions.keyFile) { + authutil.asCluster(controlMongoSConn, controlMongoSStartupOptions.keyFile, fn); + } else { + fn(); + } + }; + // Override the stop method to also stop the control mongos var originalStop = this.stop; this.stop = function() { diff --git a/jstests/noPassthroughWithMongod/no_balance_collection.js b/jstests/noPassthroughWithMongod/no_balance_collection.js index 1c2f1aae009..f6627181b8d 100644 --- a/jstests/noPassthroughWithMongod/no_balance_collection.js +++ b/jstests/noPassthroughWithMongod/no_balance_collection.js @@ -71,7 +71,7 @@ sh.disableBalancing(collB); // Wait for the balancer to fully finish the last migration and write the changelog // MUST set db var here, ugly but necessary db = st.s0.getDB("config"); -st.waitForBalancerRound(); +st.awaitBalancerRound(); // Make sure auto-migrates on insert don't move chunks var lastMigration = sh._lastMigration(collB); diff --git a/jstests/sharding/sharding_balance2.js b/jstests/sharding/sharding_balance2.js index 37c84ed8ded..7de9a97aa3e 100644 --- a/jstests/sharding/sharding_balance2.js +++ b/jstests/sharding/sharding_balance2.js @@ -1,24 +1,21 @@ /** * Test the maxSize setting for the addShard command. */ - (function() { - "use strict"; + 'use strict'; var MaxSizeMB = 1; var s = new ShardingTest({shards: 2, other: {chunkSize: 1, manualAddShard: true}}); var db = s.getDB("test"); - s.stopBalancer(); var names = s.getConnNames(); assert.eq(2, names.length); - s.adminCommand({addshard: names[0]}); - s.adminCommand({addshard: names[1], maxSize: MaxSizeMB}); + assert.commandWorked(s.s0.adminCommand({addshard: names[0]})); + assert.commandWorked(s.s0.adminCommand({addshard: names[1], maxSize: MaxSizeMB})); - s.adminCommand({enablesharding: "test"}); - var res = db.adminCommand({movePrimary: 'test', to: names[0]}); - assert(res.ok || res.errmsg == "it is already the primary"); + assert.commandWorked(s.s0.adminCommand({enablesharding: "test"})); + s.ensurePrimaryShard('test', names[0]); var bigString = ""; while (bigString.length < 10000) @@ -32,7 +29,8 @@ inserted += bigString.length; } assert.writeOK(bulk.execute()); - s.adminCommand({shardcollection: "test.foo", key: {_id: 1}}); + + assert.commandWorked(s.s0.adminCommand({shardcollection: "test.foo", key: {_id: 1}})); assert.gt(s.config.chunks.count(), 10); var getShardSize = function(conn) { @@ -63,13 +61,10 @@ } s.startBalancer(); - - // Wait until balancer finishes at least one balancing round. - assert(s.waitForBalancerRound(), "Balancer is not running: it never pinged config.mongos"); + s.awaitBalancerRound(); var chunkCounts = s.chunkCounts('foo', 'test'); assert.eq(0, chunkCounts.shard0001); s.stop(); - })(); diff --git a/jstests/sharding/top_chunk_autosplit.js b/jstests/sharding/top_chunk_autosplit.js index 5d23386230c..6047e7a948c 100644 --- a/jstests/sharding/top_chunk_autosplit.js +++ b/jstests/sharding/top_chunk_autosplit.js @@ -2,10 +2,9 @@ function shardSetup(shardConfig, dbName, collName) { var st = new ShardingTest(shardConfig); var db = st.getDB(dbName); - // Disable the balancer to not interfere with the test, but keep the balancer settings on - // (with default empty document) so the auto split logic will be able to move chunks around. - assert.writeOK(st.s.getDB('config').settings.remove({_id: 'balancer'})); - db.adminCommand({configureFailPoint: 'skipBalanceRound', mode: 'alwaysOn'}); + // Set the balancer mode to only balance on autoSplit + assert.writeOK(st.s.getDB('config').settings.update( + {_id: 'balancer'}, {'$unset': {stopped: ''}, '$set': {mode: 'autoSplitOnly'}})); return st; } |