The original post is created on Spring Data Elasticsearch issue: https://github.com/spring-projects/spring-data-elasticsearch/issues/2709#issue-1910223608

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

Comment From: eddumelendez

I think the issue is related to Elasticsearch 8. See https://github.com/spring-projects/spring-boot/issues/35926 and the examples in the description can be useful to fix your issue

Comment From: hantsy

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

Comment From: eddumelendez

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.

Comment From: scottfrederick

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.

Comment From: hantsy

@scottfrederick But Spring Data guys think this is a Spring Boot autoconfiguration issue, check https://github.com/spring-projects/spring-data-elasticsearch/issues/2709

Comment From: scottfrederick

@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.