summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/list_collections_large_number.js
blob: 2b0b5d53926cda9c62c739c2eab585de4e97754e (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
27
28
29
30
31
32
33
34
/**
 * Tests that "listCollections" command successfully returns results when the database has a very
 * large number of collections.
 * @tags: [
 *  resource_intensive,
 * ]
 */
(function() {
"use strict";

const conn = MongoRunner.runMongod({});
assert.neq(null, conn, "mongod was unable to start up");
const db = conn.getDB(jsTestName());

const validatorObj = {
    $jsonSchema: {
        bsonType: "object",
        properties: {
            s: {bsonType: "string", description: "x".repeat(4801)},

        }
    }
};
const nCollections = 3300;
jsTestLog(`Creating ${nCollections} collections....`);
for (let i = 0; i < nCollections; i++) {
    assert.commandWorked(db.createCollection("c_" + i.toPrecision(6), {validator: validatorObj}));
}
jsTestLog(`Done creating ${nCollections} collections`);
assert.commandWorked(db.runCommand({"listCollections": 1}));

// Do not validate collections since that is an expensive action.
MongoRunner.stopMongod(conn, undefined, {skipValidation: true});
})();