diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2016-11-15 16:17:19 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-03-15 11:03:44 -0400 |
commit | 584ca76de9ee66b3e11987e640f5317ae40975e4 (patch) | |
tree | db52f1717155c295437f1b4fa41a5db295183669 /jstests/core/profile_repair_cursor.js | |
parent | f05b9437fbdc53deecf55ed3c20e36af3d733953 (diff) | |
download | mongo-584ca76de9ee66b3e11987e640f5317ae40975e4.tar.gz |
SERVER-22541 Manage aggregation cursors on global cursor manager.
Moves registration of aggregation cursors to the global cursor manager.
This simplifies the logic for acquiring locks and resolving view
namespaces within the getMore and killCursors commands.
Diffstat (limited to 'jstests/core/profile_repair_cursor.js')
-rw-r--r-- | jstests/core/profile_repair_cursor.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/core/profile_repair_cursor.js b/jstests/core/profile_repair_cursor.js new file mode 100644 index 00000000000..80055a6230c --- /dev/null +++ b/jstests/core/profile_repair_cursor.js @@ -0,0 +1,39 @@ +// Confirms that a repairCursor 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_repair_cursor"); + var testColl = testDB.testColl; + assert.commandWorked(testDB.dropDatabase()); + + // Insert some data to scan over. + assert.writeOK(testColl.insert([{}, {}, {}, {}])); + + testDB.setProfilingLevel(2); + + const repairCursorCmd = {repairCursor: testColl.getName()}; + const profileEntryFilter = {op: "command", command: repairCursorCmd}; + + let cmdRes = testDB.runCommand(repairCursorCmd); + if (cmdRes.code === ErrorCodes.CommandNotSupported) { + // Some storage engines do not support this command, so we can skip this test. + return; + } + assert.commandWorked(cmdRes); + + assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(), + 1, + "expected to find profile entry for a repairCursor 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"}); + assert.eq(getMoreProfileEntry.originatingCommand, repairCursorCmd); +})(); |