testcontainers / testcontainers-node

Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.com
MIT License
1.95k stars 199 forks source link

Improve error logging when a container fails to start #683

Open cristianrgreco opened 1 year ago

cristianrgreco commented 1 year ago

Related issue https://github.com/testcontainers/testcontainers-node/issues/682, you can see from the error log that the wait strategy is failing because the image is distroless. It'd be nice to surface this without having to enable logging.

akkie commented 2 weeks ago

That would be very helpful. I have a compose file that starts 10 containers. Sometimes my pipeline fails with:

[test](https://github.com/actions/runs/11874097483/job/33089644145#step:11:6220)
Error: Health check failed: unhealthy

   at testcontainers/compose.ts:11

   9 |   const composeFilePath = resolve(rootDir, 'docker/env-test');
  10 |
> 11 |   const environment = await new DockerComposeEnvironment(composeFilePath, 'docker-compose.yml')
     |                       ^
  12 |     .withStartupTimeout(120000)
  13 |     .withWaitStrategy('web-1', Wait.forHealthCheck())
  14 |     .withWaitStrategy(

    at HealthCheckWaitStrategy.waitUntilReady (/home/runner/work/apps/web/node_modules/.pnpm/testcontainers@10.14.0/node_modules/testcontainers/src/wait-strategies/health-check-wait-strategy.ts:26:13)
    at waitForContainer (/home/runner/work/apps/web/node_modules/.pnpm/testcontainers@10.14.0/node_modules/testcontainers/src/wait-strategies/wait-for-container.ts:17:5)
    at /home/runner/work/apps/web/node_modules/.pnpm/testcontainers@10.14.0/node_modules/testcontainers/src/docker-compose-environment/docker-compose-environment.ts:155:13
    at DockerComposeEnvironment.up (/home/runner/work/apps/web/node_modules/.pnpm/testcontainers@10.14.0/node_modules/testcontainers/src/docker-compose-environment/docker-compose-environment.ts:133:7)
    at runCompose (/home/runner/work/apps/web/e2e/testcontainers/compose.ts:11:23)
    at globalSetup (/home/runner/work/apps/web/e2e/globalSetup.ts:19:16)

There is absolutely no information which container failed.