cucumber-jvm: Cucumber custom config strategy with exclusive isolated resources not running the scenarios in parallel

πŸ‘“ What did you see?

Given I am using below custom config strategy to run test in parallel e.g junit-platform.properties

cucumber.execution.parallel.config.strategy=custom
cucumber.execution.parallel.config.custom.parallelism=2
cucumber.execution.parallel.config.custom.class=com.runners.CustomStrategy

Then scenarios under Feature1,Feature2 and Feature3 are running parallelly without any issues

When i add @isolated tag to my Feature2 and update my junit-platform.properties

cucumber.publish.quiet=true
cucumber.execution.parallel.enabled=true
cucumber.filter.tags=@pricePackArchitectureV2
cucumber.execution.parallel.config.strategy=custom
cucumber.execution.parallel.config.custom.parallelism=2
cucumber.execution.parallel.config.custom.class=com.runners.CustomStrategy
cucumber.plugin=pretty,json:results/cucumber.json,junit:results/cucumber.xml
cucumber.execution.exclusive-resources.isolated.read-write=org.junit.platform.engine.support.hierarchical.ExclusiveResource.GLOBAL_KEY

βœ… What did you expect to see?

Then I am expecting all the scenarios except with Feature2(@isolated tag) should run in parallel But the scenarios under Feature1 and Feature2 are also started running sequentially

πŸ“¦ Which tool/library version are you using?

cucumber : 7.6.0 openjdk 21.0.2 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-58) OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

πŸ”¬ How could we reproduce it?

πŸ“š Any additional context?

CustomStrategy class

import org.junit.platform.commons.JUnitException;
import org.junit.platform.engine.ConfigurationParameters;
import org.junit.platform.engine.support.hierarchical.ParallelExecutionConfiguration;
import org.junit.platform.engine.support.hierarchical.ParallelExecutionConfigurationStrategy;

import java.util.concurrent.ForkJoinPool;
import java.util.function.Predicate;

public class CustomStrategy implements ParallelExecutionConfiguration, ParallelExecutionConfigurationStrategy {
    private int parallelism;

    @Override
    public int getParallelism() {
        return parallelism;
    }

    @Override
    public int getMinimumRunnable() {
        return 0;
    }

    @Override
    public int getMaxPoolSize() {
        return 256 + parallelism;
    }

    @Override
    public int getCorePoolSize() {
        return parallelism;
    }

    @Override
    public int getKeepAliveSeconds() {
        return 60;
    }

    @Override
    public Predicate<? super ForkJoinPool> getSaturatePredicate() {
        return (ForkJoinPool p) -> true;
    }

    @Override
    public ParallelExecutionConfiguration createConfiguration(ConfigurationParameters configurationParameters) {
        this.parallelism = configurationParameters.get("custom.parallelism", Integer::valueOf).orElseThrow(() ->
                new JUnitException(String.format("Configuration parameter '%s' must be: ",
                        "junit.jupiter.execution.parallel.config.custom.parallelism")));
        return this;
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Verified with latest Junit version ,the issue is fixed now

If you’re using JUnit 5 in the recommended manner, you only have to upgrade JUnit 5. The bill of materials will straighten out the dependencies.

Issue should be fixed by Junit 5.11.1 recently released. It also brings other parallelism fixes. Maybe cucumber-jvm should also be updated with the new dependency and released.

Cheers. I made a pure JUnit Jupiter version of your reproducer and created an issue for the JUnit team. Any fix is likely to come from there so you’ll want to follow that.