Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72552

Cannot merge coverage from Python source using relative imports

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • coverage-plugin
    • None

      I am usingĀ  recordCoverage step in Jenkinsfile script.

      However it fails with the following exception:

      [Coverage] Successfully parsed file '/var/lib/jenkins/workspace/acs4_multibranch_pipeline_master/coverage.xml'
      [Coverage] MODULE: 100.00% (1/1)
      [Coverage] PACKAGE: 100.00% (2/2)
      [Coverage] FILE: 93.55% (29/31)
      [Coverage] CLASS: 93.55% (29/31)
      [Coverage] LINE: 67.33% (4053/6020)
      [Coverage] BRANCH: 42.37% (738/1742)
      [Coverage] COMPLEXITY: 0
      [Coverage] COMPLEXITY_DENSITY: 0/6020
      [Coverage] LOC: 6020
      [Coverage] Successfully processed file 'coverage.xml'
      [Pipeline] }
      [Pipeline] // dir
      Error when executing always post condition:
      Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: feeb7a7a-e6a0-4d3a-9bbe-197283df3da6
      java.lang.IllegalArgumentException: Cannot merge coverage information for line 7 in [FILE] asr_client.py <0>
      at edu.hm.hafner.coverage.FileNode.mergeCounters(FileNode.java:156)
      at edu.hm.hafner.coverage.FileNode.mergeNode(FileNode.java:136)
      at edu.hm.hafner.coverage.Node.lambda$mergeNode$17(Node.java:745)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
      at edu.hm.hafner.coverage.Node.mergeNode(Node.java:741)
      at edu.hm.hafner.coverage.Node.lambda$mergeNode$17(Node.java:745)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
      at edu.hm.hafner.coverage.Node.mergeNode(Node.java:741)
      at edu.hm.hafner.coverage.Node.merge(Node.java:720)
      at java.base/java.util.stream.ReduceOps$2ReducingSink.accept(ReduceOps.java:123)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
      at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:662)
      at edu.hm.hafner.coverage.Node.merge(Node.java:687)
      at io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder.aggregateResults(CoverageRecorder.java:519)
      at io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder.perform(CoverageRecorder.java:413)
      at io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder.perform(CoverageRecorder.java:402)
      at io.jenkins.plugins.coverage.metrics.steps.CoverageStep$Execution.run(CoverageStep.java:365)
      at io.jenkins.plugins.coverage.metrics.steps.CoverageStep$Execution.run(CoverageStep.java:333)
      at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      at java.base/java.lang.Thread.run(Thread.java:833)
      
      

      The beginning of asr_client.py file is following:

      import logging
      import re
      
      from abc import abc_common
      from clients.asr_rules import Rule, PROTOCOL_UDP
      from abc.abc_common import delay_counter, LOGGING_LEVEL
      from .ssh_client import SSHClient, SSHClientFactory
      
      

      The seventh line is using relative Python import. This is possible cause of this exception.

            drulli Ulli Hafner
            kaniapm Piotr Kania
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: