There are likely more JavaScript tests which have been added since
r3.6.9 that still need to be tagged.
(cherry picked from commit 05ec08fa62)
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
// Test that the plan summary string appears in db.currentOp() for count operations. SERVER-14064.
|
|
//
|
|
// @tags: [
|
|
// # This test attempts to perform a find command and find it using the currentOp command. The
|
|
// # former operation may be routed to a secondary in the replica set, whereas the latter must be
|
|
// # routed to the primary.
|
|
// assumes_read_preference_unchanged,
|
|
// does_not_support_stepdowns,
|
|
// # Uses $where operator
|
|
// requires_scripting,
|
|
// uses_multiple_connections,
|
|
// ]
|
|
|
|
var t = db.jstests_count_plan_summary;
|
|
t.drop();
|
|
|
|
for (var i = 0; i < 1000; i++) {
|
|
t.insert({x: 1});
|
|
}
|
|
|
|
// Mock a long-running count operation by sleeping for each of
|
|
// the documents in the collection.
|
|
var awaitShell =
|
|
startParallelShell("db.jstests_count_plan_summary.find({x: 1, $where: 'sleep(100)'}).count()");
|
|
|
|
// Find the count op in db.currentOp() and check for the plan summary.
|
|
assert.soon(function() {
|
|
var current = db.currentOp({ns: t.getFullName(), "command.count": t.getName()});
|
|
|
|
assert("inprog" in current);
|
|
if (current.inprog.length === 0) {
|
|
print("Did not find count op. db.currentOp() output:");
|
|
printjson(current);
|
|
return false;
|
|
}
|
|
|
|
// There are no indices, so the plan summary should be a collscan.
|
|
var countOp = current.inprog[0];
|
|
if (!("planSummary" in countOp)) {
|
|
print("count op does not yet contain planSummary:");
|
|
printjson(countOp);
|
|
return false;
|
|
}
|
|
|
|
// There are no indices, so the planSummary should be "COLLSCAN".
|
|
print("Found count op with planSummary:");
|
|
printjson(countOp);
|
|
assert.eq("COLLSCAN", countOp.planSummary, "wrong planSummary string");
|
|
|
|
// Kill the op so that the test won't run for a long time.
|
|
db.killOp(countOp.opid);
|
|
|
|
return true;
|
|
});
|
|
|
|
var exitCode = awaitShell({checkExitSuccess: false});
|
|
assert.neq(0, exitCode, "expected shell to exit abnormally due to JS execution being terminated");
|