From 288fee69456c966751a49870eefead1b7fa6ae76 Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Fri, 3 Feb 2023 14:16:03 +0000 Subject: SERVER-73481 Ensure validate detects out-of-order keys with {full: false} --- jstests/noPassthrough/validate_out_of_order.js | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 jstests/noPassthrough/validate_out_of_order.js (limited to 'jstests/noPassthrough') 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(); +})(); -- cgit v1.2.1