0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

minor: add failing test case for profiler when system.profile doesn't exist

also test that dropping system.profile works, but only when profiling is off
This commit is contained in:
Mike Dirolf 2009-10-06 14:20:49 -04:00
parent 283572bebc
commit 103ae4cb6a

39
jstests/profile1.js Normal file
View File

@ -0,0 +1,39 @@
/* With pre-created system.profile (capped) */
db.runCommand({profile: 0});
db.getCollection("system.profile").drop();
assert(!db.getLastError(), "Z");
assert.eq(0, db.runCommand({profile: -1}).was, "A");
db.createCollection("system.profile", {capped: true, size: 1000});
db.runCommand({profile: 2});
assert.eq(2, db.runCommand({profile: -1}).was, "B");
assert.eq(1, db.system.profile.stats().capped, "C");
var capped_size = db.system.profile.storageSize();
assert.gt(capped_size, 999, "D");
assert.lt(capped_size, 2000, "E");
/* Make sure we can't drop if profiling is still on */
db.getCollection("system.profile").drop();
assert(db.getLastError(), "Y");
/* With pre-created system.profile (un-capped) */
db.runCommand({profile: 0});
db.getCollection("system.profile").drop();
assert.eq(0, db.runCommand({profile: -1}).was, "F");
db.createCollection("system.profile");
db.runCommand({profile: 2});
assert.eq(2, db.runCommand({profile: -1}).was, "G");
assert.eq(null, db.system.profile.stats().capped, "G1");
/* With no system.profile collection */
db.runCommand({profile: 0});
db.getCollection("system.profile").drop();
assert.eq(0, db.runCommand({profile: -1}).was, "H");
db.runCommand({profile: 2});
assert.eq(2, db.runCommand({profile: -1}).was, "I");
assert.eq(1, db.system.profile.stats().capped, "J");
var auto_size = db.system.profile.storageSize();
assert.gt(auto_size, capped_size, "K");