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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/**
* Tests that resizing the oplog works as expected and validates input arguments.
*
* @tags: [
* requires_replication,
* requires_wiredtiger,
* ]
*/
(function() {
"use strict";
let replSet = new ReplSetTest({nodes: 2, oplogSize: 50});
replSet.startSet();
replSet.initiate();
let primary = replSet.getPrimary();
const MB = 1024 * 1024;
const GB = 1024 * MB;
const PB = 1024 * GB;
const EB = 1024 * PB;
assert.eq(primary.getDB('local').oplog.rs.stats().maxSize, 50 * MB);
// Too small: 990MB
assert.commandFailedWithCode(primary.getDB('admin').runCommand({replSetResizeOplog: 1, size: 900}),
51024, // IDL Error code for invalid fields
"Expected replSetResizeOplog to fail because the size was too small");
// Way too small: -1GB
assert.commandFailedWithCode(
primary.getDB('admin').runCommand({replSetResizeOplog: 1, size: -1 * GB / MB}),
51024, // IDL Error code for invalid fields
"Expected replSetResizeOplog to fail because the size was too small");
// Too big: 8EB
assert.commandFailedWithCode(
primary.getDB('admin').runCommand({replSetResizeOplog: 1, size: 8 * EB / MB}),
51024, // IDL Error code for invalid fields
"Expected replSetResizeOplog to fail because the size was too big");
// Min Retention Hours not valid: -1hr
assert.commandFailedWithCode(
primary.getDB('admin').runCommand({replSetResizeOplog: 1, size: 990, minRetentionHours: -1}),
51024, // IDL Error code for invalid fields
"Expected replSetResizeOplog to fail because the minimum retention hours was too low");
// The maximum: 1PB
assert.commandWorked(primary.getDB('admin').runCommand({replSetResizeOplog: 1, size: 1 * PB / MB}));
// Valid size and minRetentionHours
assert.commandWorked(primary.getDB('admin').runCommand(
{replSetResizeOplog: 1, size: 1 * PB / MB, minRetentionHours: 5}));
// Valid minRetentionHours with no size parameter.
assert.commandWorked(
primary.getDB('admin').runCommand({replSetResizeOplog: 1, minRetentionHours: 1}));
assert.eq(primary.getDB('local').oplog.rs.stats().maxSize, 1 * PB);
replSet.stopSet();
})();
|