[YANGTOOLS-1167] maven-plugin-it does not contribute to SonarCloud Created: 02/Nov/20  Updated: 18/Oct/21  Resolved: 18/Oct/21

Status: Resolved
Project: yangtools
Component/s: maven plugin
Affects Version/s: None
Fix Version/s: 8.0.0

Type: Bug Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to ODLPARENT-274 SingleFeatureTest does not contribute... Confirmed

 Description   

Looking at https://sonarcloud.io/component_measures?id=opendaylight_yangtools&metric=new_lines_to_cover&selected=opendaylight_yangtools%3Aplugin%2Fyang-maven-plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang2sources%2Fplugin%2FFileGeneratorTask.java&view=list tells a story here. Most of the codepaths are covered by it tests, but they do not contribute here for some reason.

 Investigate why sonar is ignoring these and fix the configuration/wiring accordingly.



 Comments   
Comment by Robert Varga [ 17/Oct/21 ]

So ... Sonar is not ignoring anything, the trouble here is the same as 'Why SFT tests do not contribute": the tests are being run from a fork the surefire/failsafe JVM.
What happens is :

  1. maven starts and executes failsafe with the correct options, which
  2. runs YangToSourcesPluginTestIT, which
  3. uses maven-verifier to execute tests, which
  4. forks a new process

Which means the JVM actually executing the tests does not have the correct JaCoCo options (communicated via failsafe-plugin's argLine property). Worse yet, even if it did, the failsafe JVM exits after all tests, overwriting jacoco.exec, leading to a useless report (i.e. it has only YangToSourcesPluginTestIT coverage).

To fix this, we need to do two things:

  • get a proper .exec file
  • make sure jacoco plugin generates full execution report

For the first part the cleanest we can go is an embedded maven (i.e. Verifier.setForkJvm(false)), but that seems to be rather untested and seems to be non-trivial. Alternative is to communicate argLine to each invoked maven thing – except they will end up overwriting – for which we'll need to do some fudging to replace the .exec file name. Then we'll need to either merge into a single .exec post-exection, or tickle jacoco plugin to create an aggregate report.

For the second part we will probably need the aggregate report, as we do not want to include all classes, not just those local to maven plugin IT.

A bit more investigation is necessary, as embedded maven might end up being easy...

Comment by Robert Varga [ 17/Oct/21 ]

Unfortunately I am getting this:

[main] DEBUG org.codehaus.plexus.PlexusContainer - Created new class realm maven.api
[main] DEBUG org.codehaus.plexus.PlexusContainer - Importing foreign packages into class realm maven.api
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: javax.annotation.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: javax.annotation.security.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: javax.enterprise.inject.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: javax.enterprise.util.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: javax.inject.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.artifact < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.classrealm < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.cli < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.configuration < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.exception < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.execution < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.execution.scope < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.lifecycle < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.model < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.monitor < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.plugin < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.profiles < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.project < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.reporting < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.repository < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.rtinfo < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.settings < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.toolchain < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.usability < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.authentication < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.authorization < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.events < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.observers < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.proxy < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.repository < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.apache.maven.wagon.resource < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.classworlds < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.classworlds < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.component < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.configuration < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.container < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.context < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.lifecycle < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.logging < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.personality < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.artifact < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.collection < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.deployment < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.graph < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.impl < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.installation < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.internal.impl < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.metadata < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.repository < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.resolution < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.spi < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.transfer < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.eclipse.aether.version < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.fusesource.jansi.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.slf4j.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.slf4j.event.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.slf4j.helpers.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer -   Imported: org.slf4j.spi.* < plexus.core
[main] DEBUG org.codehaus.plexus.PlexusContainer - Populating class realm maven.api
[main] WARN Sisu - Error injecting: org.apache.maven.project.DefaultProjectBuildingHelper
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
  while locating org.apache.maven.project.DefaultProjectBuildingHelper
(...)
Comment by Robert Varga [ 17/Oct/21 ]

For comparison, normal maven does this (with mvn -X):

[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.annotation.* < plexus.core
[DEBUG]   Imported: javax.annotation.security.* < plexus.core
[DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
[DEBUG]   Imported: javax.enterprise.util.* < plexus.core
[DEBUG]   Imported: javax.inject.* < plexus.core
[DEBUG]   Imported: org.apache.maven.* < plexus.core
[DEBUG]   Imported: org.apache.maven.artifact < plexus.core
[DEBUG]   Imported: org.apache.maven.classrealm < plexus.core
[DEBUG]   Imported: org.apache.maven.cli < plexus.core
[DEBUG]   Imported: org.apache.maven.configuration < plexus.core
[DEBUG]   Imported: org.apache.maven.exception < plexus.core
[DEBUG]   Imported: org.apache.maven.execution < plexus.core
[DEBUG]   Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG]   Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG]   Imported: org.apache.maven.model < plexus.core
[DEBUG]   Imported: org.apache.maven.monitor < plexus.core
[DEBUG]   Imported: org.apache.maven.plugin < plexus.core
[DEBUG]   Imported: org.apache.maven.profiles < plexus.core
[DEBUG]   Imported: org.apache.maven.project < plexus.core
[DEBUG]   Imported: org.apache.maven.reporting < plexus.core
[DEBUG]   Imported: org.apache.maven.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG]   Imported: org.apache.maven.settings < plexus.core
[DEBUG]   Imported: org.apache.maven.toolchain < plexus.core
[DEBUG]   Imported: org.apache.maven.usability < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG]   Imported: org.codehaus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.* < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.component < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.container < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.context < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.* < plexus.core
[DEBUG]   Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG]   Imported: org.eclipse.aether.collection < plexus.core
[DEBUG]   Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG]   Imported: org.eclipse.aether.graph < plexus.core
[DEBUG]   Imported: org.eclipse.aether.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.installation < plexus.core
[DEBUG]   Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG]   Imported: org.eclipse.aether.repository < plexus.core
[DEBUG]   Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG]   Imported: org.eclipse.aether.spi < plexus.core
[DEBUG]   Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.version < plexus.core
[DEBUG]   Imported: org.fusesource.jansi.* < plexus.core
[DEBUG]   Imported: org.slf4j.* < plexus.core
[DEBUG]   Imported: org.slf4j.event.* < plexus.core
[DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
[DEBUG]   Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.

Comment by Robert Varga [ 17/Oct/21 ]

I guess my dependencies are incomplete, but that needs further investigation.

Comment by Robert Varga [ 18/Oct/21 ]

Before:

Coverage               74.7%
Lines to Cover       31,144
Uncovered Lines       7,223
Line Coverage          76.8%
Conditions to Cover  10,443
Uncovered Conditions  3,308
Condition Coverage     68.3%

After:

Coverage               75.1%
Lines to Cover       31,144
Uncovered Lines       7,073
Line Coverage          77.3%
Conditions to Cover  10,443
Uncovered Conditions  3,262
Condition Coverage     68.8%

i.e. +0.5% lines, +0.5% conditions, +0.4% overall.

FileGeneratorTask is now reported as:

Coverage              85.5%
Lines to Cover          87
Uncovered Lines          9
Line Coverage         89.7%
Conditions to Cover     23
Uncovered Conditions     7
Condition Coverage    69.6%
Comment by Robert Varga [ 18/Oct/21 ]

In the end this is implemented through partial .exec files, which are then merged into a single jacoco.exec file. We then analyze yang-maven-plugin's and its dependencies.

Generated at Wed Feb 07 20:55:22 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.