Closed akkie closed 2 months ago
I can see that the SSHD container was only started once with the port from the first run.
IIRC, this is by design. The port forwarding container is implemented as a singleton. I did some tests, and I cannot reproduce the issue. The randomly opened host ports are successfully forwarded.
This means your logic is the following?
-----> parallel -> get free app port -> start app with free port -> call ExposeHostPortsAsync with free app port -> start containers <-----
Or do you call the ExposeHostPortsAsync with the app ports upfront? Because the method accepts multiple ports?
Yes, you are right. The forwarding for random generated ports works. I can see in my Dapr logs, that it could connect to the application. It seems that I have another issue, when running things in parallel. So I will close the issue. Thanks for your support!
Testcontainers version
3.8.0
Using the latest Testcontainers version?
Yes
Host OS
MacOS
Host arch
ARM
.NET version
6.0.402
Docker version
Docker info
What happened?
I try to implement parallel running integration tests with Gherkin. To have an isolated test environment. The app and the containers are instantiated in the
[BeforeScenario]
step and shutdown in the[AfterScenario]
step. During instantiation I also setup the port forwarding from the container to the app. Because they run in parallel, each started app has a different port. For each test run I callTestcontainersSettings.ExposeHostPortsAsync
with the actual app port.Now the first test is successful, the others not. If I look at the started containers, I can see that the SSHD container was only started once with the port from the first run.
Relevant log output
No response
Additional information
No response