summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Saltz <matthew.saltz@mongodb.com>2018-08-01 14:47:27 -0400
committerMatthew Saltz <matthew.saltz@mongodb.com>2018-08-09 14:04:28 -0400
commit25de1e85f2369d00391979f6efc5827d5e574e6f (patch)
tree868c49d8175b8abaec92875e682b0fbf8fb5aaa7
parent16f62b01bf8098d761044ff71318d166e9a82dee (diff)
downloadmongo-25de1e85f2369d00391979f6efc5827d5e574e6f.tar.gz
SERVER-36392 Make tests that rely on the autosplitter unintentially not require the autosplitter
-rw-r--r--jstests/sharding/authCommands.js9
-rw-r--r--jstests/sharding/movechunk_include.js17
-rw-r--r--jstests/sharding/movechunk_with_default_paranoia.js5
-rw-r--r--jstests/sharding/movechunk_with_moveParanoia.js13
-rw-r--r--jstests/sharding/movechunk_with_noMoveParanoia.js8
-rw-r--r--jstests/ssl/libs/ssl_helpers.js10
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});