summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2020-08-21 19:07:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-14 21:52:51 +0000
commitc21f819b43459cfec98ea880b8c6e22a414fa956 (patch)
tree78d3b69e322a8a95a84dcc89b763dfdef30a315d
parent07b796b71e35154e0ab4fc5e6f7a3a3ff9cbc896 (diff)
downloadmongo-c21f819b43459cfec98ea880b8c6e22a414fa956.tar.gz
SERVER-50475 Put data on both shards in mr_noscripting.js
(cherry picked from commit e213ad984d8f72560ab14bb63c0c7dbdb9cc4efa)
-rw-r--r--jstests/sharding/mr_noscripting.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/jstests/sharding/mr_noscripting.js b/jstests/sharding/mr_noscripting.js
index dd4c2d83f9b..f4b477ed1c5 100644
--- a/jstests/sharding/mr_noscripting.js
+++ b/jstests/sharding/mr_noscripting.js
@@ -13,10 +13,9 @@ const mongos = st.s;
const testDB = mongos.getDB('test');
const coll = testDB.bar;
-// Shard the collection and make sure there is a chunk on each shard.
+// Shard the collection and make sure there is a non-empty chunk on each shard.
st.shardColl(coll.getName(), {x: 1}, {x: 0}, {x: 1});
-
-assert.commandWorked(coll.insert({x: 1}));
+assert.commandWorked(coll.insert([{x: 1}, {x: -1}]));
const mapFn = function() {
emit(this.x, 1);
@@ -26,8 +25,17 @@ const reduceFn = function(key, values) {
return 1;
};
-assert.commandFailedWithCode(
- testDB.runCommand({mapreduce: 'bar', map: mapFn, reduce: reduceFn, out: {inline: 1}}), 31264);
+const mrCmd = {
+ mapreduce: 'bar',
+ map: mapFn,
+ reduce: reduceFn,
+ out: {inline: 1}
+};
+// If the command succeeds when it should have failed, having the explain plan in the log may help.
+assert.commandFailedWithCode(testDB.runCommand(mrCmd), 31264, () => {
+ const explain = tojson(testDB.runCommand({explain: mrCmd}));
+ return `mapReduce command was expected to fail, but succeeded; explain plan is ${explain}`;
+});
st.stop();
}());