summaryrefslogtreecommitdiff
path: root/jstests/core/collStats_numericOnly.js
blob: b5927700ddf69fbe96b4dc8dd67197f00e1b8ce4 (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
35
36
37
38
39
40
41
42
43
/**
 * Tests that collStats does not return expensive creationString field when numericOnly is true.
 * @tags: [requires_wiredtiger, requires_fcv_52, requires_collstats]
 */
(function() {
"use strict";

// Grab the storage engine, default is wiredTiger
var storageEngine = jsTest.options().storageEngine || "wiredTiger";

// Although this test is tagged with 'requires_wiredtiger', this is not sufficient for ensuring
// that the parallel suite runs this test only on WT configurations. See SERVER-36181.
if (storageEngine !== 'wiredTiger') {
    jsTest.log('Skipping test because storageEngine is not "wiredTiger"');
    return;
}

const dbName = "test";
const collName = "collStats_numericOnly";

const testDB = db.getSiblingDB(dbName);
const testColl = testDB.getCollection(collName);

assert.commandWorked(testColl.insert({a: 1}));

{
    // The collStats result should not contain the creationString field.
    const res = assert.commandWorked(testDB.runCommand({collStats: collName, numericOnly: true}));
    assert(res.hasOwnProperty("wiredTiger"));
    assert(res.wiredTiger.hasOwnProperty("cache"));
    assert(!res.wiredTiger.hasOwnProperty("creationString"));
    assert(!res.wiredTiger.hasOwnProperty("metadata"));
}

{
    // By default the creationString field should exist.
    const res = assert.commandWorked(testDB.runCommand({collStats: collName}));
    assert(res.hasOwnProperty("wiredTiger"));
    assert(res.wiredTiger.hasOwnProperty("cache"));
    assert(res.wiredTiger.hasOwnProperty("creationString"));
    assert(res.wiredTiger.hasOwnProperty("metadata"));
}
})();