retry check() sets status to UP for XMPP server with valid certificate (STARTTLS)
This commit is contained in:
parent
698521f089
commit
068cb35022
@ -186,8 +186,23 @@ describe("TCP Monitor", () => {
|
|||||||
status: PENDING,
|
status: PENDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
await tcpMonitor.check(monitor, heartbeat, {});
|
// Retry up to 5 times for external service reliability
|
||||||
|
let lastError;
|
||||||
assert.strictEqual(heartbeat.status, UP);
|
for (let attempt = 1; attempt <= 5; attempt++) {
|
||||||
|
try {
|
||||||
|
await tcpMonitor.check(monitor, heartbeat, {});
|
||||||
|
assert.strictEqual(heartbeat.status, UP);
|
||||||
|
return; // Success, exit test
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
// Reset heartbeat for next attempt
|
||||||
|
heartbeat.msg = "";
|
||||||
|
heartbeat.status = PENDING;
|
||||||
|
// Wait a bit before retrying
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 500 * 2 ** (attempt - 1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If all retries failed, throw the last error
|
||||||
|
throw lastError;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user