Skip to content

Possible race condition with JUnit 5 in 1.16.1 and 1.16.2 #4679

@SanityResort

Description

@SanityResort

When trying to upgrade from 1.15.3 to 1.16.2 we encountered an issue breaking our tests that might be a race condition.

It seems that connecting to the exposed port is not possible yet when the test cases are executed. Adding timeouts to the @BeforeEach method does reduce these errors which would suggest a race condition here.

I did have a look at PR 4597 and the linked issues. Maybe these could be related but cannot say for sure.

So far I have not been able to create a local reproducer but adding debug logging produces the following output:

[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 633fc3b2f14fb048fd089b805c2596cba8d36358e5802af6e78075f50cfecc96
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 633fc3b2f14fb048fd089b805c2596cba8d36358e5802af6e78075f50cfecc96
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT4.845S
[AMQP Connection 127.0.0.1:49668] WARN com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred (Exception message: Connection reset)
[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 57d3b35f8cba584142d5efc0c69c1864802b3c977cefddf815cd415b972af66f
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 57d3b35f8cba584142d5efc0c69c1864802b3c977cefddf815cd415b972af66f
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT5.483S
[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 364373afe9fed9056c0314b75709b76a5013c1f7d375089c2329d51686cba14e
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 364373afe9fed9056c0314b75709b76a5013c1f7d375089c2329d51686cba14e
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT5.912S

This shows a run of three tests starting a container with a rabbitmq:3.8 image, in our tests we try to connect to that container during the @BeforeEach setup method (Moving this call to the actual test method did not solve the issue). The first test results in an error where as the other two complete successfully. We have also seen runs with all three tests failing.

From the log output it would seem the container is up and running before the test gets executed, the actual behaviour suggests differently. With 1.16.0 or 1.15.3 we did not observe any similar issues.

Connection reset could also imply that the container was shutting down again already but that would be unexpected during the test setup and adding timeout at the start of the setup method should not have an effect on it.

Changing to a shared container instance for all tests did also not solve the issue.

Please let me know if you require any further information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolution/waiting-for-infoWaiting for more information of the issue author or another 3rd party.type/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions