I have a trouble with running e2e tests via jest with using testcontainers-node on gitlab ci.
default:
image: personal-registy/node:14-alpine3.12
services:
- name: personal-registy/docker:19.03-dind
alias: docker-dind
entrypoint: ['dockerd']
command: ['--host=tcp://0.0.0.0:2375']
variables:
IMAGE: $REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DOCKER_HOST: tcp://docker-dind:2375
DOCKER_DRIVER: overlay2
RYUK_CONTAINER_IMAGE: personal-regist/ruyk:0.3.2
stages:
- Prepare
- Tests
modules:
stage: Prepare
script:
- npm ci --no-audit
artifacts:
paths:
- node_modules/
expire_in: 1 hour
test-e2e:
stage: Tests
before_script:
- mkdir $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
after_script:
- rm -rf $home/.docker
dependencies:
- modules
script:
- npm run test:e2e
artifacts:
expire_in: 1 day
First step has no problem with building and preparing typescript code for test. But on running CI via npm command I got next stacktrace in log message:
Error: (HTTP code 409) container stopped/paused - Container d26dbb007bd42c3eb129e83db6253f3056fcc37294c84c4f00d13637bd451d6b is not running
at /builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:315:17
at getCause (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:345:7)
at Modem.buildPayload (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:314:5)
at IncomingMessage.<anonymous> (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:286:14)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
reason: 'container stopped/paused',
statusCode: 409,
json: {
message: 'Container d26dbb007bd42c3eb129e83db6253f3056fcc37294c84c4f00d13637bd451d6b is not running'
}
}
If I start test on local machine via npm I have no problem with running tests.
I found solution.
Ryuk couldn't start because of problems with accessing to Docker socket. I just disabled Ryuk on CI via env:
variables:
TESTCONTAINERS_RYUK_DISABLED: 'true'
After this my tests was completed successfully.