2017-10-13 23:37:14 +02:00
|
|
|
// Test that dropping the replset oplog, the local database, and the admin database are all
|
|
|
|
// prohibited in a replset.
|
2014-11-10 20:52:32 +01:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"use strict";
|
|
|
|
let rt = new ReplSetTest({name: "drop_oplog", nodes: 1, oplogSize: 30});
|
2014-11-10 20:52:32 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let nodes = rt.startSet();
|
|
|
|
rt.initiate();
|
|
|
|
let master = rt.getPrimary();
|
|
|
|
let localDB = master.getDB('local');
|
2014-11-10 20:52:32 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let threw = false;
|
2015-04-20 21:36:09 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let ret = assert.commandFailed(localDB.runCommand({drop: 'oplog.rs'}));
|
|
|
|
assert.eq('can\'t drop live oplog while replicating', ret.errmsg);
|
2015-04-20 21:36:09 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let dropOutput = localDB.dropDatabase();
|
|
|
|
assert.eq(dropOutput.ok, 0);
|
|
|
|
assert.eq(dropOutput.errmsg, "Cannot drop 'local' database while replication is active");
|
2014-11-10 20:52:32 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let adminDB = master.getDB('admin');
|
|
|
|
dropOutput = adminDB.dropDatabase();
|
|
|
|
assert.eq(dropOutput.ok, 0);
|
|
|
|
assert.eq(dropOutput.errmsg, "Dropping the 'admin' database is prohibited.");
|
2017-10-13 23:37:14 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let renameOutput = localDB.oplog.rs.renameCollection("poison");
|
|
|
|
assert.eq(renameOutput.ok, 0);
|
|
|
|
assert.eq(renameOutput.errmsg, "can't rename live oplog while replicating");
|
2014-11-10 20:52:32 +01:00
|
|
|
|
2019-08-14 15:52:59 +02:00
|
|
|
assert.commandWorked(localDB.foo.insert({a: 1}));
|
2019-07-27 00:20:35 +02:00
|
|
|
renameOutput = localDB.foo.renameCollection("oplog.rs");
|
|
|
|
assert.eq(renameOutput.ok, 0);
|
|
|
|
assert.eq(renameOutput.errmsg, "can't rename to live oplog while replicating");
|
|
|
|
rt.stopSet();
|
2014-11-10 20:52:32 +01:00
|
|
|
}());
|