2
votes

Sometimes when I run a test on jenkins with logical OR tag selection (karate.options="--tags @vld,@command-composition") the tests are executed unitl the end but will never step out of

Results results = Runner.parallel(getClass(),5 , karateOutputPath);

This is definetly a problem concerning karate AND jenkins because when executed on a local machine, the problem never occured.

Also when the tags are selected separatelly (eg. "--tags @vld" or "--tags @command-composition") the problem does not occure. Even on jenkins.

This is my parallel runner class used for executing the tests in parallel. I added some logging debug outputs in order to clarify where the execution is running into an infinite loop.

The execution is not stepping out of test execution:

Results results = Runner.parallel(getClass(),5 , karateOutputPath);

and therefore everything after (including)

logger.debug("DEBUG-LOG: AFTER TEST - BEFORE REPORT GENERATION");

is never executed.

@KarateOptions(tags = {"~@ignore"})
public class ParallelRunner {

    private static final Logger logger = LoggerFactory.getLogger("com.intuit.karate");

    @Test
    public void testParallel() throws IOException {

        // RESET LAST USED ICCID
        Helper.resetLastIccid();

        String outputPath = "build";
        String karateOutputPath = outputPath + "/surefire-reports";
        logger.debug("DEBUG-LOG: BEFORE TEST");
        Results results = Runner.parallel(getClass(),5 , karateOutputPath);
        logger.debug("DEBUG-LOG: AFTER TEST - BEFORE REPORT GENERATION");
        generateReport(karateOutputPath);
        logger.debug("DEBUG-LOG: AFTER GEN REPORT");
        assertTrue("scenarios failed", results.getFailCount() == 0);
    }

    private static void generateReport(String karateOutputPath) {
        logger.debug("DEBUG-LOG: IN GEN REPORT");
        Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
        List<String> jsonPaths = new ArrayList(jsonFiles.size());
        jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
        Configuration config = new Configuration(new File("build"), "MH Conan Mobile Systemtest");
        ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
        reportBuilder.generateReports();
    }
}

I also played arround with the number of used threads and parallel execution==false. Nothing seems to help.

I also compared the surefire-reports output folder between a local run and a jenkins build. All surefire reports for the executed features are there but on jenkins the results-json.txt and timeline.html is missing.

So, is there anyone out there who has also experienced this kind of behaviour? Or has someone further ideas how to debug or at least narrow down this problem somehow?

Help is very much appreciated! :)

Karate-Version: 0.9.2 (latest)

1

1 Answers

2
votes

With two features who respectively have the @feature1 and @feature2 tags, when running

mvn clean install -Dkarate.options="--tags @feature1,@feature2"

Both features are played. That's not an AND tag selection but an OR tag selection. With

mvn clean install -Dkarate.options="--tags @feature1 --tags @feature2"

None of the two features are played. That's an AND selection.

Appart from that, have you tried creating a minimal karate project, with just a couple of features that are just doing a few simple steps each, and to launch it on Jenkins?