summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/capped_deletes_within_startup_recovery.js
blob: 1ad13296373ffa867aebbbff091104a3104abda7 (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
/**
 * Tests that capped deletes occur during statup recovery on documents inserted earlier in startup
 * recovery.
 *
 * @tags: [
 *   requires_replication,
 * ]
 */
(function() {
'use strict';

load('jstests/libs/fail_point_util.js');

const replTest = new ReplSetTest({nodes: 1});
replTest.startSet();
replTest.initiate();

const primary = replTest.getPrimary();
const testDB = primary.getDB('test');
const coll = testDB.getCollection(jsTestName());

assert.commandWorked(testDB.createCollection(coll.getName(), {capped: true, size: 100, max: 1}));

const ts = assert.commandWorked(testDB.runCommand({insert: coll.getName(), documents: [{a: 1}]}))
               .operationTime;
configureFailPoint(primary, 'holdStableTimestampAtSpecificTimestamp', {timestamp: ts});

assert.commandWorked(coll.insert([{b: 1}, {b: 2}]));
replTest.restart(primary);

// Stopping the test fixture runs validate with {enforceFastCount: true}. This will cause collection
// validation to fail if startup recovery did not perform capped deletes on documents that were
// inserted earlier in startup recovery.
replTest.stopSet();
})();