fix(qa): release docker health probe bodies · openclaw/openclaw@a085db6
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -183,6 +183,7 @@ describe("runQaDockerUp", () => {
|
183 | 183 | it("falls back to the container IP when the host gateway port is unreachable", async () => { |
184 | 184 | const calls: string[] = []; |
185 | 185 | const fetchCalls: string[] = []; |
| 186 | +const hostGatewayCancel = vi.fn(async () => {}); |
186 | 187 | const outputDir = await mkdtemp(path.join(os.tmpdir(), "qa-docker-up-")); |
187 | 188 | const repoRoot = path.resolve("/repo/openclaw"); |
188 | 189 | const composeFile = path.join(outputDir, "docker-compose.qa.yml"); |
@@ -214,6 +215,9 @@ describe("runQaDockerUp", () => {
|
214 | 215 | }, |
215 | 216 | fetchImpl: vi.fn(async (input: string) => { |
216 | 217 | fetchCalls.push(input); |
| 218 | +if (input === "http://127.0.0.1:18889/healthz") { |
| 219 | +return { ok: false, body: { cancel: hostGatewayCancel } }; |
| 220 | +} |
217 | 221 | return { |
218 | 222 | ok: |
219 | 223 | input === "http://127.0.0.1:43124/healthz" || |
@@ -237,6 +241,7 @@ describe("runQaDockerUp", () => {
|
237 | 241 | "http://192.168.165.4:18789/healthz", |
238 | 242 | ]); |
239 | 243 | expect(result.gatewayUrl).toBe("http://192.168.165.4:18789/"); |
| 244 | +expect(hostGatewayCancel).toHaveBeenCalledTimes(1); |
240 | 245 | } finally { |
241 | 246 | await rm(outputDir, { recursive: true, force: true }); |
242 | 247 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,20 @@ function resolveDefaultQaDockerDir(repoRoot: string) {
|
25 | 25 | return path.resolve(repoRoot, ".artifacts/qa-docker"); |
26 | 26 | } |
27 | 27 | |
| 28 | +async function isQaLabDockerHealthReachable(url: string, fetchImpl: FetchLike) { |
| 29 | +let response: Awaited<ReturnType<FetchLike>> | undefined; |
| 30 | +try { |
| 31 | +response = await fetchImpl(url); |
| 32 | +return response.ok; |
| 33 | +} catch { |
| 34 | +return false; |
| 35 | +} finally { |
| 36 | +try { |
| 37 | +await response?.body?.cancel?.(); |
| 38 | +} catch {} |
| 39 | +} |
| 40 | +} |
| 41 | + |
28 | 42 | export async function runQaDockerUp( |
29 | 43 | params: { |
30 | 44 | repoRoot?: string; |
@@ -114,11 +128,7 @@ export async function runQaDockerUp(
|
114 | 128 | sleepImpl, |
115 | 129 | ); |
116 | 130 | let gatewayUrl = hostGatewayUrl; |
117 | | -if ( |
118 | | -!(await fetchImpl(`${hostGatewayUrl}healthz`) |
119 | | -.then((response) => response.ok) |
120 | | -.catch(() => false)) |
121 | | -) { |
| 131 | +if (!(await isQaLabDockerHealthReachable(`${hostGatewayUrl}healthz`, fetchImpl))) { |
122 | 132 | const containerGatewayUrl = await resolveComposeServiceUrl( |
123 | 133 | "openclaw-qa-gateway", |
124 | 134 | 18789, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -156,6 +156,18 @@ describe("matrix harness runtime", () => {
|
156 | 156 | ); |
157 | 157 | }); |
158 | 158 | |
| 159 | +it("cancels Matrix versions probe response bodies", async () => { |
| 160 | +const cancel = vi.fn(async () => {}); |
| 161 | +const fetchImpl = vi.fn(async () => ({ ok: true, body: { cancel } })); |
| 162 | + |
| 163 | +await expect( |
| 164 | +testing.isMatrixVersionsReachable("http://127.0.0.1:28008/", fetchImpl), |
| 165 | +).resolves.toBe(true); |
| 166 | + |
| 167 | +expect(fetchImpl).toHaveBeenCalledWith("http://127.0.0.1:28008/_matrix/client/versions"); |
| 168 | +expect(cancel).toHaveBeenCalledTimes(1); |
| 169 | +}); |
| 170 | + |
159 | 171 | it("falls back to the container IP when the host port is unreachable", async () => { |
160 | 172 | const calls: string[] = []; |
161 | 173 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -51,9 +51,17 @@ function buildVersionsUrl(baseUrl: string) {
|
51 | 51 | } |
52 | 52 | |
53 | 53 | async function isMatrixVersionsReachable(baseUrl: string, fetchImpl: FetchLike) { |
54 | | -return await fetchImpl(buildVersionsUrl(baseUrl)) |
55 | | -.then((response) => response.ok) |
56 | | -.catch(() => false); |
| 54 | +let response: Awaited<ReturnType<FetchLike>> | undefined; |
| 55 | +try { |
| 56 | +response = await fetchImpl(buildVersionsUrl(baseUrl)); |
| 57 | +return response.ok; |
| 58 | +} catch { |
| 59 | +return false; |
| 60 | +} finally { |
| 61 | +try { |
| 62 | +await response?.body?.cancel?.(); |
| 63 | +} catch {} |
| 64 | +} |
57 | 65 | } |
58 | 66 | |
59 | 67 | async function withMatrixQaHarnessTimeout<T>( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。