Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

junit 5 - Unable to run multiple discoveries at a time

My team developed a custom runner for junit tests. Now I'm working to improve it's performance and trying to create few TestPlans simulteniously. To be honest at this step I'm even not going to execute it. The only thing I need is to get a complete list of TestIdentifiers for further filtering in UI.

Everything works fine when working on the same thread.

So I have a method to discover testCases:

    private CompletableFuture<List<TestCasesDetails>> discover(boolean mode) {
        return CompletableFuture.supplyAsync(() -> {
            TestPlan testPlan = testPlanGenerator.createTestPlan(
                    jarDiscoverService.discover(mode)
            );
            try {
                return testCaseMapper.getMappedTestCasesList(mode, testPlan);
            } catch (ClassNotFoundException e) {
                throw new NotFoundException("Wrong tag or tests not found");
            }
        });
    }

where createTestPlan is:

    public TestPlan createTestPlan(LauncherDiscoveryRequest request) {
        Launcher launcher = LauncherFactory.create ();
        return launcher.discover (request);
    }

and jarDiscoverService.discover triggers some business logic, but finally building a LauncherDiscoveryRequest:

         LauncherDiscoveryRequestBuilder.request()
                .selectors(discoverySelectorList)
                .filters(
                        excludeEngines("..."),
                        executionMode ? includeTags("...") : excludeTags("...")
                )
                .filters(filterTags)
                .configurationParameters(...)
                .build();

When running it, getting :

java.nio.file.FileSystemAlreadyExistsException: null
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:104) ~[jdk.zipfs:na]
    at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:335) ~[na:na]
    at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:284) ~[na:na]
    at org.junit.platform.commons.util.CloseablePath.createForJarFileSystem(CloseablePath.java:57) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.CloseablePath.create(CloseablePath.java:46) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.ClasspathScanner.findClassesForUri(ClasspathScanner.java:102) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.ClasspathScanner.lambda$findClassesForUris$0(ClasspathScanner.java:94) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
    at org.junit.platform.commons.util.ClasspathScanner.findClassesForUris(ClasspathScanner.java:97) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.ClasspathScanner.scanForClassesInPackage(ClasspathScanner.java:78) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.ReflectionUtils.findAllClassesInPackage(ReflectionUtils.java:981) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.util.ReflectionUtils.findAllClassesInPackage(ReflectionUtils.java:974) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.commons.support.ReflectionSupport.findAllClassesInPackage(ReflectionSupport.java:138) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.ClassContainerSelectorResolver.resolve(ClassContainerSelectorResolver.java:53) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:155) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543) ~[na:na]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:45) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:96) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:81) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:83) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:58) ~[junit-platform-console-standalone-1.7.0-M1.jar:1.7.0-M1]

@user:6327046 Marc Philipp, would be cool to hear from you or someone from junit team :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...