summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorPaolo Polato <paolo.polato@mongodb.com>2021-06-03 13:58:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-04 08:16:37 +0000
commit4d58bea897115e86b17c20a808bd392f663c2552 (patch)
tree2e9167ab78e7fdde61351ab4f94d390561b5e73c /jstests
parent057fff6d4dc4dc8f739abfc1e9a497ad3abb32ce (diff)
downloadmongo-4d58bea897115e86b17c20a808bd392f663c2552.tar.gz
SERVER-56786 expand the bounds parameter of mergeChunk in the config server
Diffstat (limited to 'jstests')
-rw-r--r--jstests/auth/lib/commands_lib.js14
-rw-r--r--jstests/core/views/views_all_commands.js1
-rw-r--r--jstests/libs/override_methods/network_error_and_txn_override.js1
-rw-r--r--jstests/libs/override_methods/read_and_write_concern_helpers.js1
-rw-r--r--jstests/replsets/db_reads_while_recovering_all_commands.js1
-rw-r--r--jstests/sharding/merge_chunk_hashed.js29
-rw-r--r--jstests/sharding/merge_chunks_test.js32
-rw-r--r--jstests/sharding/read_write_concern_defaults_application.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js1
11 files changed, 69 insertions, 14 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index 88e7da8bf4a..268559a46b1 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -2843,6 +2843,20 @@ var authCommandsLib = {
]
},
{
+ testname: "_configsvrCommitChunksMerge",
+ command: {_configsvrCommitChunksMerge: "x.y"},
+ skipSharded: true,
+ expectFail: true,
+ testcases: [
+ {
+ runOnDb: adminDbName,
+ roles: {__system: 1},
+ privileges: [{resource: {cluster: true}, actions: ["internal"]}],
+ expectFail: true
+ },
+ ]
+ },
+ {
testname: "_configsvrCommitChunkSplit",
command: {_configsvrCommitChunkSplit: "x.y"},
skipSharded: true,
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index 817af63ff7d..1fdaf68dca1 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -88,6 +88,7 @@ let viewsCommandTests = {
_configsvrBalancerStop: {skip: isAnInternalCommand},
_configsvrClearJumboFlag: {skip: isAnInternalCommand},
_configsvrCommitChunkMerge: {skip: isAnInternalCommand},
+ _configsvrCommitChunksMerge: {skip: isAnInternalCommand},
_configsvrCommitChunkMigration: {skip: isAnInternalCommand},
_configsvrCommitChunkSplit: {skip: isAnInternalCommand},
_configsvrCommitMovePrimary: {skip: isAnInternalCommand},
diff --git a/jstests/libs/override_methods/network_error_and_txn_override.js b/jstests/libs/override_methods/network_error_and_txn_override.js
index 346db3ac1db..9cf0e366da1 100644
--- a/jstests/libs/override_methods/network_error_and_txn_override.js
+++ b/jstests/libs/override_methods/network_error_and_txn_override.js
@@ -75,6 +75,7 @@ const kNonRetryableCommands = new Set([
"_configsvrAddShard",
"_configsvrAddShardToZone",
"_configsvrCommitChunkMerge",
+ "_configsvrCommitChunksMerge",
"_configsvrCommitChunkMigration",
"_configsvrCommitChunkSplit",
"_configsvrCreateDatabase",
diff --git a/jstests/libs/override_methods/read_and_write_concern_helpers.js b/jstests/libs/override_methods/read_and_write_concern_helpers.js
index 6f7ac663357..6a9ad045497 100644
--- a/jstests/libs/override_methods/read_and_write_concern_helpers.js
+++ b/jstests/libs/override_methods/read_and_write_concern_helpers.js
@@ -21,6 +21,7 @@ var kCommandsSupportingWriteConcern = new Set([
"_configsvrAddShard",
"_configsvrAddShardToZone",
"_configsvrCommitChunkMerge",
+ "_configsvrCommitChunksMerge",
"_configsvrCommitChunkMigration",
"_configsvrCommitChunkSplit",
"_configsvrCreateDatabase",
diff --git a/jstests/replsets/db_reads_while_recovering_all_commands.js b/jstests/replsets/db_reads_while_recovering_all_commands.js
index 687ca075f3e..5bb5d5f6a00 100644
--- a/jstests/replsets/db_reads_while_recovering_all_commands.js
+++ b/jstests/replsets/db_reads_while_recovering_all_commands.js
@@ -33,6 +33,7 @@ const allCommands = {
_configsvrBalancerStop: {skip: isPrimaryOnly},
_configsvrClearJumboFlag: {skip: isPrimaryOnly},
_configsvrCommitChunkMerge: {skip: isPrimaryOnly},
+ _configsvrCommitChunksMerge: {skip: isPrimaryOnly},
_configsvrCommitChunkMigration: {skip: isPrimaryOnly},
_configsvrCommitChunkSplit: {skip: isPrimaryOnly},
_configsvrCommitMovePrimary: {skip: isPrimaryOnly},
diff --git a/jstests/sharding/merge_chunk_hashed.js b/jstests/sharding/merge_chunk_hashed.js
index cd3d184f474..d1159bbfb17 100644
--- a/jstests/sharding/merge_chunk_hashed.js
+++ b/jstests/sharding/merge_chunk_hashed.js
@@ -111,14 +111,6 @@ assert.commandFailed(admin.runCommand({
assert.commandFailed(admin.runCommand(
{mergeChunks: ns, bounds: [{x: NumberLong(-1500000000000000000)}, {x: MaxKey}]}));
-// Make sure merging single chunks is invalid.
-assert.commandFailed(admin.runCommand({mergeChunks: ns, bounds: [{x: MinKey}, chunkToSplit.min]}));
-assert.commandFailed(admin.runCommand({
- mergeChunks: ns,
- bounds: [{x: NumberLong(-4500000000000000000)}, {x: NumberLong(-4000000000000000000)}]
-}));
-assert.commandFailed(admin.runCommand({mergeChunks: ns, bounds: [{x: 110}, {x: MaxKey}]}));
-
// Make sure merging over holes is invalid.
assert.commandFailed(admin.runCommand(
{mergeChunks: ns, bounds: [{x: MinKey}, {x: NumberLong(-3500000000000000000)}]}));
@@ -140,6 +132,27 @@ assert.eq(4, staleCollection.find().itcount());
jsTest.log("Trying merges that should succeed...");
+// Merging single chunks should be treated as a no-op
+// (or fail because 'the range specifies one single chunk' in multiversion test environments)
+try {
+ assert.commandWorked(
+ admin.runCommand({mergeChunks: ns, bounds: [{x: MinKey}, chunkToSplit.min]}));
+} catch (e) {
+ if (!e.message.match(/could not merge chunks, collection .* already contains chunk for/)) {
+ throw e;
+ }
+}
+try {
+ assert.commandWorked(admin.runCommand({
+ mergeChunks: ns,
+ bounds: [{x: NumberLong(-4500000000000000000)}, {x: NumberLong(-4000000000000000000)}]
+ }));
+} catch (e) {
+ if (!e.message.match(/could not merge chunks, collection .* already contains chunk for/)) {
+ throw e;
+ }
+}
+
// Make sure merge including the MinKey works.
assert.commandWorked(admin.runCommand(
{mergeChunks: ns, bounds: [{x: MinKey}, {x: NumberLong(-4500000000000000000)}]}));
diff --git a/jstests/sharding/merge_chunks_test.js b/jstests/sharding/merge_chunks_test.js
index d4f74c26fb6..88992b8a133 100644
--- a/jstests/sharding/merge_chunks_test.js
+++ b/jstests/sharding/merge_chunks_test.js
@@ -56,12 +56,6 @@ assert.commandFailed(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20
assert.commandFailed(
admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 105}, {_id: MaxKey}]}));
-// Make sure merging single chunks is invalid
-assert.commandFailed(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 0}]}));
-assert.commandFailed(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20}, {_id: 40}]}));
-assert.commandFailed(
- admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 110}, {_id: MaxKey}]}));
-
// Make sure merging over holes is invalid
assert.commandFailed(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 0}, {_id: 40}]}));
assert.commandFailed(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 40}, {_id: 110}]}));
@@ -75,6 +69,32 @@ assert.eq(4, staleCollection.find().itcount());
jsTest.log("Trying merges that should succeed...");
+// Merging single chunks should be treated as a no-op
+// (or fail because 'the range specifies one single chunk' in multiversion test environments)
+try {
+ assert.commandWorked(
+ admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 0}]}));
+} catch (e) {
+ if (!e.message.match(/could not merge chunks, collection .* already contains chunk for/)) {
+ throw e;
+ }
+}
+try {
+ assert.commandWorked(
+ admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20}, {_id: 40}]}));
+} catch (e) {
+ if (!e.message.match(/could not merge chunks, collection .* already contains chunk for/)) {
+ throw e;
+ }
+}
+try {
+ assert.commandWorked(
+ admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 110}, {_id: MaxKey}]}));
+} catch (e) {
+ if (!e.message.match(/could not merge chunks, collection .* already contains chunk for/)) {
+ throw e;
+ }
+}
// Make sure merge including the MinKey works
assert.commandWorked(
admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 10}]}));
diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js
index 38ab751a758..43e3abbf3e6 100644
--- a/jstests/sharding/read_write_concern_defaults_application.js
+++ b/jstests/sharding/read_write_concern_defaults_application.js
@@ -82,6 +82,7 @@ let testCases = {
_configsvrBalancerStop: {skip: "internal command"},
_configsvrClearJumboFlag: {skip: "internal command"},
_configsvrCommitChunkMerge: {skip: "internal command"},
+ _configsvrCommitChunksMerge: {skip: "internal command"},
_configsvrCommitChunkMigration: {skip: "internal command"},
_configsvrCommitChunkSplit: {skip: "internal command"},
_configsvrCommitMovePrimary: {skip: "internal command"},
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index fafd7e23329..ae88a62b0a7 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -54,6 +54,7 @@ let testCases = {
_configsvrBalancerStop: {skip: "primary only"},
_configsvrClearJumboFlag: {skip: "primary only"},
_configsvrCommitChunkMerge: {skip: "primary only"},
+ _configsvrCommitChunksMerge: {skip: "primary only"},
_configsvrCommitChunkMigration: {skip: "primary only"},
_configsvrCommitChunkSplit: {skip: "primary only"},
_configsvrCommitMovePrimary: {skip: "primary only"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
index 657bc2a3502..20e21459b80 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
@@ -65,6 +65,7 @@ let testCases = {
_configsvrBalancerStop: {skip: "primary only"},
_configsvrClearJumboFlag: {skip: "primary only"},
_configsvrCommitChunkMerge: {skip: "primary only"},
+ _configsvrCommitChunksMerge: {skip: "primary only"},
_configsvrCommitChunkMigration: {skip: "primary only"},
_configsvrCommitChunkSplit: {skip: "primary only"},
_configsvrCommitMovePrimary: {skip: "primary only"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
index fd8c1582384..6b2d4f6f90d 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -56,6 +56,7 @@ let testCases = {
_configsvrBalancerStop: {skip: "primary only"},
_configsvrClearJumboFlag: {skip: "primary only"},
_configsvrCommitChunkMerge: {skip: "primary only"},
+ _configsvrCommitChunksMerge: {skip: "primary only"},
_configsvrCommitChunkMigration: {skip: "primary only"},
_configsvrCommitChunkSplit: {skip: "primary only"},
_configsvrCommitMovePrimary: {skip: "primary only"},