summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@mongodb.com>2019-12-11 21:33:49 +0000
committerevergreen <evergreen@mongodb.com>2019-12-11 21:33:49 +0000
commit57acc8b666b8c9dfc34eaf03c226ab26ac225781 (patch)
tree1a0971f0cce77fc5178fc48952770dc164818b22 /jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js
parent3da6513067131a50323f3388b8dc2918da885732 (diff)
downloadmongo-57acc8b666b8c9dfc34eaf03c226ab26ac225781.tar.gz
SERVER-44475 Remove Query Knob
Diffstat (limited to 'jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js')
-rw-r--r--jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js88
1 files changed, 41 insertions, 47 deletions
diff --git a/jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js b/jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js
index 52bd8b22ceb..e2bd18146e4 100644
--- a/jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js
+++ b/jstests/noPassthroughWithMongod/mapreduce_intermediate_reduce.js
@@ -1,47 +1,41 @@
-// This test validates that map/reduce runs intermediate reduce steps in order to keep the
-// in-memory state small. See SERVER-12949 for more details.
-//
-function assertGLEOK(status) {
- assert(status.ok && status.err === null, "Expected OK status object; found " + tojson(status));
-}
-
-var db = db.getSisterDB("MapReduceTestDB");
-db.dropDatabase();
-
-var coll = db.getCollection("mrInput");
-
-// Insert 10 x 49 elements (10 i-s, 49 j-s)
-//
-var expectedOutColl = [];
-
-var bulk = coll.initializeUnorderedBulkOp();
-for (var i = 0; i < 10; i++) {
- for (var j = 1; j < 50; j++) {
- bulk.insert({idx: i, j: j});
- }
- expectedOutColl.push({_id: i, value: j - 1});
-}
-assert.commandWorked(bulk.execute());
-
-function mapFn() {
- emit(this.idx, 1);
-}
-function reduceFn(key, values) {
- return Array.sum(values);
-}
-
-var out = coll.mapReduce(mapFn, reduceFn, {out: {replace: "mrOutput"}});
-
-// Check the output is as expected
-//
-var outColl = db.getCollection("mrOutput").find().toArray();
-assert.eq(outColl, expectedOutColl, "The output collection is incorrect.");
-
-assert.eq(out.counts.input, 490, "input count is wrong");
-assert.eq(out.counts.emit, 490, "emit count is wrong");
-
-// If this fails, most probably some of the configuration settings under mongo::mr::Config have
-// changed, such as reduceTriggerRatio or maxInMemSize. If not the case, then something else
-// must have changed with when intermediate reduces occur (see mongo::mr::State::checkSize).
-//
-assert.eq(out.counts.reduce, 14, "reduce count is wrong");
+// This test validates that map/reduce runs intermediate reduce steps in order to keep the
+// in-memory state small. See SERVER-12949 for more details.
+
+load("jstests/aggregation/extras/utils.js"); // For resultsEq
+(function() {
+"use strict";
+
+function assertGLEOK(status) {
+ assert(status.ok && status.err === null, "Expected OK status object; found " + tojson(status));
+}
+
+db = db.getSisterDB("MapReduceTestDB");
+db.dropDatabase();
+
+var coll = db.getCollection("mrInput");
+
+// Insert 10 x 49 elements (10 i-s, 49 j-s)
+var expectedOutColl = [];
+
+var bulk = coll.initializeUnorderedBulkOp();
+for (var i = 0; i < 10; i++) {
+ for (var j = 1; j < 50; j++) {
+ bulk.insert({idx: i, j: j});
+ }
+ expectedOutColl.push({_id: i, value: j - 1});
+}
+assert.commandWorked(bulk.execute());
+
+function mapFn() {
+ emit(this.idx, 1);
+}
+function reduceFn(key, values) {
+ return Array.sum(values);
+}
+
+var out = coll.mapReduce(mapFn, reduceFn, {out: {replace: "mrOutput"}});
+
+// Check the output is as expected
+var outColl = db.getCollection("mrOutput").find().toArray();
+assert(resultsEq(outColl, expectedOutColl));
+})();