Files
mongo/jstests/core/write/no_db_created.js
Joshua Siegel 169f8dc283 SERVER-111817 Add tag to exclude tests from timeseries CRUD suite (#44113)
GitOrigin-RevId: a3ab3b89275fa89c9824f6af467d56d605096159
2025-11-21 18:08:16 +00:00

42 lines
1.3 KiB
JavaScript

// Checks that some operations do not create a database
//
// @tags: [
// assumes_no_implicit_collection_creation_on_get_collection,
// # The test runs commands that are not allowed with security token: compact.
// not_allowed_with_signed_security_token,
// requires_non_retryable_commands,
// uses_compact,
// # The passthrough creates collections implicitly.
// exclude_from_timeseries_crud_passthrough,
// ]
let adminDB = db.getSiblingDB("admin");
let noDB = function (db) {
let dbName = db.getName();
let dbsRes = assert.commandWorked(adminDB.runCommand("listDatabases"));
dbsRes.databases.forEach(function (e) {
assert.neq(dbName, e.name, "Found db which shouldn't exist:" + dbName + "; " + tojson(dbsRes));
});
};
let mydb = db.getSiblingDB("neverCreated");
mydb.dropDatabase();
noDB(mydb);
let coll = mydb.fake;
// force:true is for replset passthroughs
assert.commandFailed(coll.runCommand("compact", {force: true}));
noDB(mydb);
assert.commandWorked(coll.insert({}));
mydb.dropDatabase();
assert.commandFailed(coll.runCommand("dropIndexes"));
noDB(mydb);
assert.commandWorked(coll.insert({}));
mydb.dropDatabase();
assert.commandFailed(coll.runCommand("collMod", {expireAfterSeconds: 1}));
noDB(mydb);
assert.commandWorked(coll.insert({}));
mydb.dropDatabase();