summaryrefslogtreecommitdiff
path: root/jstests/sharding/merge_chunks_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/merge_chunks_test.js')
-rw-r--r--jstests/sharding/merge_chunks_test.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/jstests/sharding/merge_chunks_test.js b/jstests/sharding/merge_chunks_test.js
index e801a430061..3f9daee1960 100644
--- a/jstests/sharding/merge_chunks_test.js
+++ b/jstests/sharding/merge_chunks_test.js
@@ -58,12 +58,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}]}));
@@ -77,6 +71,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}]}));