mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
SERVER-42129 modifies test to account for ephemeralForTest engine's missing oplog after restart.
This commit is contained in:
parent
f38eabe384
commit
45ff40ff0f
@ -3962,11 +3962,18 @@ var authCommandsLib = {
|
||||
command: {insert: "oplog.rs", documents: [{ts: Timestamp()}]},
|
||||
skipSharded: true,
|
||||
setup: function(db) {
|
||||
load("jstests/libs/storage_engine_utils.js");
|
||||
if (!db.getCollectionNames().includes("oplog.rs")) {
|
||||
assert.commandWorked(
|
||||
db.runCommand({create: "oplog.rs", capped: true, size: 10000}));
|
||||
} else {
|
||||
assert.commandWorked(db.adminCommand({replSetResizeOplog: 1, size: 10000}));
|
||||
if (storageEngineIsWiredTigerOrInMemory()) {
|
||||
assert.commandWorked(db.adminCommand({replSetResizeOplog: 1, size: 10000}));
|
||||
} else {
|
||||
assert.commandWorked(db.runCommand({drop: "oplog.rs"}));
|
||||
assert.commandWorked(
|
||||
db.runCommand({create: "oplog.rs", capped: true, size: 10000}));
|
||||
}
|
||||
}
|
||||
},
|
||||
teardown: function(db) {
|
||||
|
@ -3,4 +3,10 @@ function storageEngineIsWiredTigerOrInMemory() {
|
||||
// unspecified in the test options.
|
||||
return !jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger" ||
|
||||
jsTest.options().storageEngine === "inMemory";
|
||||
}
|
||||
|
||||
function storageEngineIsWiredTiger() {
|
||||
// We assume that WiredTiger is the default storage engine, if the storage engine is
|
||||
// unspecified in the test options.
|
||||
return !jsTest.options().storageEngine || jsTest.options().storageEngine === "wiredTiger";
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
// Tests that dropping the oplog is forbidden on standalone nodes with storage engines
|
||||
// that support the command "replSetResizeOplog". The support for this command is
|
||||
// provided only by the WiredTiger storage engine.
|
||||
// Therefore, attempts to drop the oplog when using these storage engines should fail.
|
||||
// Also, nodes running in a replica set will forbid dropping the oplog, but
|
||||
// for a different reason.
|
||||
// Note: We detect whether a storage engine supports the replSetResizeOplog command
|
||||
// by checking whether it supportsRecoveryTimestamp().
|
||||
/* Tests that dropping the oplog is forbidden on standalone nodes with storage engines
|
||||
* that support the command "replSetResizeOplog". The support for this command is
|
||||
* provided only by the WiredTiger storage engine.
|
||||
* Therefore, attempts to drop the oplog when using these storage engines should fail.
|
||||
* Also, nodes running in a replica set will forbid dropping the oplog, but
|
||||
* for a different reason.
|
||||
* Note: We detect whether a storage engine supports the replSetResizeOplog command
|
||||
* by checking whether it supportsRecoveryTimestamp().
|
||||
*
|
||||
* @tags: [requires_persistence]
|
||||
*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
@ -16,17 +20,18 @@
|
||||
nodes: 1
|
||||
});
|
||||
|
||||
rt.startSet();
|
||||
|
||||
rt.initiate();
|
||||
|
||||
// Restart as a standalone node.
|
||||
rt.restart(0, {noReplSet: true});
|
||||
// Start as a standalone node.
|
||||
rt.start(0, {noReplSet: true});
|
||||
|
||||
let master = rt.getPrimary();
|
||||
let localDB = master.getDB('local');
|
||||
|
||||
if (storageEngineIsWiredTigerOrInMemory()) {
|
||||
// Standalone nodes don't start with an oplog; create one. The size of the oplog doesn't
|
||||
// matter. We are capping the oplog because some storage engines do not allow the creation
|
||||
// of uncapped oplog collections.
|
||||
assert.commandWorked(localDB.runCommand({create: 'oplog.rs', capped: true, size: 1000}));
|
||||
|
||||
if (storageEngineIsWiredTiger()) {
|
||||
const ret = assert.commandFailed(localDB.runCommand({drop: 'oplog.rs'}));
|
||||
assert.eq("can't drop oplog on storage engines that support replSetResizeOplog command",
|
||||
ret.errmsg);
|
||||
|
Loading…
Reference in New Issue
Block a user