Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 444198

Summary: Sonar code coverage (jacoco) not working for Linux Tools
Product: Community Reporter: Marc-André Laperle <malaperle>
Component: SonarAssignee: Generic Inbox <sonar-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, bernd.hufmann, mistria, webmaster
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Marc-André Laperle CLA 2014-09-15 19:08:41 EDT
Hello,

I have been trying to get the code coverage working for the Linux Tools project for a while now. What's strange is that I tried reproducing the problem in a VM with the same Hudson, Sonar versions and the same source code and it worked fine in the VM. I am not sure what is wrong but I see that the jacoco.exec file on Eclipse's Hudson is missing the coverage information whereas the one in my VM includes it (I checked by importing the file using EclEmma).

In the Eclipse Hudson console output, there is this warning:
[WARN] [07:03:01.231] Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?

When I compare a single .class between both servers, they are identical so in my mind, there shouldn't be missing debug information. But one of them produces code coverage information and one doesn't. The Hudson job configurations on the two machines are very similar (different proxy settings). I also tried to run maven with -X but there was no extra output related to this.

Another strange thing is that CDT has a very similar setup and it works fine. Any help in troubleshooting the issue would be greatly appreciated.

The Hudson job:
https://hudson.eclipse.org/linuxtools/job/linuxtools-sonar/

Thank you!
Comment 1 Eclipse Webmaster CLA 2014-09-25 11:59:27 EDT
I've taken a peak and there doesn't seem to be much difference between your job and the cdt-sonar job(aside from their not using jacoco).

A few quick searches on Google didn't turn up anything that looked promising.

-M.
Comment 2 Marc-André Laperle CLA 2014-09-25 14:37:15 EDT
(In reply to Eclipse Webmaster from comment #1)
> I've taken a peak and there doesn't seem to be much difference between your
> job and the cdt-sonar job(aside from their not using jacoco).

Thanks for looking at it. cdt-sonar does use jacoco as well, it is done in the pom.xml. It sounds to me that there is something wrong with the environment of the build because with the same Hudson version, Java, Sonar and same job configuration (aside from proxy) then it works with my VM (Ubuntu 13.10). Maybe it would be worth trying to create the same job on the CDT HIPP to see if that changes anything?
Comment 3 Marc-André Laperle CLA 2014-09-25 16:16:28 EDT
I copied the job (copy/pasted manually) to the CDT instance and it worked, code coverage is properly calculated.

https://hudson.eclipse.org/cdt/job/temporary-linuxtools-sonar/

There must be some difference between the two machines that affects the result but I can't figure out what. The Maven, Java versions are the same. The only thing I can see in the log that's different is the kernel version: 3.0.76-0.11-default for CDT and 3.0.74-0.6.8-default for Linux Tools. I don't think that would have anything to do with it though...
Comment 4 Mickael Istria CLA 2014-09-25 17:25:33 EDT
Maybe you should try "mvn clean install" instead of "mvn clean verify" to help SonarQube maven plugin in resolving classes.
Also, are you sure the path that you give the sonar (apparently $WORKSPACE/jacoco.exec) actually contains the report file? I believe it's better to set the sonar.jacoco.reportPath property in job configuration (For both regular build and SonarQube), and make sure jacoco-maven-plugin uses this property to put reports, and uses "append".
Comment 5 Marc-André Laperle CLA 2014-09-26 16:00:17 EDT
It turns out that when I copy/pasted the job to the CDT machine, I forgot to copy the "profiles" field in the maven build. It turns out that was the key to making it work! I'm not sure what's wrong with this specific profile (build-server) but it works for now. I can investigate what's wrong with this profile on my own to document the real issue but I'll mark this as fixed since this is not a problem with the Eclipse infrastructure. Thank you for your help!