Skip to content
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

Merged

Conversation

samed-bicer
Copy link
Contributor

@samed-bicer samed-bicer commented Feb 18, 2023

#5037 add an option to Testcontainers annotation for JUnit to start containers in parallel

@samed-bicer
Copy link
Contributor Author

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

Copy link
Member

@eddumelendez eddumelendez left a 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.

@samed-bicer samed-bicer force-pushed the junit-parallel-container-startup branch from 9a5f69e to 6b875c2 Compare March 11, 2023 20:26
@samed-bicer
Copy link
Contributor Author

samed-bicer commented Mar 11, 2023

Thanks for your contribution, @samed-bicer ! Left some comments.

Thanks for the review comments, applied them! Should I also update the documentation?
I cannot see anything related to disabledWithoutDocker() option for @Testcontainers annotation in documentation.
I can add it plus the parallel() option into the docs

@eddumelendez
Copy link
Member

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

@eddumelendez eddumelendez changed the title add option to start containers in parallel for junit (#5037) [junit-jupiter] Add parallel attribute to @Testcontainers Mar 12, 2023
Comment on lines 113 to 117
if (isParallelExecutionEnabled(context)) {
Startables.deepStart(restartContainers.stream().map(adapter -> adapter.container)).join();
} else {
restartContainers.forEach(adapter -> store.getOrComputeIfAbsent(adapter.getKey(), k -> adapter.start()));
}
Copy link
Member

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?

Copy link
Contributor Author

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; }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me

Copy link
Contributor Author

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

@eddumelendez eddumelendez added this to the next milestone Mar 13, 2023
@eddumelendez eddumelendez merged commit 74a523a into testcontainers:main Mar 13, 2023
@eddumelendez
Copy link
Member

Thanks for your contribution, @samed-bicer ! This is now merged in main branch and it will be part of the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants