summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/capped_deletes_within_rollback.js38
-rw-r--r--jstests/noPassthrough/capped_deletes_within_startup_recovery.js45
2 files changed, 83 insertions, 0 deletions
diff --git a/jstests/noPassthrough/capped_deletes_within_rollback.js b/jstests/noPassthrough/capped_deletes_within_rollback.js
new file mode 100644
index 00000000000..8ba6a13e1f7
--- /dev/null
+++ b/jstests/noPassthrough/capped_deletes_within_rollback.js
@@ -0,0 +1,38 @@
+/**
+ * Tests that capped deletes occur during rollback on documents inserted earlier in rollback.
+ *
+ * @tags: [
+ * requires_replication,
+ * ]
+ */
+(function() {
+'use strict';
+
+load('jstests/replsets/libs/rollback_test.js');
+
+const rollbackTest = new RollbackTest(jsTestName());
+
+const testDB = function() {
+ return rollbackTest.getPrimary().getDB('test');
+};
+
+const coll = function() {
+ return testDB().getCollection(jsTestName());
+};
+
+assert.commandWorked(
+ testDB().createCollection(coll().getName(), {capped: true, size: 100, max: 1}));
+assert.commandWorked(coll().insert({a: 1}));
+
+rollbackTest.transitionToRollbackOperations();
+rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
+
+assert.commandWorked(coll().insert([{b: 1}, {b: 2}]));
+
+rollbackTest.transitionToSyncSourceOperationsDuringRollback();
+rollbackTest.transitionToSteadyStateOperations();
+
+assert.eq(coll().find().itcount(), 1);
+
+rollbackTest.stop();
+})(); \ No newline at end of file
diff --git a/jstests/noPassthrough/capped_deletes_within_startup_recovery.js b/jstests/noPassthrough/capped_deletes_within_startup_recovery.js
new file mode 100644
index 00000000000..527d9bb0d76
--- /dev/null
+++ b/jstests/noPassthrough/capped_deletes_within_startup_recovery.js
@@ -0,0 +1,45 @@
+/**
+ * Tests that capped deletes occur during statup recovery on documents inserted earlier in startup
+ * recovery.
+ *
+ * @tags: [
+ * requires_persistence,
+ * requires_replication,
+ * ]
+ */
+(function() {
+'use strict';
+
+load('jstests/libs/fail_point_util.js');
+
+const replTest = new ReplSetTest({nodes: 1});
+replTest.startSet();
+replTest.initiate();
+
+const primary = function() {
+ return replTest.getPrimary();
+};
+
+const testDB = function() {
+ return primary().getDB('test');
+};
+
+const coll = function() {
+ return 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());
+
+assert.eq(coll().find().itcount(), 1);
+
+replTest.stopSet();
+})(); \ No newline at end of file