Skip to content
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

[Error] reuseContainer does not work for embedded-kafka #1128

Open
arturk9 opened this issue Feb 8, 2023 · 6 comments
Open

[Error] reuseContainer does not work for embedded-kafka #1128

arturk9 opened this issue Feb 8, 2023 · 6 comments
Labels

Comments

@arturk9
Copy link

arturk9 commented Feb 8, 2023

Hello,

It seems like embedded-kafka keeps spawning new containers, even if reuseContainer flag is set to true. Please take a look at the code sample below:

https://github.com/arturk9/kafka-reuse-demo

Reproduction steps:

  1. run ./gradlew build multiple times in short interval
  2. reuse has no effect - new containers are spawned each time

screenshot

Would it be possible to add support for embedded-kafka containers reuse?

Thank you in advance :)

@Fameing Fameing added the bug label Mar 23, 2023
@Fameing
Copy link
Collaborator

Fameing commented Apr 21, 2023

Hi @arturk9,

Could you try version 3.0.0-RC5 and give feedback if the problem is gone ?

@arturk9
Copy link
Author

arturk9 commented Apr 24, 2023

hello @Fameing

Once upgraded to 3.0.0-RC5, both containers mongo and kafka are not reused. I did some debugging, seems like the configuration is correct and "shouldBeReused" flag is set to true properly for both containers, but each execution still spawns new containers. After upgrading, not only new kafka container is created, but it seems like mongodb is no longer reusable.

Zrzut ekranu 2023-04-24 o 08 27 27

Zrzut ekranu 2023-04-24 o 08 27 12

The following condition is also evaluated as true:
Zrzut ekranu 2023-04-24 o 08 32 09

Is there anything I am missing in the config?

@Chismur
Copy link

Chismur commented Apr 24, 2023

Hi @arturk9 and @Fameing
Faced the same problem with kafka. In my case I have configuration through the bootstrap.yaml file.
Found out that reusing container is working as expected in case if we get rid of network for kafka. I just manually sets null to kafkaNetwork() bean through the debugger.
But still I didn't found how to remove network property when I'm using bootstrap.yml configuration not static

image
image

@Fameing
Copy link
Collaborator

Fameing commented Apr 24, 2023

Thank you,
I also found a problem that using Network for a container generates a different hash. This problem is related to testcontainer-java.

@Chismur
Copy link

Chismur commented Apr 25, 2023

@Fameing
Is it possible somehow to avoid network generation for Kafka through bootstrap config file? Or this is not possible for now?

Thanks in advance!

@Chismur
Copy link

Chismur commented Apr 25, 2023

@arturk9 @Fameing
My suggestion as a temporary workaround is to override bean kafkaNetwork (set this bean to null)
as described here https://stackoverflow.com/questions/68898220/spring-boot-boostrap-bean-override

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants