summaryrefslogtreecommitdiff
path: root/jstests/core/eval_mr.js
blob: 04de66affb085aad846deec7d8ef6422a0d0bfe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
// non-sharded collection because sharded collection exists already.
// @tags: [assumes_unsharded_collection]

// 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));
})();