From 068cb35022f5b495526442f4c00239fde20570cf Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 6 Jan 2026 06:41:37 +0100 Subject: [PATCH] retry check() sets status to UP for XMPP server with valid certificate (STARTTLS) --- test/backend-test/monitors/test-tcp.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/backend-test/monitors/test-tcp.js b/test/backend-test/monitors/test-tcp.js index 4626fe34f..9946376ba 100644 --- a/test/backend-test/monitors/test-tcp.js +++ b/test/backend-test/monitors/test-tcp.js @@ -186,8 +186,23 @@ describe("TCP Monitor", () => { status: PENDING, }; - await tcpMonitor.check(monitor, heartbeat, {}); - - assert.strictEqual(heartbeat.status, UP); + // Retry up to 5 times for external service reliability + let lastError; + 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; }); });