SERVER-127088 Enable disagg_sharding_change_streams_v2 suite in disagg TSAN variant (#54424)

GitOrigin-RevId: 7056171813ade7de85e06bee81ece9e2fc0e0579
This commit is contained in:
Felipe Farinon 2026-05-26 12:02:32 -04:00 committed by MongoDB Bot
parent 576672878f
commit c0bc268ebc
2 changed files with 21 additions and 4 deletions

View File

@ -592,14 +592,24 @@ export function ChangeStreamTest(_db, options) {
let changes = self.getNextChanges(cursor, expectedNumChanges, skipFirstBatch);
if (ignoreOrder) {
const errMsgFunc = () => `${tojsonMaybeTruncate(changes)} != ${tojsonMaybeTruncate(expectedChanges)}`;
assert.eq(changes.length, expectedNumChanges, errMsgFunc);
const lengthMismatchErrMsg = () =>
"Change stream event count mismatch (order ignored). " +
`Expected ${expectedNumChanges} event(s), observed ${changes.length}. ` +
`Expected events: ${tojsonMaybeTruncate(expectedChanges)}. ` +
`Observed events: ${tojsonMaybeTruncate(changes)}.`;
assert.eq(changes.length, expectedNumChanges, lengthMismatchErrMsg);
for (let i = 0; i < changes.length; i++) {
const itemMismatchErrMsg = () =>
"Change stream event mismatch (order ignored). " +
`No expected event matched observed event at index ${i}. ` +
`Observed event: ${tojsonMaybeTruncate(changes[i])}. ` +
`Expected events: ${tojsonMaybeTruncate(expectedChanges)}. ` +
`Observed events: ${tojsonMaybeTruncate(changes)}.`;
assert(
expectedChanges.some((expectedChange) => {
return isChangeStreamEventEq(changes[i], expectedChange, eventModifier);
}),
errMsgFunc,
itemMismatchErrMsg,
);
}
} else {

View File

@ -116,6 +116,7 @@ function runTransitionTestCases(transitionType, watchMode, collSetupType) {
// the transition (we use the first event by the previous test case as resume point).
csCursor = null;
const resumePoint = observedEvents[0]._id;
const resumeId = observedEvents[0].fullDocument._id;
try {
csCursor = cst.getChangeStream({watchMode: watchMode, coll: coll, resumeAfter: resumePoint});
@ -133,7 +134,13 @@ function runTransitionTestCases(transitionType, watchMode, collSetupType) {
// On the other hand, a change stream resumed before a "transition from dedicated config server"
// is expected to retrieve all the subsequent events.
cst.assertNextChangesEqualUnordered({cursor: csCursor, expectedChanges: expectedEvents.slice(1)});
//
// We exclude the event we resumed from (observedEvents[0]) rather than always slicing
// expectedEvents at index 0. In a sharded cluster the change stream delivers events in
// cluster-time order, which can differ from insertion order, so the first observed event
// may not be expectedEvents[0].
const resumedExpected = expectedEvents.filter((e) => e.fullDocument._id !== resumeId);
cst.assertNextChangesEqualUnordered({cursor: csCursor, expectedChanges: resumedExpected});
cst.cleanUp();
}