diff options
Diffstat (limited to 'jstests/core/profile_list_collections.js')
-rw-r--r-- | jstests/core/profile_list_collections.js | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/jstests/core/profile_list_collections.js b/jstests/core/profile_list_collections.js index 3db9e7971c9..cf6132e71c7 100644 --- a/jstests/core/profile_list_collections.js +++ b/jstests/core/profile_list_collections.js @@ -3,37 +3,39 @@ // Confirms that a listCollections command is not profiled. (function() { - "use strict"; +"use strict"; - // For getLatestProfilerEntry and getProfilerProtocolStringForCommand. - load("jstests/libs/profiler.js"); +// For getLatestProfilerEntry and getProfilerProtocolStringForCommand. +load("jstests/libs/profiler.js"); - var testDB = db.getSiblingDB("profile_list_collections"); - assert.commandWorked(testDB.dropDatabase()); - const numCollections = 5; - for (let i = 0; i < numCollections; ++i) { - assert.commandWorked(testDB.runCommand({create: "test_" + i})); - } +var testDB = db.getSiblingDB("profile_list_collections"); +assert.commandWorked(testDB.dropDatabase()); +const numCollections = 5; +for (let i = 0; i < numCollections; ++i) { + assert.commandWorked(testDB.runCommand({create: "test_" + i})); +} - testDB.setProfilingLevel(2); +testDB.setProfilingLevel(2); - const profileEntryFilter = {op: "command", command: "listCollections"}; +const profileEntryFilter = { + op: "command", + command: "listCollections" +}; - let cmdRes = - assert.commandWorked(testDB.runCommand({listCollections: 1, cursor: {batchSize: 1}})); +let cmdRes = assert.commandWorked(testDB.runCommand({listCollections: 1, cursor: {batchSize: 1}})); - // We don't profile listCollections commands. - assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(), - 0, - "Did not expect any profile entry for a listCollections command"); +// We don't profile listCollections commands. +assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(), + 0, + "Did not expect any profile entry for a listCollections command"); - const getMoreCollName = cmdRes.cursor.ns.substr(cmdRes.cursor.ns.indexOf(".") + 1); - cmdRes = assert.commandWorked( - testDB.runCommand({getMore: cmdRes.cursor.id, collection: getMoreCollName})); +const getMoreCollName = cmdRes.cursor.ns.substr(cmdRes.cursor.ns.indexOf(".") + 1); +cmdRes = assert.commandWorked( + testDB.runCommand({getMore: cmdRes.cursor.id, collection: getMoreCollName})); - // A listCollections cursor doesn't really have a namespace to use to record profile entries, so - // does not get recorded in the profile. - assert.throws(() => getLatestProfilerEntry(testDB, {op: "getmore"}), - [], - "Did not expect to find entry for getMore on a listCollections cursor"); +// A listCollections cursor doesn't really have a namespace to use to record profile entries, so +// does not get recorded in the profile. +assert.throws(() => getLatestProfilerEntry(testDB, {op: "getmore"}), + [], + "Did not expect to find entry for getMore on a listCollections cursor"); })(); |