blob: e3cde4f2adaa47bef27bcd3468985852ed62d189 (
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
|
// Confirms that a parallelCollectionScan 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_parallel_collection_scan");
var testColl = testDB.testColl;
assert.commandWorked(testDB.dropDatabase());
// Insert some data to scan over.
assert.writeOK(testColl.insert([{}, {}, {}, {}]));
testDB.setProfilingLevel(2);
const parallelCollectionScanCmd = {parallelCollectionScan: testColl.getName(), numCursors: 1};
const profileEntryFilter = {op: "command"};
for (var field in parallelCollectionScanCmd) {
profileEntryFilter['command.' + field] = parallelCollectionScanCmd[field];
}
let cmdRes = assert.commandWorked(testDB.runCommand(parallelCollectionScanCmd));
assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(),
1,
"expected to find profile entry for a parallelCollectionScan command");
const firstCursor = cmdRes.cursors[0].cursor;
const getMoreCollName = firstCursor.ns.substr(firstCursor.ns.indexOf(".") + 1);
cmdRes = assert.commandWorked(
testDB.runCommand({getMore: firstCursor.id, collection: getMoreCollName}));
const getMoreProfileEntry = getLatestProfilerEntry(testDB, {op: "getmore"});
for (var field in parallelCollectionScanCmd) {
assert.eq(
getMoreProfileEntry.originatingCommand[field], parallelCollectionScanCmd[field], field);
}
})();
|