summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/distinct_cmd_response_too_large.js
blob: 79f8d73c82cc70230502e1d7081eeae89c823690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Confirms that mongod will return an error when the result generated for a distinct command
 * exceeds MaxBSONSize.
 */
(function() {
"use strict";

const conn = MongoRunner.runMongod();
const db = conn.getDB('test');
const coll = db.test;

const largeString = new Array(1000 * 1000).join('x');

let bulk = coll.initializeUnorderedBulkOp();
for (let x = 0; x < 17; ++x) {
    bulk.insert({_id: (largeString + x.toString())});
}
assert.commandWorked(bulk.execute());

assert.commandFailedWithCode(db.runCommand({distinct: "test", key: "_id", query: {}}), 17217);

MongoRunner.stopMongod(conn);
})();