blob: 51e70f4dc5d6d168e17ad56a8f4be016729e4bf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Test that reading the profiling level doesn't create databases, but setting it does.
(function(db) {
'use strict';
function dbExists() {
return Array.contains(db.getMongo().getDBNames(), db.getName());
}
db = db.getSiblingDB('profile_no_such_db'); // Note: changes db argument not global var.
assert.commandWorked(db.dropDatabase());
assert(!dbExists());
// Reading the profiling level shouldn't create the database.
var defaultProfilingLevel = db.getProfilingLevel();
assert(!dbExists());
// This test assumes that the default profiling level hasn't been changed.
assert.eq(defaultProfilingLevel, 0);
[0, 1, 2].forEach(function(level) {
jsTest.log('Testing profiling level ' + level);
// Setting the profiling level creates the database.
// Note: in storage engines other than MMAPv1 setting the profiling level to 0 puts the
// database
// in a weird state where it exists internally, but doesn't show up in listDatabases, and
// won't
// exist if you restart the server.
var res = db.setProfilingLevel(level);
assert.eq(res.was, defaultProfilingLevel);
assert(dbExists() || level == 0);
assert.eq(db.getProfilingLevel(), level);
// Dropping the db reverts the profiling level to the default.
assert.commandWorked(db.dropDatabase());
assert.eq(db.getProfilingLevel(), defaultProfilingLevel);
assert(!dbExists());
});
}(db));
|