cardano-foundation / cardano-rosetta

An implementation of Rosetta for Cardano
https://www.rosetta-api.org
Apache License 2.0
98 stars 50 forks source link

Test container isn't being cleaned up when setup fails #139

Open oneEdoubleD opened 4 years ago

oneEdoubleD commented 4 years ago

When running yarn test I'm getting this error about the test container not being cleaned up correctly. It can be worked around by changing line 7 of test/e2e/jest-setup/docker.ts from const CONTAINER_NAME = 'cardano-test'; to another name such as cardano-test-yarn, however you'd need to change this name every time you run the test suite.

edd@home:~/Workspace/cardano-rosetta$ sudo yarn test
yarn run v1.22.4
$ jest
Error: (HTTP code 409) unexpected - Conflict. The container name "/cardano-test" is already in use by container "ef3b1ff316d9bcfbf320a6a148e73dc77c2781298b58ebf1a235e1a5bf3c95e9". You have to remove (or rename) that container to be able to reuse that name. 
    at /home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:301:17
    at getCause (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:331:7)
    at Modem.buildPayload (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:300:5)
    at IncomingMessage.<anonymous> (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:275:14)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
oneEdoubleD commented 4 years ago

The error when tearing down is:

Error: (HTTP code 500) server error - cannot stop container: cardano-test-yarn: Cannot kill container a7e51522bca42608103508bb43b9af4bb4d01df4bd4c892156088e9bdf439be3: unknown error after kill: runc did not terminate sucessfully: container_linux.go:392: signaling init process caused "permission denied"
: unknown 
    at /home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:301:17
    at getCause (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:331:7)
    at Modem.buildPayload (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:300:5)
    at IncomingMessage.<anonymous> (/home/edd/Workspace/cardano-rosetta/node_modules/docker-modem/lib/modem.js:275:14)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Note I ran the test with sudo.

rhyslbw commented 4 years ago

You shouldn't be running yarn with sudo, so this particular situation is expected. The real exception here is when the setup fails for some reason, such as the host port is not available, and the container is not attempted to be cleaned up.