blob: 5d94050d775c448b094aec64592ab61f89d3bdfa (
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
|
// Provides convenience methods for confirming system.profile content.
// Retrieve latest system.profile entry.
function getLatestProfilerEntry(inputDb, filter) {
if (filter === null) {
filter = {};
}
var cursor = inputDb.system.profile.find(filter).sort({$natural: -1});
assert(
cursor.hasNext(),
"could not find any entries in the profile collection matching filter: " + tojson(filter));
return cursor.next();
}
// Returns a string representing the wire protocol used for commands run on the given connection.
// This string matches the system.profile "protocol" field when commands are profiled.
function getProfilerProtocolStringForCommand(conn) {
if ("opQueryOnly" === conn.getClientRPCProtocols()) {
return "op_query";
}
return "op_command";
}
// Throws an assertion if the profiler does not contain exactly one entry matching <filter>.
// Optional arguments <errorMsgFilter> and <errorMsgProj> limit profiler output if this asserts.
function profilerHasSingleMatchingEntryOrThrow(inputDb, filter, errorMsgFilter, errorMsgProj) {
assert.eq(inputDb.system.profile.find(filter).itcount(),
1,
"Expected exactly one op matching: " + tojson(filter) + " in profiler " +
tojson(inputDb.system.profile.find(errorMsgFilter, errorMsgProj).toArray()));
}
|