fix(e2e): bound upgrade survivor probe retries · openclaw/openclaw@a37dd02
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
File tree
scripts/e2e/lib/upgrade-survivor
| Original file line number | Diff line number | Diff line change |
|---|
@@ -107,7 +107,7 @@ function matchesDegradedReadyExpectation(body) {
|
107 | 107 | |
108 | 108 | async function fetchProbeText() { |
109 | 109 | const elapsedMs = Date.now() - startedAt; |
110 | | -const remainingMs = Math.max(1, timeoutMs - elapsedMs); |
| 110 | +const remainingMs = timeoutMs - elapsedMs; |
111 | 111 | const controller = new AbortController(); |
112 | 112 | const attemptDeadlineMs = Math.min(attemptTimeoutMs, remainingMs); |
113 | 113 | let timer; |
@@ -138,7 +138,7 @@ const startedAt = Date.now();
|
138 | 138 | let lastError; |
139 | 139 | let lastResult; |
140 | 140 | |
141 | | -while (Date.now() - startedAt <= timeoutMs) { |
| 141 | +while (Date.now() - startedAt < timeoutMs) { |
142 | 142 | try { |
143 | 143 | const { response, text } = await fetchProbeText(); |
144 | 144 | let body; |
@@ -171,9 +171,17 @@ while (Date.now() - startedAt <= timeoutMs) {
|
171 | 171 | } catch (error) { |
172 | 172 | lastError = error instanceof Error ? error.message : String(error); |
173 | 173 | } |
| 174 | +const remainingDelayMs = timeoutMs - (Date.now() - startedAt); |
| 175 | +if (remainingDelayMs <= 0) { |
| 176 | +break; |
| 177 | +} |
| 178 | +const delayMs = Math.min(500, remainingDelayMs); |
174 | 179 | await new Promise((resolve) => { |
175 | | -setTimeout(resolve, 500); |
| 180 | +setTimeout(resolve, delayMs); |
176 | 181 | }); |
| 182 | +if (delayMs === remainingDelayMs) { |
| 183 | +break; |
| 184 | +} |
177 | 185 | } |
178 | 186 | |
179 | 187 | const suffix = lastResult ? ` (last HTTP ${lastResult.status}: ${lastResult.text})` : ""; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -192,6 +192,39 @@ describe("scripts/e2e/lib/upgrade-survivor/probe-gateway.mjs", () => {
|
192 | 192 | } |
193 | 193 | }); |
194 | 194 | |
| 195 | +it("keeps failed probe retries inside the total timeout", async () => { |
| 196 | +const server = createHttpServer((_request, response) => { |
| 197 | +response.writeHead(503, { "content-type": "application/json" }); |
| 198 | +response.end(JSON.stringify({ ready: false, failing: ["gateway"] })); |
| 199 | +}); |
| 200 | +const baseUrl = await listen(server); |
| 201 | +const out = path.join(makeTempDir(), "ready-timeout.json"); |
| 202 | +const startedAt = Date.now(); |
| 203 | +try { |
| 204 | +const result = await runProbe([ |
| 205 | +"--base-url", |
| 206 | +baseUrl, |
| 207 | +"--path", |
| 208 | +"/readyz", |
| 209 | +"--expect", |
| 210 | +"ready", |
| 211 | +"--out", |
| 212 | +out, |
| 213 | +"--timeout-ms", |
| 214 | +"50", |
| 215 | +"--attempt-timeout-ms", |
| 216 | +"25", |
| 217 | +]); |
| 218 | + |
| 219 | +expect(result.status).not.toBe(0); |
| 220 | +expect(Date.now() - startedAt).toBeLessThan(300); |
| 221 | +expect(result.stderr).toContain("probe did not satisfy ready within 50ms"); |
| 222 | +expect(fs.existsSync(out)).toBe(false); |
| 223 | +} finally { |
| 224 | +server.close(); |
| 225 | +} |
| 226 | +}); |
| 227 | + |
195 | 228 | it("allows degraded ready responses only when degraded readiness is explicit", async () => { |
196 | 229 | const server = createHttpServer((_request, response) => { |
197 | 230 | response.writeHead(503, { "content-type": "application/json" }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。