summaryrefslogtreecommitdiff
path: root/jstests/multiVersion
diff options
context:
space:
mode:
authorNicholas Zolnierz <nicholas.zolnierz@mongodb.com>2019-11-19 14:49:37 +0000
committerevergreen <evergreen@mongodb.com>2019-11-19 14:49:37 +0000
commit0bed872351365fa35107e0d9818d9066642a84a4 (patch)
tree069823b8122b461f50874b22fad3cab9982a3840 /jstests/multiVersion
parent4722a18440d6645a24f83def678f7cf7a6a290fe (diff)
downloadmongo-0bed872351365fa35107e0d9818d9066642a84a4.tar.gz
SERVER-44150 Enable MR tests for output mode 'reduce' with a non-trivial reduce function
Diffstat (limited to 'jstests/multiVersion')
-rw-r--r--jstests/multiVersion/map_reduce_multiversion_cluster.js42
-rw-r--r--jstests/multiVersion/map_reduce_multiversion_repl_set.js13
2 files changed, 23 insertions, 32 deletions
diff --git a/jstests/multiVersion/map_reduce_multiversion_cluster.js b/jstests/multiVersion/map_reduce_multiversion_cluster.js
index 79524c67067..e2020744610 100644
--- a/jstests/multiVersion/map_reduce_multiversion_cluster.js
+++ b/jstests/multiVersion/map_reduce_multiversion_cluster.js
@@ -68,10 +68,11 @@ function runValidMrTests(coll) {
}
function assertResultsValid(results, expectedCount) {
- assert.gt(results.length, 0);
- assert.lte(results.length, expectedCount);
+ assert.gt(results.length, 0, tojson(results));
+ assert.lte(results.length, expectedCount, tojson(results));
results.map(resultDoc => assert.eq(resultDoc.value.avgAge,
- resultDoc.value.total / resultDoc.value.count));
+ resultDoc.value.total / resultDoc.value.count,
+ tojson(results)));
}
// Inline output.
@@ -102,18 +103,14 @@ function runValidMrTests(coll) {
// Cache a sample result document to ensure that re-reducing actually occurs below.
let sampleDoc = mergeColl.findOne();
- // TODO SERVER-44150: Enable the following tests once the new implementation is able to
- // support re-reducing against an existing collection.
-
// Output mode "reduce" to an existing unsharded collection.
- // assert.commandWorked(coll.mapReduce(
- // map,
- // reduce,
- // {finalize: fin, out: {reduce: mergeColl.getName(), db:
- // mergeColl.getDB().getName()}}));
- // res = mergeColl.find().toArray();
- // assertResultsValid(res, states.length);
- // assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
+ assert.commandWorked(coll.mapReduce(
+ map,
+ reduce,
+ {finalize: fin, out: {reduce: mergeColl.getName(), db: mergeColl.getDB().getName()}}));
+ res = mergeColl.find().toArray();
+ assertResultsValid(res, states.length);
+ assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
// Drop and recreate the target collection as sharded.
mergeColl.drop();
@@ -142,17 +139,14 @@ function runValidMrTests(coll) {
// Cache a sample result document to ensure that re-reducing actually occurs below.
sampleDoc = mergeColl.findOne({_id: {$not: {$in: ["AL", "PA"]}}});
- // TODO SERVER-44150: Enable the following tests once the new implementation is able to
- // support re-reducing against an existing collection.
-
// Output mode "reduce" to an existing sharded collection.
- // assert.commandWorked(coll.mapReduce(map, reduce, {
- // finalize: fin,
- // out: {reduce: mergeColl.getName(), db: mergeColl.getDB().getName(), sharded: true}
- // }));
- // res = mergeColl.find().toArray();
- // assertResultsValid(res, states.length + 2);
- // assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
+ assert.commandWorked(coll.mapReduce(map, reduce, {
+ finalize: fin,
+ out: {reduce: mergeColl.getName(), db: mergeColl.getDB().getName(), sharded: true}
+ }));
+ res = mergeColl.find().toArray();
+ assertResultsValid(res, states.length + 2);
+ assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
}
// Test merge to a collection in the same database as the source collection.
diff --git a/jstests/multiVersion/map_reduce_multiversion_repl_set.js b/jstests/multiVersion/map_reduce_multiversion_repl_set.js
index 3ec026c7bbd..8853b9b5e9e 100644
--- a/jstests/multiVersion/map_reduce_multiversion_repl_set.js
+++ b/jstests/multiVersion/map_reduce_multiversion_repl_set.js
@@ -83,16 +83,13 @@ function runValidMrTests(db, coll) {
res = mergeColl.find().toArray();
assertResultsValid(res);
- // TODO SERVER-44150: Enable the following tests once the new implementation is able to
- // support re-reducing against an existing collection.
-
// Cache a sample result document to ensure that re-reducing actually occurs below.
- // const sampleDoc = mergeColl.findOne();
+ const sampleDoc = mergeColl.findOne();
- // // Output mode "reduce" to an existing collection.
- // assert.commandWorked(
- // coll.mapReduce(map, reduce, {finalize: fin, out: {reduce: mergeColl.getName()}}));
- // assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
+ // Output mode "reduce" to an existing collection.
+ assert.commandWorked(
+ coll.mapReduce(map, reduce, {finalize: fin, out: {reduce: mergeColl.getName()}}));
+ assert.gte(mergeColl.findOne({_id: sampleDoc._id}).value.avgAge, sampleDoc.value.avgAge);
}
//