My other blog (in Hungarian) merhetetlen.blogspot.com

Friday 2 September 2011

Coverage to bring them all

After the sweet success with JaCoCo (the project was called off, but I 've brought out everything from it), I have decided to jump to the next level.

My old problem with integration test coverage (we use TeamCity) is that it eats a lot of memory... One of our projects has 4 war files which have to be deployed in an embedded forked container (cargo) and the regression suite has 3000 tests, a lots of them generated with TestNG DataProvider (always use the Iterator variant).
The build agent has 6GB RAM but it is not enough. I could reserve 4GB but it always died with OOM... So we did not have coverage (and static analysis results) for weeks...

So I decided to use JaCoCo here as well. Not because it uses less memory, but it can be used via TCP. And it is awesome!

We have the possibility to separate the test run and the container of the application under test but can still gather the coverage easily.
On our development server I've set up one of our tomcats to run with jacoco (put a line to the catalina.sh, even I could do it. The JaCoCo team says it won't eat too much memory, so you can run it like this.)
To gather the results we modified one JaCoCo sample code (provided by the developers), and create a simple jar from it, we pass the ip, the port of the jacoco agent, and the file name what will be used to save the coverage file, and a flag to configure the data flush (keep results or flush it). So after the failsafe plugin, in the post-integration-phase we can call it with a simple exec plugin... And we have the exec file like starting the container with the maven build.

OK, there is one addition. Before starting this maven build I've set up a dependency to our regular remote deploy TeamCity configurations....

But there were problems....


  • One of our projects has a clustered environment... no problem, we've modified the data collector to accept list of IP's and concat the last segment of the IP after the data file name property. After we had the exec files from all head-ends we use the antrun plugin to merge these into one. (unfortunately jacoco maven plugin does not support this feature yet)

So it's solved....


  • One of our projects has client side application (this is used by the tests).... no problem, use the misunderstood config of the failsafe plugin... now we will have a jacoco in the failsafe's JVM (we have to fork the failsafe to flush the results at the end of the tests).... And in the post-integration-test do the merge...


Now only one thing's left.... use the results :)

No comments:

Post a Comment