summaryrefslogtreecommitdiff
path: root/jstests/core/eval_mr.js
blob: 84a929035d6bc3f3cde4d278327ac7c1f4b1def1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test that the eval command can't be used to invoke the mapReduce command.  SERVER-17889.
(function() {
    "use strict";
    db.eval_mr.drop();
    db.eval_mr_out.drop();
    assert.writeOK(db.eval_mr.insert({val: 1}));
    assert.writeOK(db.eval_mr.insert({val: 2}));
    var runBasicMapReduce = function() {
        return db.eval_mr.runCommand("mapReduce",
                                     {map: function() { emit(0, this.val); },
                                      reduce: function(id, values) { return Array.sum(values); },
                                      out: {replace: "eval_mr_out"}});
    };
    assert.commandWorked(runBasicMapReduce());
    assert.eq(3, db.eval_mr_out.findOne().value);
    assert.commandFailed(db.eval(runBasicMapReduce));
})();