-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Declaring the global read-write lock on a leaf node should not fail execution #4027
Comments
This can be reproduced with https://github.com/mpkorstanje/junit5-locks/tree/main Feature: example
@isolated
Scenario: a
When I wait 1 hour
@reads-and-writes-system-properties
Scenario: b
When I wait 1 hour cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=2
cucumber.execution.exclusive-resources.isolated.read-write=org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY
cucumber.execution.exclusive-resources.reads-and-writes-system-properties.read-write=java.lang.System.properties package io.cucumber.skeleton;
import io.cucumber.java.en.When;
import java.util.concurrent.TimeUnit;
public class StepDefinitions {
@When("I wait {int} hour")
public void iWaitHour(int arg0) throws InterruptedException {
TimeUnit.SECONDS.sleep(arg0);
}
} Unlike with JUnit Jupiter the
Prior to executing b, the nop lock from example and the exclusive resource from a is still held in the thread locks.
So then Lines 81 to 85 in d013085
And it is worth noting that the comment about the Lines 78 to 80 in d013085
|
Does Cucumber somehow bypass |
Cucumber does not. I'd say that the CucumberTestEngine is fairly unremarkable in that regard. The difference is that JUnits Note: It doesn't look like any actual parallelism is needed to reproduce the problem. This will also produce the problem:
|
With some trickery it is possible effectively put import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceLock;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;
import static org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY;
public class LockTest {
@Test
@ResourceLock(value = GLOBAL_KEY, mode = READ_WRITE) // effectively @Isolated
void test1() throws InterruptedException {
TimeUnit.SECONDS.sleep(1);
}
@Test
@ResourceLock(value = "b", mode = READ_WRITE)
void test2() throws InterruptedException {
TimeUnit.SECONDS.sleep(1);
}
} junit.jupiter.execution.parallel.mode.default=concurrent
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=1 |
Thanks for the reproducer! I'll take a look today. |
Prior to this change additional locks were not cleared from siblings when discovering the global read-write lock on a test descriptor which led to incompatible locks and caused test execution to fail. Fixes #4027.
I've verified that #4039 fixes the problem for the reproducer. |
Prior to this change additional locks were not cleared from siblings when discovering the global read-write lock on a test descriptor which led to incompatible locks and caused test execution to fail. Fixes #4027.
Cheers. That was quick! |
Backported to the |
I've upgraded my Cucumber test framework with JUnit 5.11.1 and I get a new error:
All I can say is that inside the feature file I have two scenarios: one marked with
@isolated
global read write exclusive resource and another scenario is marked with a simple read write exclusive resource.Reverting to JUnit 5.11.0 works without any error !
I'm sorry I cannot give more details. Maybe I will try to isolate it to a more detailed scenario when I'll have more time.
The text was updated successfully, but these errors were encountered: