I am trying to start the testcontainers with a new 8.x elasticsearch image with testcontainers 3.6.0.
However, the container quits immediately, and I cannot execute any tests.
I found out that the discovery.zen.* settings are no longer supported and will cause the container to quit now. ES 8 breaking changes
java.lang.IllegalArgumentException: unknown setting [discovery.zen.minimum_master_nodes] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
Also, the check if the container is up will not work properly. I assume this is because Elasticsearch will use https now by default. I did not find anything in the changelogs, but there is a comment in the Java testcontainers here [ElasticsearchContainer.java] "major version 8 is secure by default" (https://github.com/testcontainers/testcontainers-java/blob/84d3444600aaeeac6813505fe5bfbf9ffce760ef/modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java#L178)
Here is the error message that I get.
received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/10.199.0.2:9200, remoteAddress=/10.199.0.1:47096
In order for the container to start, I need to change the environment variables as follows:
This does not work
from testcontainers.elasticsearch import ElasticSearchContainer
es = ElasticSearchContainer(image=f"elasticsearch:8.3.2")
try:
es.start()
finally:
es.stop()
If I remove the environment variable, this code works
from testcontainers.elasticsearch import ElasticSearchContainer
es = ElasticSearchContainer(image=f"elasticsearch:8.3.2") \
.with_env("xpack.security.enabled", "false")
es.env.pop('discovery.zen.minimum_master_nodes')
try:
es.start()
finally:
es.stop()
I could prepare a Pull Request in which I check whether the version of the container is 8 or higher and set the environment variables accordingly. Does this sound like the correct approach?
I am trying to start the testcontainers with a new 8.x elasticsearch image with testcontainers 3.6.0.
However, the container quits immediately, and I cannot execute any tests.
I found out that the
discovery.zen.*settings are no longer supported and will cause the container to quit now. ES 8 breaking changesAlso, the check if the container is up will not work properly. I assume this is because Elasticsearch will use https now by default. I did not find anything in the changelogs, but there is a comment in the Java testcontainers here [ElasticsearchContainer.java] "major version 8 is secure by default" (https://github.com/testcontainers/testcontainers-java/blob/84d3444600aaeeac6813505fe5bfbf9ffce760ef/modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java#L178)
Here is the error message that I get.
In order for the container to start, I need to change the environment variables as follows:
This does not work
If I remove the environment variable, this code works
I could prepare a Pull Request in which I check whether the version of the container is 8 or higher and set the environment variables accordingly. Does this sound like the correct approach?