diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/authCommands.js | 9 | ||||
-rw-r--r-- | jstests/sharding/movechunk_include.js | 17 | ||||
-rw-r--r-- | jstests/sharding/movechunk_with_default_paranoia.js | 5 | ||||
-rw-r--r-- | jstests/sharding/movechunk_with_moveParanoia.js | 13 | ||||
-rw-r--r-- | jstests/sharding/movechunk_with_noMoveParanoia.js | 8 | ||||
-rw-r--r-- | jstests/ssl/libs/ssl_helpers.js | 10 |
6 files changed, 38 insertions, 24 deletions
diff --git a/jstests/sharding/authCommands.js b/jstests/sharding/authCommands.js index 75b4af71710..cd75ddd5cec 100644 --- a/jstests/sharding/authCommands.js +++ b/jstests/sharding/authCommands.js @@ -21,8 +21,7 @@ var st = new ShardingTest({ shards: 2, rs: {oplogSize: 10, useHostname: false}, - other: - {keyFile: 'jstests/libs/key1', useHostname: false, chunkSize: 2, enableAutoSplit: true}, + other: {keyFile: 'jstests/libs/key1', useHostname: false, chunkSize: 2}, }); var mongos = st.s; @@ -70,13 +69,15 @@ str += str; } - var bulk = testDB.foo.initializeUnorderedBulkOp(); for (var i = 0; i < 100; i++) { + var bulk = testDB.foo.initializeUnorderedBulkOp(); for (var j = 0; j < 10; j++) { bulk.insert({i: i, j: j, str: str}); } + assert.writeOK(bulk.execute({w: "majority"})); + // Split the chunk we just inserted so that we have something to balance. + assert.commandWorked(st.splitFind("test.foo", {i: i, j: 0})); } - assert.writeOK(bulk.execute({w: "majority"})); assert.eq(expectedDocs, testDB.foo.count()); diff --git a/jstests/sharding/movechunk_include.js b/jstests/sharding/movechunk_include.js index 285ec587682..f4c1c2f00a6 100644 --- a/jstests/sharding/movechunk_include.js +++ b/jstests/sharding/movechunk_include.js @@ -1,4 +1,13 @@ -function setupMoveChunkTest(st) { +function setupMoveChunkTest(shardOptions) { + var st = new ShardingTest({ + shards: 2, + mongos: 1, + other: { + chunkSize: 1, + shardOptions: shardOptions, + } + }); + // Stop Balancer st.stopBalancer(); @@ -25,6 +34,11 @@ function setupMoveChunkTest(st) { } assert.writeOK(bulk.execute()); + // Make sure there are chunks to move + for (var i = 0; i < 10; ++i) { + assert.commandWorked(st.splitFind("test.foo", {_id: i})); + } + var stats = st.chunkCounts("foo"); var to = ""; for (shard in stats) { @@ -41,4 +55,5 @@ function setupMoveChunkTest(st) { _waitForDelete: true }); // some tests need this... assert(result, "movechunk failed: " + tojson(result)); + return st; } diff --git a/jstests/sharding/movechunk_with_default_paranoia.js b/jstests/sharding/movechunk_with_default_paranoia.js index 97b8d5c6db1..82daf3be66d 100644 --- a/jstests/sharding/movechunk_with_default_paranoia.js +++ b/jstests/sharding/movechunk_with_default_paranoia.js @@ -3,9 +3,10 @@ * be created). */ -var st = new ShardingTest({shards: 2, mongos: 1, other: {chunkSize: 1, enableAutoSplit: true}}); load("jstests/sharding/movechunk_include.js"); -setupMoveChunkTest(st); + +// Passing no shardOptions to test default moveParanoia +var st = setupMoveChunkTest({}); var shards = [st.shard0, st.shard1]; for (i in shards) { diff --git a/jstests/sharding/movechunk_with_moveParanoia.js b/jstests/sharding/movechunk_with_moveParanoia.js index b3b203af32e..3b63b9b8eea 100644 --- a/jstests/sharding/movechunk_with_moveParanoia.js +++ b/jstests/sharding/movechunk_with_moveParanoia.js @@ -2,18 +2,9 @@ * This test sets moveParanoia flag and then check that the directory is created with the moved data */ -var st = new ShardingTest({ - shards: 2, - mongos: 1, - other: { - chunkSize: 1, - enableAutoSplit: true, - shardOptions: {moveParanoia: ""}, - } -}); - load("jstests/sharding/movechunk_include.js"); -setupMoveChunkTest(st); + +var st = setupMoveChunkTest({moveParanoia: ""}); var shards = [st.shard0, st.shard1]; var foundMoveChunk = false; diff --git a/jstests/sharding/movechunk_with_noMoveParanoia.js b/jstests/sharding/movechunk_with_noMoveParanoia.js index 2ca6ef96f16..49df2f89614 100644 --- a/jstests/sharding/movechunk_with_noMoveParanoia.js +++ b/jstests/sharding/movechunk_with_noMoveParanoia.js @@ -1,14 +1,10 @@ /** * This test sets moveParanoia flag and then check that the directory is created with the moved data */ -var st = new ShardingTest({ - shards: 2, - mongos: 1, - other: {chunkSize: 1, enableAutoSplit: true, shardOptions: {noMoveParanoia: ""}} -}); load("jstests/sharding/movechunk_include.js"); -setupMoveChunkTest(st); + +var st = setupMoveChunkTest({noMoveParanoia: ""}); var shards = [st.shard0, st.shard1]; for (i in shards) { diff --git a/jstests/ssl/libs/ssl_helpers.js b/jstests/ssl/libs/ssl_helpers.js index 05d0a5b9333..6b5ed90d283 100644 --- a/jstests/ssl/libs/ssl_helpers.js +++ b/jstests/ssl/libs/ssl_helpers.js @@ -108,6 +108,12 @@ function mixedShardTest(options1, options2, shouldSucceed) { try { // Start ShardingTest with enableBalancer because ShardingTest attempts to turn // off the balancer otherwise, which it will not be authorized to do if auth is enabled. + // + // Also, the autosplitter will be turned on automatically with 'enableBalancer: true'. We + // then want to disable the autosplitter, but cannot do so here with 'enableAutoSplit: + // false' because ShardingTest will attempt to call disableAutoSplit(), which it will not be + // authorized to do if auth is enabled. + // // Once SERVER-14017 is fixed the "enableBalancer" line can be removed. // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. var st = new ShardingTest({ @@ -124,6 +130,7 @@ function mixedShardTest(options1, options2, shouldSucceed) { authSucceeded = true; st.stopBalancer(); + st.disableAutoSplit(); // Test that $lookup works because it causes outgoing connections to be opened testShardedLookup(st); @@ -150,6 +157,9 @@ function mixedShardTest(options1, options2, shouldSucceed) { assert.writeOK(bulk.execute()); assert.eq(128, db1.col.count(), "error retrieving documents from cluster"); + // Split chunk to make it small enough to move + assert.commandWorked(st.splitFind("test.col", {_id: 0})); + // Test shards talking to each other r = st.getDB('test').adminCommand( {moveChunk: 'test.col', find: {_id: 0}, to: st.shard0.shardName}); |