-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Improve Elasticsearch ServiceConnection #35926
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
Comments
I m beginner and i have no idea ...how to start contributing for project.. Anyone any guides for me?? |
Thanks for your interest in contributing. I'm not sure if we have any at the moment, but please keep an eye out for unassigned issues labelled with ideal for contribution or, if you haven't contributed before, first-timers only. |
I'll see if this ends up being over my head or not, but I'm starting to investigate this / work on it. Feedback is always welcome. I am only slightly familiar with Spring Boot, having used JHipster to make a simple app recently, and I haven't used Elasticsearch yet. |
Something came up that I'm going to have to work on for at least a few days before I can get back to this unfortunately. |
It's going to be a while before I can get back to this actually. Perhaps a week. Edit: I'm looking into this issue again currently. |
Hi all, can you all confirm to me what the goal here is exactly? Are we wanting to make it such that users can use Elasticsearch 8 Testcontainers without having to configure the SSL manually using a RestClientBuilderCustomizer? Probably while keeping SSL enabled? @eddumelendez the bulk of your edits in your draft proposal were in the DataElasticsearchTestIntegrationTests.java file, so I wanted to clarify and ask. That file is for tests that are for internal use by the Spring team, right? Were you just tinkering around in there for dev purposes? I assume we would be wanting to modify other files instead to provide the functionality we are going for, right? By the way passing in "docker.elastic.co/elasticsearch/elasticsearch:8.7.1" (or better yet, modifying DockerImageNames.elasticsearch8()) to the ElasticsearchContainer constructor in that test file in your draft proposal makes the tests pass, but you're probably already way ahead of me. Currently it's using Elasticsearch 7. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I've got another prototype that uses the SSL bundle abstractions to let the container create the |
Thanks for sharing, @scottfrederick! My only comment would be related to isVersion8OrGreater in the spring-boot-testcontainers module. Because for custom images it will not work due to there is not compatibility image version in Testcontainers at the moment. I think the |
Good time of the day to you! I'd say the goal is to have support in SpringBoot Testcontainers for Elasticsearch for all Elasticsearch supported versions, which currently are 7.x and 8.x. The thing is: both 7.x and 8.x can be secured (e.g. require password) and run with HTTPS (these can be turned on and off independently). The I've tried to make both determined by examining the logs. Unfortunately, I haven't found a reliable, race-free way working for both versions so far (which would be also backward compatible). In theory the configuration of Elastcsearch could be checked, compared with env, and then we could compute if security and HTTPS are enabled. However, this would mean a) redoing some product logic, and b) maintaining it. The idea is to make two HTTP(S) requests, to determine if SSL and security are on or off. AFAICT (but I'd love to be corrected) there's no other way of saying 100% correctly that Elasticsearch in the container is running with HTTPS or HTTP. The only 100% reliable method to determine what protocol shall be used (HTTP or HTTPS) I found so far (for both versions) is actually trying to establish secured connection and checking this test results. Apart from security and HTTPS, there's a third issue, adding the self-signed certificate to trusted ones. IMHO the ideal approach would be to make the Spring Boot Testcontainers module do that automatically, e.g. by creating SSL bundle and changing the properties accordingly. However, I don't know what would be the idiomatic way of doing this, so for now I'm relying on I hope there's a Spring guru around, who could help to achieve the same effect without the need of adding an extra method every time the developer decides to use Elasticsearch with HTTPS enabled ;-) |
Thanks for taking a look at this and providing feedback @pioorg. I wasn't very happy with either of the
This is the design challenge we're facing with this issue. There are a few other container types that support SSL, and we'd like to have a consistent way to set up the Spring Boot connection including SSL details that supports both |
Hello @scottfrederick |
Spring boot 3.5.0-M2 released #41137 and solves this issue for Elasticserach 8 as you can see in the following example eddumelendez/testcontainers-samples@7fed8b0. Closing this issue. Thanks! |
Currently, ElasticsearchContainerConnectionDetailsFactory only maps
nodes
and that works with Elasticsearch 7. However, Elasticsearch 8 has security enabled by default and additional configuration is required.This is an example using Elasticsearch 7 and this one using Elasticsearch 8. As you can see, with Elasticsearch 8 the
SSLContext
is provided via acustomizer
so the connection through https is successful.You can find a draft proposal here. I tried to do it via ssl bundles by copying the
http_ca.crt
from the container to the test resources directory but I couldn't set it up correctly.The text was updated successfully, but these errors were encountered: