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

Allow @ResourceLock and @Isolated to work across processes #4211

Open
Arthurm1 opened this issue Dec 19, 2024 · 0 comments
Open

Allow @ResourceLock and @Isolated to work across processes #4211

Arthurm1 opened this issue Dec 19, 2024 · 0 comments

Comments

@Arthurm1
Copy link

@ResourceLock is great for ensuring tests run with as much concurrency as possible while protecting exclusive access to resources for the duration of a single test method/class.

My issue is that it only protects the resource within that single JUnit test run. If I execute a number of different test runs simultaneously (in different processes) and those test runs have tests that use @ResourceLock("foo") then foo can be accessed at the same time from the different test runs.

This happens for me as I use Gradle and have many subprojects. Gradle allows running subprojects tests in parallel or sequentially. Running tests in parallel means each project will run its tests in its own process and so @ResourceLock("foo") will not be respected across subprojects.

Because of this I have to run each subproject's test task sequentially which is slower.

Deliverables

Ideally there would be an option on @ResourceLock to specify the level of the lock e.g. @ResourceLock(level = LOCAL | MACHINE).

For @ResourceLock("Foo", level = LOCAL), the locking would behave as it currently is and this would be the default.
For @ResourceLock("Foo", level = MACHINE) the lock on Foo would prevent any junit runs on that machine from simultaneously accessing Foo. (Perhaps using java.nio.channels.FileLock)

It would be good if this could be extended to @Isolated(level = LOCAL | MACHINE) to allow only a single test to run concurrently even during multiple simultaneous test runs.

Or is there already a way to do this?

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

No branches or pull requests

1 participant