ci: Improve Redis client disconnection handling in integration tests

- Updated the afterAll cleanup logic in integration tests for GenerationJobManager, RedisEventTransport, and RedisJobStore to use `quit()` for graceful disconnection of the Redis client.
- Added fallback to `disconnect()` if `quit()` fails, enhancing robustness in resource management during test teardown.
- Improved comments for clarity on the disconnection process and error handling.
This commit is contained in:
Danny Avila 2025-12-15 09:41:31 -05:00
parent 71a1a69568
commit 10e9e2c008
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
3 changed files with 27 additions and 9 deletions

View file

@ -45,11 +45,17 @@ describe('GenerationJobManager Integration Tests', () => {
});
afterAll(async () => {
if (ioredisClient && 'disconnect' in ioredisClient) {
if (ioredisClient) {
try {
ioredisClient.disconnect();
// Use quit() to gracefully close - waits for pending commands
await ioredisClient.quit();
} catch {
// Ignore disconnect errors
// Fall back to disconnect if quit fails
try {
ioredisClient.disconnect();
} catch {
// Ignore
}
}
}
process.env = originalEnv;

View file

@ -29,11 +29,17 @@ describe('RedisEventTransport Integration Tests', () => {
});
afterAll(async () => {
if (ioredisClient && 'disconnect' in ioredisClient) {
if (ioredisClient) {
try {
ioredisClient.disconnect();
// Use quit() to gracefully close - waits for pending commands
await ioredisClient.quit();
} catch {
// Ignore
// Fall back to disconnect if quit fails
try {
ioredisClient.disconnect();
} catch {
// Ignore
}
}
}
process.env = originalEnv;

View file

@ -57,11 +57,17 @@ describe('RedisJobStore Integration Tests', () => {
});
afterAll(async () => {
if (ioredisClient && 'disconnect' in ioredisClient) {
if (ioredisClient) {
try {
ioredisClient.disconnect();
// Use quit() to gracefully close - waits for pending commands
await ioredisClient.quit();
} catch {
// Ignore disconnect errors
// Fall back to disconnect if quit fails
try {
ioredisClient.disconnect();
} catch {
// Ignore
}
}
}
process.env = originalEnv;