blob: b94ee6b422b75016c991f181edb70d2bf49b4e7a (
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
48
|
// @tags: [does_not_support_stepdowns, requires_getmore, requires_profiling]
// Confirms that a listIndexes command and subsequent getMores of its cursor are profiled correctly.
(function() {
"use strict";
// For getLatestProfilerEntry and getProfilerProtocolStringForCommand.
load("jstests/libs/profiler.js");
var testDB = db.getSiblingDB("profile_list_indexes");
var testColl = testDB.testColl;
assert.commandWorked(testDB.dropDatabase());
const numIndexes = 5;
for (let i = 0; i < numIndexes; ++i) {
let indexSpec = {};
indexSpec["fakeField_" + i] = 1;
assert.commandWorked(testColl.ensureIndex(indexSpec));
}
testDB.setProfilingLevel(2);
const listIndexesCommand = {
listIndexes: testColl.getName(),
cursor: {batchSize: 1}
};
const profileEntryFilter = {
op: "command"
};
for (var field in listIndexesCommand) {
profileEntryFilter['command.' + field] = listIndexesCommand[field];
}
let cmdRes = assert.commandWorked(testDB.runCommand(listIndexesCommand));
assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(),
1,
"Expected to find profile entry for a listIndexes command");
const getMoreCollName = cmdRes.cursor.ns.substr(cmdRes.cursor.ns.indexOf(".") + 1);
cmdRes = assert.commandWorked(
testDB.runCommand({getMore: cmdRes.cursor.id, collection: getMoreCollName}));
const getMoreProfileEntry = getLatestProfilerEntry(testDB, {op: "getmore"});
for (var field in listIndexesCommand) {
assert.eq(getMoreProfileEntry.originatingCommand[field], listIndexesCommand[field], field);
}
})();
|