summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2023-02-03 14:16:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-10 23:57:03 +0000
commit57c08db7751a049911c9d36837006814cd5ac3b5 (patch)
tree80426b42dee50fda6a1a3318380a49f386ddd79d /jstests
parent835768e45b76a71cc9e12f6684e51a6d1d8dcc87 (diff)
downloadmongo-57c08db7751a049911c9d36837006814cd5ac3b5.tar.gz
SERVER-73481 Ensure validate detects out-of-order keys with {full: false}
(cherry picked from commit 288fee69456c966751a49870eefead1b7fa6ae76)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/validate_out_of_order.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/noPassthrough/validate_out_of_order.js b/jstests/noPassthrough/validate_out_of_order.js
new file mode 100644
index 00000000000..27142a71c5f
--- /dev/null
+++ b/jstests/noPassthrough/validate_out_of_order.js
@@ -0,0 +1,37 @@
+/**
+ * Tests that out-of-order keys are detected by validation during both the collection and index scan
+ * phases.
+ */
+(function() {
+"use strict";
+
+const rst = new ReplSetTest({nodes: 1});
+rst.startSet();
+rst.initiate();
+
+let primary = rst.getPrimary();
+let coll = primary.getCollection('test.out_of_order');
+assert.commandWorked(coll.createIndex({x: 1}));
+
+for (let i = 0; i < 5; i++) {
+ assert.commandWorked(coll.insert({x: i}));
+}
+
+// Test record store out-of-order detection.
+assert.commandWorked(
+ primary.adminCommand({configureFailPoint: "WTRecordStoreUassertOutOfOrder", mode: "alwaysOn"}));
+let res = assert.commandWorked(coll.validate());
+assert(!res.valid);
+assert.commandWorked(
+ primary.adminCommand({configureFailPoint: "WTRecordStoreUassertOutOfOrder", mode: "off"}));
+
+// Test index entry out-of-order detection.
+assert.commandWorked(
+ primary.adminCommand({configureFailPoint: "failIndexKeyOrdering", mode: "alwaysOn"}));
+res = assert.commandWorked(coll.validate());
+assert(!res.valid);
+assert.commandWorked(
+ primary.adminCommand({configureFailPoint: "failIndexKeyOrdering", mode: "off"}));
+
+rst.stopSet();
+})();