blob: 1d2a40578c95fce3eb051c883cd8cf7108656e44 (
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
44
45
46
47
|
// The test runs commands that are not allowed with security token: setProfilingLevel.
// @tags: [
// not_allowed_with_security_token,
// does_not_support_stepdowns,
// requires_getmore,
// requires_profiling,
// ]
// Confirms that a listCollections command is not profiled.
(function() {
"use strict";
// For 'getLatestProfilerEntry()'.
load("jstests/libs/profiler.js");
var testDB = db.getSiblingDB("profile_list_collections");
assert.commandWorked(testDB.dropDatabase());
const numCollections = 5;
for (let i = 0; i < numCollections; ++i) {
assert.commandWorked(testDB.runCommand({create: "test_" + i}));
}
testDB.setProfilingLevel(2);
const profileEntryFilter = {
op: "command",
command: "listCollections"
};
let cmdRes = assert.commandWorked(testDB.runCommand({listCollections: 1, cursor: {batchSize: 1}}));
// We don't profile listCollections commands.
assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(),
0,
"Did not expect any profile entry for a listCollections command");
const getMoreCollName = cmdRes.cursor.ns.substr(cmdRes.cursor.ns.indexOf(".") + 1);
cmdRes = assert.commandWorked(
testDB.runCommand({getMore: cmdRes.cursor.id, collection: getMoreCollName}));
// A listCollections cursor doesn't really have a namespace to use to record profile entries, so
// does not get recorded in the profile.
assert.throws(() => getLatestProfilerEntry(testDB, {op: "getmore"}),
[],
"Did not expect to find entry for getMore on a listCollections cursor");
})();
|