summaryrefslogtreecommitdiff
path: root/jstests/core/eval_mr.js
blob: 4a3dc8dad6cd309d3d641f8d45c30480c5e29559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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));
})();