Skip to content

Cucumber custom config strategy with exclusive isolated resources not running the scenarios in parallel #2910

Closed
@iamsethi

Description

@iamsethi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions