-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
Testcontainer started twice since 3.4 #43253
Comments
Is this causing an issue? Can you provide a sample application showing the actual problem you're facing? |
I do not think it creates a big problem but still created a regression on my side because I'm wrapping the MockServer and override the start() method to perform additional stuff. I can fix by verifying if the TestContainer is running but would be ideal to not start twice? |
Can you please share the sample we've requested? See also https://github.com/spring-projects/spring-boot/wiki/How-To-Get-Help |
We could perhaps use a non-null response from |
@wilkinsona protected final C getContainer() {
Assert.state(this.container != null,
"Container cannot be obtained before the connection details bean has been initialized");
if (!this.container.isRunning() && this.container instanceof Startable startable) {
startable.start();
}
return this.container;
}
/**
* @return is the container currently running?
*/
default boolean isRunning() {
if (getContainerId() == null) {
return false;
}
try {
Boolean running = getCurrentContainerInfo().getState().getRunning();
return Boolean.TRUE.equals(running);
} catch (DockerException e) {
return false;
}
}
/**
* @return is the container created?
*/
default boolean isCreated() {
if (getContainerId() == null) {
return false;
}
try {
String status = getCurrentContainerInfo().getState().getStatus();
return "created".equalsIgnoreCase(status) || isRunning();
} catch (DockerException e) {
return false;
}
} |
Yes, that's what I was (poorly) describing above when talking about the container ID. It'll certainly help, but I'm not sure that it'll address the problem 100% of the time as there appears to be an implied assumption in Testcontainers that |
That I was not aware, I thought that start() would only be called once. I'll definitely do that on my side! Feel free to improve on Spring side as you describe :) Thanks a lot for your help and quick response! I really appreciate! Cheers! |
We might be able to track beans that we've started ourselves rather than relying on the container ID |
ContainerConnectionDetailsFactory.getContainer() is doing
While
TestcontainersLifecycleBeanPostProcessor.initializeStartables(...)
already started the MockServerThe text was updated successfully, but these errors were encountered: