SERVER-125722: Improve debug for change streams fsm tests (#52855)

GitOrigin-RevId: 259fe37fb9b08640cb79b5ee9af4dceb0e2aded5
This commit is contained in:
nicola cabiddu 2026-04-29 19:27:40 +01:00 committed by MongoDB Bot
parent 6d086d138a
commit 2575db9dd1
2 changed files with 13 additions and 3 deletions

View File

@ -37,7 +37,8 @@ const TEST_COLL = "test_coll_fsm";
const TEST_COLL_2 = "test_coll_fsm_2";
// Random seed for the entire test run, logged for reproducibility.
const TEST_SEED = Date.now();
// Override with `--shellSeed=<n>` (resmoke) to reproduce a previous run.
const TEST_SEED = typeof TestData !== "undefined" && Number.isFinite(TestData.seed) ? TestData.seed : Date.now();
/**
* Operation types to filter out before comparison.
@ -147,7 +148,7 @@ function computeExpectedEvents(commands, watchMode) {
.map((e) => ({event: e, cursorClosed: e.operationType === "invalidate"}));
}
function buildCommandTrace(commands) {
function buildCommandTrace(commands, source) {
return commands.map((cmd, i) => {
const shardIds = Array.isArray(cmd.shardSet) ? cmd.shardSet.map((s) => s._id) : [];
return {
@ -158,10 +159,15 @@ function buildCommandTrace(commands) {
shardSet: shardIds,
primaryShard: cmd.primaryShard ? cmd.primaryShard._id : null,
targetShardKey: cmd.targetShardKey ?? null,
source,
};
});
}
function buildAggregatedCommandTrace(writers) {
return writers.flatMap((w) => buildCommandTrace(w.commands, `${w.dbName}.${w.collName}`));
}
/**
* Build reader specs for the given watch mode.
*
@ -201,7 +207,7 @@ function buildReaderSpecs(commandsByWriter, startTime, batchSize, watchMode) {
dbName: w.dbName,
collName: w.collName,
numberOfEventsToRead: events.length,
debugCommandTrace: buildCommandTrace(w.commands),
debugCommandTrace: buildCommandTrace(w.commands, `${w.dbName}.${w.collName}`),
},
};
});
@ -223,6 +229,7 @@ function buildReaderSpecs(commandsByWriter, startTime, batchSize, watchMode) {
dbName,
collName: writers[0].collName,
numberOfEventsToRead: eventCount,
debugCommandTrace: buildAggregatedCommandTrace(writers),
},
};
});
@ -241,6 +248,7 @@ function buildReaderSpecs(commandsByWriter, startTime, batchSize, watchMode) {
dbName: "admin",
collName: null,
numberOfEventsToRead: eventCount,
debugCommandTrace: buildAggregatedCommandTrace(commandsByWriter),
},
},
];

View File

@ -80,6 +80,8 @@ class Writer {
jsTest.log.error(`Writer [${config.instanceName}]: cmd[${i}] ${spec.type} FAILED`, {
error: e.toString(),
spec: spec,
totalCommands: config.commandSpecs.length,
seed: config.seed,
});
throw e;
}