Closed MarvinVaillant closed 1 week ago
Does anyone have a clue why this can happen? Or how I can investigate further?
Hi, do you have a project to reproduce it?
I'll try to provide you with a minimal example today.
Sorry for the slow response. Here is the example repo: https://github.com/MarvinVaillant/demo-long-kafka-streams-teardown/tree/main
Here you'll also find a short video that shows the issue: https://github.com/user-attachments/assets/535847ac-cbbc-4f72-b6c9-a09e682bf84e
@MarvinVaillant thanks for providing the example but I am not able to run the project. It fails because of Mapped port can only be obtained after the container is started
. I can make some changes but I can not see the behavior described.
i'm really sorry. I was fiddeling around with the code to get some more insights. Could you please pull the latest commits?
Thanks for updating it. I'm moving this to a discussion because It is not an issue itself. Testcontainers is creating, running the container and killing it. However, in order to close the context you should call close
explicitly or rather use @DirtiesContext. I do not have much experience on Kafka Streams but others can help on how to handle this.
Module
Kafka
Testcontainers version
1.19.8
Using the latest Testcontainers version?
Yes
Host OS
MacOS, Linux, Windows
Host Arch
ARM, x86
Docker version
What happened?
We're running a Spring Boot project with Kafka Streams. We have one integration test (using
@SpringBootTest
and@Testcontainers
) that sometimes takes several minutes to complete after all tests successfully ran. Lots of Kafka "no connection to node" and "Node 1 disconnected" are printed in the logs repeatedly.It seems like the Kafka container is stopped before the Spring context is shutdown. And the Spring Context is waiting for Kafka to become available before shutting down.
Relevant log output
Additional Information
The issue seems to be mitigated to some extend (we wait < 10 seconds for the test to finalize) if we start the container manually in the
@BeforeAll
method, instead of using the@Testcontainers
and@Container
annotations.