-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Race condition when chaining tests that use sshd
make 2nd test fail
#677
Comments
I will take a look but yep, looks like a race condition, thanks and advance to all your explanations and great context. |
Hi @lbroudoux, thanks for raising such a detailed issue. The idea behind the current implementation of a session ID is that it is shared across processes, including test processes. You can see in the Resource Reaper implementation for example that it checks for the existence of an existing container for the given session ID and reuses that if it exists: testcontainers-node/packages/testcontainers/src/reaper/reaper.ts Lines 33 to 36 in 824cd8d
If the session ID implementation remains the same (I need to have a chat with the other Testcontainers maintainers about this), the correct fix would be to implement a similar check in the Port Forwarder, so that the existing container is reused instead of a conflict being thrown. |
Thanks for the heads-up and commenting on the progression! I think reuse is fine, but we should also be able to change the host port the Also, I have used the |
If we change the existing host port that SSHD is bound to then we will break parallel testing, e.g if test suite 1 exposes port 8080 and is in progress, and test suite 2 then exposes port 8081, then test suite 1 will fail. What I think makes sense is to append a host port whenever |
@lbroudoux please try version 10.3.2 |
I've checked with Thanks! |
Expected Behaviour
My application contains 2 Jest tests that pop out containers that must access the host on different ports (I start and stop the application on a random free port in both tests).
As I'm stopping all containers and networks in
afterAll()
method of my 2 tests, I expect those 2 tests to pass when run in sequence (each test launched independently pass).Actual Behaviour
I face an error when running the 2nd test. This error occurs whatever the order of tests:
It seems the
sshd
container is still attached to the previously running container in 1st test. Maybe it's not killed fast enough byryuk
at the end of first test...Testcontainer Logs
When setting
export DEBUG=testcontainers*
before running my tests, I got following relevant logs - from the end of previous end to the failure when starting the second one:Steps to Reproduce
shift-left-demo/nest-order-service
folder and runnpm install
Environment Information
The text was updated successfully, but these errors were encountered: