Skip to content

Testcontainers Elasticsearch does not work #37672

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

Closed
hantsy opened this issue Oct 4, 2023 · 6 comments
Closed

Testcontainers Elasticsearch does not work #37672

hantsy opened this issue Oct 4, 2023 · 6 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@hantsy
Copy link

hantsy commented Oct 4, 2023

The original post is created on Spring Data Elasticsearch issue: spring-projects/spring-data-elasticsearch#2709 (comment)

But it seems like a Spring Boot testcontainers autoconfiguration issue, the following example project was working in Spring 3.1. Now it is updated to Spring Boot 3.2-M3, Java 21, and Elasticsearch 8, it test failed.

The sample project is https://github.com/spring-projects/spring-data-elasticsearch/files/12793105/boot-data-elasticsearch.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 4, 2023
@eddumelendez
Copy link
Contributor

eddumelendez commented Oct 4, 2023

I think the issue is related to Elasticsearch 8. See #35926 and the examples in the description can be useful to fix your issue

@hantsy
Copy link
Author

hantsy commented Oct 4, 2023

But it seems something was changed in Spring Boot 3.2, I followed the sample project (Spring Boot 3.1.4) in your link https://github.com/eddumelendez/testcontainers-samples/blob/main/spring-boot-elasticsearch have added tests for ES 7 and ES 8, both failed.

Check here, https://github.com/hantsy/spring6-sandbox/tree/master/boot-data-elasticsearch/src/test/java/com/example/demo

@eddumelendez
Copy link
Contributor

eddumelendez commented Oct 4, 2023

To be more specific it works with spring boot 3.2.0-M2 and start failing with 3.2.0-M3. However, if <spring-data-bom.version>2023.1.0-M2</spring-data-bom.version> is set then it works with Spring Boot 3.2.0-M3. I don't this this is related to Spring Boot Testcontainers integration.

@scottfrederick
Copy link
Contributor

Thanks the the analysis @eddumelendez. In addition to isolating the change to Spring Data Elasticsearch, the tests are failing on an assertion that is attempting to verify the state of an object after it has been saved to a repository. Since the repository and the container have been created as expected by this point in the test, I don't think this has anything to do Boot's auto-configuration or Testcontainers integration.

I debugged through the flow far enough to see that calls are being made to create the ID when saving the entity, but the generated ID is not getting copied back into the Product.id field. This might have something to do with this change in Spring Data Elasticsearch, but I can't tell for sure.

If you want to get further, I would suggest refining the sample to configure Spring Data Elasticsearch without Boot auto-configuration as suggested in the earlier issue and create a new issue in Spring Data Elasticsearch.

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
@scottfrederick scottfrederick added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 4, 2023
@hantsy
Copy link
Author

hantsy commented Oct 6, 2023

@scottfrederick But Spring Data guys think this is a Spring Boot autoconfiguration issue, check spring-projects/spring-data-elasticsearch#2709

@scottfrederick
Copy link
Contributor

@hantsy The same advice is being given in two issues now. Since it appears you've been able to reproduce the problem using manual Spring Data Elasticsearch configuration without Spring Boot auto-configuration involved, let's keep the discussion in the Spring Data Elasticsearch issue please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

4 participants