testcontainers / testcontainers-java

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

Display name for GenericContainer #2246

Open findepi opened 4 years ago

findepi commented 4 years ago

When using regular containers, the image name is usually sufficient for identifying which container given log line is about. However, when using 2+ GenericContainer instances with same image, it's no longer so:

2020-01-13T13:32:45.298+0100    INFO    testcontainers-lifecycle-2  🐳 [centos:7]    Creating container for image: centos:7
2020-01-13T13:32:45.297+0100    INFO    testcontainers-lifecycle-1  🐳 [centos:7]    Creating container for image: centos:7
2020-01-13T13:32:45.297+0100    INFO    testcontainers-lifecycle-0  🐳 [centos:7]    Creating container for image: centos:7
...
2020-01-13T13:37:46.946+0100    ERROR   testcontainers-lifecycle-1  🐳 [centos:7]    Could not start container
java.lang.IllegalStateException: Container exited with code 1
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:457)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:317)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:315)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:302)
    at java.util.concurrent.CompletableFuture.uniRun(CompletableFuture.java:705)
    at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:687)
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Neither the log line, nor the exception provide information which container failed.

findepi commented 4 years ago

Proposed solutions:

  1. mention command besides image in log messages

  2. provide optional "display name" property (defaulting to image name), that will be used in logging.

I offer to work on this, but I'd like to hear maintainers' preferences first.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

stale[bot] commented 4 years ago

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

findepi commented 4 years ago

I have only "Comment" button available. How can i reopen?

bsideup commented 4 years ago

@findepi I reopened it for you :)

bsideup commented 4 years ago

@findepi we're talking only about the logs, right? Not container's name?

findepi commented 4 years ago

@bsideup Yes, this issue is about the logs only.

findepi commented 4 years ago

However, if we allow configuring container name (which would be nice in itself), this could be used in logging too.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

findepi commented 4 years ago

.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

findepi commented 4 years ago

.