1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-09 21:21:11 +03:00

tests: fix flaky timeout assertion in maintenance notification test (#3143)

* Add debug info to assertion messages for root cause analysis

* Fix flaky timeout assertion in maintenance notification test

* Apply same tolerance fix to NORMAL_COMMAND_TIMEOUT assertions
This commit is contained in:
kiryazovi-redis
2025-12-05 14:11:48 +02:00
committed by GitHub
parent 7c419e03c8
commit a64134c55f

View File

@@ -125,17 +125,17 @@ describe("Timeout Handling During Notifications", () => {
notifications.forEach((notification) => { notifications.forEach((notification) => {
assert.ok( assert.ok(
result[notification]?.error instanceof Error, result[notification]?.error instanceof Error,
`${notification} notification error should be instanceof Error` `${notification} notification error should be instanceof Error. Got: ${JSON.stringify(result[notification])}`
); );
assert.ok( assert.ok(
result[notification]?.duration >= RELAXED_COMMAND_TIMEOUT && result[notification]?.duration >= RELAXED_COMMAND_TIMEOUT * 0.8 &&
result[notification]?.duration < RELAXED_COMMAND_TIMEOUT * 1.2, result[notification]?.duration < RELAXED_COMMAND_TIMEOUT * 1.2,
`${notification} notification should timeout within relaxed timeout` `${notification} notification should timeout within relaxed timeout. Duration: ${result[notification]?.duration}, Expected: [${RELAXED_COMMAND_TIMEOUT * 0.8}, ${RELAXED_COMMAND_TIMEOUT * 1.2})`
); );
assert.strictEqual( assert.strictEqual(
result[notification]?.error?.constructor?.name, result[notification]?.error?.constructor?.name,
"CommandTimeoutDuringMaintenanceError", "CommandTimeoutDuringMaintenanceError",
`${notification} notification error should be CommandTimeoutDuringMaintenanceError` `${notification} notification error should be CommandTimeoutDuringMaintenanceError. Got: ${result[notification]?.error?.constructor?.name}`
); );
}); });
}); });
@@ -164,9 +164,9 @@ describe("Timeout Handling During Notifications", () => {
"Command Timeout error should be instanceof Error" "Command Timeout error should be instanceof Error"
); );
assert.ok( assert.ok(
durationMigrate >= NORMAL_COMMAND_TIMEOUT && durationMigrate >= NORMAL_COMMAND_TIMEOUT * 0.8 &&
durationMigrate < NORMAL_COMMAND_TIMEOUT * 1.2, durationMigrate < NORMAL_COMMAND_TIMEOUT * 1.2,
`Normal command should timeout within normal timeout ms` `Normal command should timeout within normal timeout ms. Duration: ${durationMigrate}, Expected: [${NORMAL_COMMAND_TIMEOUT * 0.8}, ${NORMAL_COMMAND_TIMEOUT * 1.2})`
); );
assert.strictEqual( assert.strictEqual(
errorMigrate?.constructor?.name, errorMigrate?.constructor?.name,
@@ -199,9 +199,9 @@ describe("Timeout Handling During Notifications", () => {
"Command Timeout error should be instanceof Error" "Command Timeout error should be instanceof Error"
); );
assert.ok( assert.ok(
durationBind >= NORMAL_COMMAND_TIMEOUT && durationBind >= NORMAL_COMMAND_TIMEOUT * 0.8 &&
durationBind < NORMAL_COMMAND_TIMEOUT * 1.2, durationBind < NORMAL_COMMAND_TIMEOUT * 1.2,
`Normal command should timeout within normal timeout ms` `Normal command should timeout within normal timeout ms. Duration: ${durationBind}, Expected: [${NORMAL_COMMAND_TIMEOUT * 0.8}, ${NORMAL_COMMAND_TIMEOUT * 1.2})`
); );
assert.strictEqual( assert.strictEqual(
errorBind?.constructor?.name, errorBind?.constructor?.name,