diff options
Diffstat (limited to 'jstests/core/administrative/profile/system_profile.js')
-rw-r--r-- | jstests/core/administrative/profile/system_profile.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/jstests/core/administrative/profile/system_profile.js b/jstests/core/administrative/profile/system_profile.js new file mode 100644 index 00000000000..ba03b39dbd0 --- /dev/null +++ b/jstests/core/administrative/profile/system_profile.js @@ -0,0 +1,75 @@ +// The test runs commands that are not allowed with security token: convertToCapped, mapReduce, +// profile. +// @tags: [ +// not_allowed_with_security_token, +// does_not_support_stepdowns, +// requires_capped, +// requires_collstats, +// requires_non_retryable_commands, +// requires_non_retryable_writes, +// requires_profiling, +// uses_map_reduce_with_temp_collections, +// ] + +// Test various user operations against "system.profile" collection. SERVER-18111. + +var testDB = db.getSiblingDB("system_profile"); +var testDBCopy = db.getSiblingDB("system_profile_copy"); + +// Create/drop should succeed. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("system.profile")); +testDB.system.profile.drop(); + +// convertToCapped should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("system.profile")); +assert.eq(false, testDB.system.profile.stats().capped); +assert.commandFailedWithCode(testDB.system.profile.convertToCapped(1024 * 1024), + ErrorCodes.BadValue); +assert.eq(false, testDB.system.profile.stats().capped); + +// Basic write operations should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("system.profile")); +assert.writeError(testDB.system.profile.insert({})); +assert.writeError(testDB.system.profile.update({}, {a: 1})); +assert.writeError(testDB.system.profile.update({}, {a: 1}, {upsert: true})); +assert.writeError(testDB.system.profile.remove({})); + +// Using findAndModify to write to "system.profile" should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("system.profile")); +assert.commandFailed( + testDB.system.profile.runCommand("findAndModify", {query: {}, update: {a: 1}})); +assert.commandFailed( + testDB.system.profile.runCommand("findAndModify", {query: {}, update: {a: 1}, upsert: true})); +assert.commandFailed(testDB.system.profile.runCommand("findAndModify", {query: {}, remove: true})); + +// Using mapReduce to write to "system.profile" should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.foo.insert({val: 1})); +assert.commandFailed(testDB.foo.runCommand("mapReduce", { + map: function() { + emit(0, this.val); + }, + reduce: function(id, values) { + return Array.sum(values); + }, + out: "system.profile" +})); + +// Using aggregate to write to "system.profile" should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.foo.insert({val: 1})); +assert.commandFailed(testDB.foo.runCommand("aggregate", {pipeline: [{$out: "system.profile"}]})); + +// Renaming to/from "system.profile" should fail. +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("system.profile")); +assert.commandFailed(testDB.adminCommand( + {renameCollection: testDB.system.profile.getFullName(), to: testDB.foo.getFullName()})); +assert.commandWorked(testDB.dropDatabase()); +assert.commandWorked(testDB.createCollection("foo")); +assert.commandFailed(testDB.adminCommand( + {renameCollection: testDB.foo.getFullName(), to: testDB.system.profile.getFullName()})); |