summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/drop_oplog_should_fail_if_storage_engine_supports_replSetResizeOplog_command.js
blob: 20d4b93049b187a5498f5d3f872cd3ec90e59f54 (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
/* 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,
 *  # Multiversion testing is not supported for tests running ReplSetTest as standalones.
 *  multiversion_incompatible,
 * ]
 */

(function() {
"use strict";

load("jstests/libs/storage_engine_utils.js");

// Start a standalone node.
let primary = MongoRunner.runMongod();
let localDB = primary.getDB('local');

// 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);
} else {
    assert.commandWorked(localDB.runCommand({drop: 'oplog.rs'}));
}

MongoRunner.stopMongod(primary);
}());