Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Starting an elasticsearch container" message in constructor #6127

Conversation

deejgregor
Copy link
Contributor

@deejgregor deejgregor commented Nov 5, 2022

At this point in the constructor, we are not actually starting Elasticsearch, so this message can lead to confusion (it did for me, leading me to dig into it). I didn't find any of the other org.testcontainers container classes that output a message like this in their constructor.

When the container is actually started, we still get a log message from GenericContainer, anyway, so I think we can just safely delete this log line, which is what this PR does.

Notice line 8 where we have Starting an elasticsearch container:

...
20:37:40.568 [main] INFO  🐳 [testcontainers/ryuk:0.3.4] - Creating container for image: testcontainers/ryuk:0.3.4
20:37:41.040 [main] INFO  org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for https://index.docker.io/v1/
20:37:49.798 [main] INFO  🐳 [testcontainers/ryuk:0.3.4] - Container testcontainers/ryuk:0.3.4 is starting: 7201de8310b1f5870622b4070203ccf609a9a6a550ab3bfb682193c9f1fe7424
20:38:08.714 [main] INFO  🐳 [testcontainers/ryuk:0.3.4] - Container testcontainers/ryuk:0.3.4 started in PT28.516627S
20:38:08.729 [main] INFO  org.testcontainers.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
20:38:08.730 [main] INFO  org.testcontainers.DockerClientFactory - Checking the system...
20:38:08.732 [main] INFO  org.testcontainers.DockerClientFactory - βœ”οΈŽ Docker server version should be at least 1.6.0
20:38:08.732 [main] INFO  🐳 [docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2] - Starting an elasticsearch container using [docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2]
20:38:08.824 [main] INFO  🐳 [postgres:10.7-alpine] - Creating container for image: postgres:10.7-alpine
20:38:12.712 [main] INFO  🐳 [postgres:10.7-alpine] - Container postgres:10.7-alpine is starting: f1a9cd20285eea9cc684b76a44916a35e5c9715e787773895f49c164b1a1baa2
20:38:43.861 [main] INFO  🐳 [postgres:10.7-alpine] - Container postgres:10.7-alpine started in PT35.03724S
20:38:44.015 [main] INFO  🐳 [horizon:latest] - Creating container for image: horizon:latest
20:39:44.261 [main] INFO  🐳 [horizon:latest] - Container horizon:latest is starting: 73913f424c20e78c297033c9674286f9659ea87ce124ee08e2c29a9e7cb49a9f
20:39:55.601 [main] INFO  org.opennms.smoketest.containers.OpenNMSContainer - Waiting for startup to begin.
...

I can confirm that no Elasticsearch container has been created f I look at recently-created containers while the test is running. I don't see Elasticsearch, but I do see the other containers listed in the output above (and that I expect to see in this case): ryuk, postgres, and OpenNMS horizon.

CONTAINER ID   IMAGE                                 COMMAND                  CREATED
73913f424c20   horizon:latest                        "/entrypoint.sh -s"      6 minutes ago
f1a9cd20285e   postgres:10.7-alpine                  "docker-entrypoint.s…"   8 minutes ago
7201de8310b1   testcontainers/ryuk:0.3.4             "/app"                   8 minutes ago

In our case, this happens because of the log message in the ElasticsearchContainer constructor, and also our smoke test OpenNMSStack infrastructure that pre-defines a number of container stacks that we use in tests, one of which called ALEC includes Elasticsearch (code). However in the test output I showed above, it wasn't the ALEC stack that was being used--an ElasticsearchContainer object was instantiated, but the container was never actually created or started in this case.

At this point in the constructor, we are not actually starting
Elasticsearch, so this message can lead to confusion. I didn't find
any of the other container classes that output a message like this
in their constructor. When the container is actually started, we
still get a log message from GenericContainer, anyway.
@deejgregor deejgregor requested a review from a team as a code owner November 5, 2022 01:04
@eddumelendez eddumelendez merged commit 96af052 into testcontainers:main Nov 5, 2022
@eddumelendez
Copy link
Member

Thanks @deejgregor ! this is now merged in main branch.

@eddumelendez eddumelendez added this to the next milestone Nov 5, 2022
@deejgregor deejgregor deleted the fix-elasticsearch-starting-message branch November 12, 2022 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants