-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[junit-jupiter] Add parallel attribute to @Testcontainers
#6658
[junit-jupiter] Add parallel attribute to @Testcontainers
#6658
Conversation
Hi, this is my first contribution to the project. If you can review and leave some comments I would be happy to address them. @eddumelendez @kiview Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, @samed-bicer ! Left some comments.
...es/junit-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersExtension.java
Outdated
Show resolved
Hide resolved
...es/junit-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersExtension.java
Outdated
Show resolved
Hide resolved
9a5f69e
to
6b875c2
Compare
...es/junit-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersExtension.java
Outdated
Show resolved
Hide resolved
...es/junit-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersExtension.java
Outdated
Show resolved
Hide resolved
Thanks for the review comments, applied them! Should I also update the documentation? |
...les/junit-jupiter/src/test/java/org/testcontainers/junit/jupiter/ParallelExecutionTests.java
Outdated
Show resolved
Hide resolved
...les/junit-jupiter/src/test/java/org/testcontainers/junit/jupiter/ParallelExecutionTests.java
Outdated
Show resolved
Hide resolved
...les/junit-jupiter/src/test/java/org/testcontainers/junit/jupiter/ParallelExecutionTests.java
Outdated
Show resolved
Hide resolved
Thanks! I think we should add docs at the end of https://www.testcontainers.org/quickstart/junit_5_quickstart/ Once this PR is merged, then we can add the docs in a separate PR |
@Testcontainers
if (isParallelExecutionEnabled(context)) { | ||
Startables.deepStart(restartContainers.stream().map(adapter -> adapter.container)).join(); | ||
} else { | ||
restartContainers.forEach(adapter -> store.getOrComputeIfAbsent(adapter.getKey(), k -> adapter.start())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, this can be replaced by calling startSharedContainers()
, of course, the name should change. Also, in order to prevent to get this evaluated every single time even when there is no containers, a check can be added. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree; there is no need for duplication, will rename the method as startContainers()
For the check you mentioned is it OK to put a guard clause that checks the size of the given container list? something like
if (restartContainers.isEmpty()) { return; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed the function and added the guard clause
Thanks for your contribution, @samed-bicer ! This is now merged in |
#5037 add an option to Testcontainers annotation for JUnit to start containers in parallel