Skip to content

Commit db44ecd

Browse files
github-actions[bot]CopilotCopilot
authored
[Test Coverage] container-lifecycle.ts (#6396)
* test: add unit tests for container-lifecycle.ts Covers startContainers, runAgentCommand, and fastKillAgentContainer: - Success paths and error delegation to handleHealthcheckError - Retry logic for api-proxy and squid transient startup failures - cli-proxy failure error with DNS detail - Topology mode onNetworkReady callback - Timeout exit code (124) and external kill (143) - Blocked domain reporting - fastKillAgentContainer custom timeout and error tolerance Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: remove duplicate lifecycle test suite --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 7d3936c commit db44ecd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/container-start.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ describe('startContainers', () => {
275275
expectComposeUpAttempts(1);
276276
});
277277

278+
it('includes DNS failure details when awf-cli-proxy startup fails with EAI_AGAIN', async () => {
279+
// 1. docker rm (initial cleanup)
280+
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
281+
// 2. docker compose up (fails with cli-proxy unhealthy)
282+
mockExecaFn.mockRejectedValueOnce(new Error('dependency failed to start: container awf-cli-proxy is unhealthy'));
283+
// 3. docker inspect awf-api-proxy (fallback check - healthy)
284+
mockExecaFn.mockResolvedValueOnce({ stdout: 'running|healthy', stderr: '', exitCode: 0 } as any);
285+
// 4. docker inspect awf-squid (fallback check - healthy)
286+
mockExecaFn.mockResolvedValueOnce({ stdout: 'running|healthy', stderr: '', exitCode: 0 } as any);
287+
// 5. docker logs --tail 50 awf-cli-proxy (diagnostics before fail-fast throw)
288+
mockExecaFn.mockResolvedValueOnce({ stdout: 'cli-proxy startup logs', stderr: '', exitCode: 0 } as any);
289+
// 6. docker logs --tail 50 awf-cli-proxy (DNS failure scan)
290+
mockExecaFn.mockResolvedValueOnce({
291+
stdout: 'Error: getaddrinfo EAI_AGAIN my-service.svc.cluster.local',
292+
stderr: '',
293+
exitCode: 0
294+
} as any);
295+
296+
await expect(startContainers(getDir(), ['github.com'])).rejects.toThrow('my-service.svc.cluster.local');
297+
});
298+
278299
it('should route retry error through Squid diagnostics when retry fails with non-api-proxy error', async () => {
279300
// Create access.log with denied entries so Squid diagnostics fire
280301
const squidLogsDir = path.join(getDir(), 'squid-logs');

0 commit comments

Comments
 (0)