summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough
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-03 15:42:09 +0000
commit288fee69456c966751a49870eefead1b7fa6ae76 (patch)
tree3a8d94e45242d91906531b620a36083bdd6022e7 /jstests/noPassthrough
parentee66aa703f68534866af61d17b6f72e0e229a001 (diff)
downloadmongo-288fee69456c966751a49870eefead1b7fa6ae76.tar.gz
SERVER-73481 Ensure validate detects out-of-order keys with {full: false}
Diffstat (limited to 'jstests/noPassthrough')
-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();
+})();