summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-04-06 09:42:22 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-04-06 09:42:22 -0400
commit2f1c0cfb1704caa14e8fec482ee5bcd16081cfed (patch)
treeae69f12ba6a36551332b868ee6c84974e4d875f8 /jstests
parentb26dabc3c9c542ceb13314959603747ee36347de (diff)
downloadmongo-2f1c0cfb1704caa14e8fec482ee5bcd16081cfed.tar.gz
SERVER-28304 Profiler level 2 should not filter on sample rate
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/profile_sampling.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/jstests/core/profile_sampling.js b/jstests/core/profile_sampling.js
index 6ad60060845..d235c945f04 100644
--- a/jstests/core/profile_sampling.js
+++ b/jstests/core/profile_sampling.js
@@ -3,12 +3,12 @@
"use strict";
// Use a special db to support running other tests in parallel.
- var profileDB = db.getSisterDB("profile_sampling");
- var coll = profileDB.profile_sampling;
+ const profileDB = db.getSisterDB("profile_sampling");
+ const coll = profileDB.profile_sampling;
profileDB.dropDatabase();
- var originalProfilingSettings;
+ let originalProfilingSettings;
try {
originalProfilingSettings = assert.commandWorked(profileDB.setProfilingLevel(0));
profileDB.system.profile.drop();
@@ -17,29 +17,41 @@
profileDB.createCollection(coll.getName());
assert.writeOK(coll.insert({x: 1}));
- assert.commandWorked(profileDB.setProfilingLevel(2, {sampleRate: 0}));
+ assert.commandWorked(profileDB.setProfilingLevel(1, {sampleRate: 0, slowms: -1}));
assert.neq(null, coll.findOne({x: 1}));
assert.eq(1, coll.find({x: 1}).count());
assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}}));
- profileDB.setProfilingLevel(0);
+ assert.commandWorked(profileDB.setProfilingLevel(0));
- profileDB.system.profile.find().forEach(printjson);
assert.eq(0, profileDB.system.profile.count());
profileDB.system.profile.drop();
- assert.commandWorked(profileDB.setProfilingLevel(2, {sampleRate: 0.5}));
+ assert.commandWorked(profileDB.setProfilingLevel(1, {sampleRate: 0.5, slowms: -1}));
// This should generate about 500 profile log entries.
- for (var i = 0; i < 500; i++) {
+ for (let i = 0; i < 500; i++) {
assert.neq(null, coll.findOne({x: 1}));
assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}}));
}
- profileDB.setProfilingLevel(0);
+ assert.commandWorked(profileDB.setProfilingLevel(0));
assert.between(10, profileDB.system.profile.count(), 990);
+ profileDB.system.profile.drop();
+
+ // Profiling level of 2 should log all operations, regardless of sample rate setting.
+ assert.commandWorked(profileDB.setProfilingLevel(2, {sampleRate: 0}));
+ // This should generate exactly 1000 profile log entries.
+ for (let i = 0; i < 5; i++) {
+ assert.neq(null, coll.findOne({x: 1}));
+ assert.writeOK(coll.update({x: 1}, {$inc: {a: 1}}));
+ }
+ assert.commandWorked(profileDB.setProfilingLevel(0));
+ assert.eq(10, profileDB.system.profile.count());
+ profileDB.system.profile.drop();
+
} finally {
let profileCmd = {};
profileCmd.profile = originalProfilingSettings.was;