New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-5092] Add maven profile with code coverage report generation #2836
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @BorisOsipov! Looks good. I would prefer is we changed the argLine
definitions as little as possible. That's why I would like to just use the late property evaluation once in the parent POM and let that be inherited by all Surefire configurations.
pom.xml
Outdated
<log4j.configuration>${log4j.configuration}</log4j.configuration> | ||
</systemPropertyVariables> | ||
<argLine>-Xms256m -Xmx800m -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine> | ||
<!-- Do not define argLine here. See http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's bound to cause problems because a lot of code assumes these arguments here. We shouldn't touch them and instead do as the documentation you linked suggested:
One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:
<argLine>@{argLine} -Xms256m -Xmx800m -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine>
pom.xml
Outdated
@@ -93,6 +93,7 @@ under the License. | |||
<flink.forkCount>1C</flink.forkCount> | |||
<flink.reuseForks>true</flink.reuseForks> | |||
<log4j.configuration>log4j-test.properties</log4j.configuration> | |||
<argLine>-Xms256m -Xmx800m -XX:-UseGCOverheadLimit</argLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if the argline configuration stayed as is. It is missing the fork number here. This requires us to manually insert it for all modules which rely on it.
<argLine>-Xms256m -Xmx2800m -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine> | ||
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just remove all argLine definition here along with the forkNumber definition. They are already defined in the parent pom.
<argLine>-Xms256m -Xmx1000m -Dlog4j.configuration=${log4j.configuration} -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine> | ||
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
<argLine>-Xms256m -Xmx1000m -Dlog4j.configuration=${log4j.configuration} -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine> | ||
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here (see above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments. Then we should be ready to merge.
pom.xml
Outdated
@@ -93,7 +93,7 @@ under the License. | |||
<flink.forkCount>1C</flink.forkCount> | |||
<flink.reuseForks>true</flink.reuseForks> | |||
<log4j.configuration>log4j-test.properties</log4j.configuration> | |||
<argLine>-Xms256m -Xmx800m -XX:-UseGCOverheadLimit</argLine> | |||
<argLine> </argLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed anymore.
pom.xml
Outdated
@@ -996,10 +996,9 @@ under the License. | |||
<reuseForks>${flink.reuseForks}</reuseForks> | |||
<systemPropertyVariables> | |||
<forkNumber>0${surefire.forkNumber}</forkNumber> | |||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is probably fine. Could you re-add this line and remove the parameter from the the argLine
?
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> | ||
<argLine>-Xms256m -Xmx1000m -Dlog4j.configuration=${log4j.configuration} -XX:-UseGCOverheadLimit</argLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be reduced to
<argLine>@{argLine} -Xmx1000m</argLine>
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> | ||
<argLine>-Xms256m -Xmx1000m -Dlog4j.configuration=${log4j.configuration} -XX:-UseGCOverheadLimit</argLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be reduced to
<argLine>@{argLine} -Xmx1000m</argLine>
<systemPropertyVariables> | ||
<mvn.forkNumber>0${surefire.forkNumber}</mvn.forkNumber> | ||
</systemPropertyVariables> | ||
<argLine>-Xms256m -Xmx2800m -Dmvn.forkNumber=${surefire.forkNumber} -XX:-UseGCOverheadLimit</argLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be reduced to
<argLine>@{argLine} -Xmx2800m</argLine>
@mxm Thank you for review. I ran into some issues with collecting coverage data. |
@mxm |
Has anyone actually looked in detail into the report that is generated? |
If i ran this myself, could i see which lines are not covered? |
You can find report in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If late property binding does not work, let's use the property. Could you add a comment for the property? It seems to be an undocumented feature of Surefire. It is hard to guess that setting a property influences the configuration of a Maven plugin?
By the way, the forkNumber is used for logging but also other purposes (using it as an offset for port bindings to prevent collisions).
The plugin cannot detect cross-module coverage, correct? as in, all the tests in flink-tests will not contribute in any way to the coverage of other modules? |
It does not: https://github.com/jacoco/jacoco/wiki/MavenMultiModule
That's a bummer but apparently there are some workarounds:
http://www.thinkcode.se/blog/2012/02/18/test-coverage-in-a-multi-module-maven-project
|
b1ce36a
to
5fc5d95
Compare
@zentol Yes plugin cannot detect out of box cross-module coverage, but there are some tricks how it could be done. I've implemented and tested one of them.
Changes in shade configuration made some test broken:
I investigate that they cannot run correctly without shading and there is no way to fix it. So you can get full coverage report by running command What do you think about these changes? |
I will try this out on the weekend and report back :) |
Pay attention that Jacoco does not support parallel test execution. Your experiment will be longer than usual full tests execution |
@zentol Hi. Any news? |
@BorisOsipov i haven't found time yet to try this out :( The long running time makes it tricky since you devote the machine completely to tests for hours. I could let it run over night though ... frankly, i haven't considered that option yet for some reason. Will try that tonight. |
I let it run overnight but a test failure caused the build to lockup :( |
I have tryed to collect coverage by this approach. |
@kenmy Thank you, this helped me a lot :) @BorisOsipov From a quick glance the aggregation appears to be working. This is really cool stuff. We'll have to go through the pom changes again, maybe @rmetzger can help here. But i wanna get this in. :) Some thoughts:
|
Sure. It setups like in other plugins by include\exclude section in plugin configuration.
Unfortunately no. All available coverage counters described here http://www.eclemma.org/jacoco/trunk/doc/counters.html |
Ok, cool. We should certainly exclude classes under "org.apache.flink.runtime.messages". I'll have to dig through the report some more to find others, but i guess we can add them later on too. |
@@ -364,6 +363,18 @@ under the License. | |||
</transformers> | |||
</configuration> | |||
</execution> | |||
<execution> | |||
<id>shade-flink</id> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this we execute the shade-plugin also for other build-profiles, correct? (same for flink-examples/flink-examples-streaming
) It would be cool if this would only be done when creating the coverage report, so that the normal build-time is unaffected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maven's philosophy is 'one artifact per project'. These projects don't follow this way and produce several jar's artifacts :)
Shade plugin should produce flink-storm-streaming_2.10-1.2-SNAPSHOT-shaded.jar but it doesn't do it. It is a problem for maven install plugin that wants to have such jar by default. And it leads to failure on install phase without such configuration changes. For this reason I added such changes.
So I propose don't collect test coverage for these projects (flink-storm and streaming examples) at all. What do you think?
- add maven profile 'coverage' with maven jacoco plugin - extract argLine from surefire configuration to project properties
- add module for tests coverage report aggregating - add option for disabling replacing original jar with shaded one
5fc5d95
to
c1eb73e
Compare
@zentol I've rebased pr and excluded mentioned above flink-examples-streaming and flink-storm-examples modules. |
@@ -65,6 +68,7 @@ under the License. | |||
<goal>shade</goal> | |||
</goals> | |||
<configuration combine.self="override"> | |||
<shadedArtifactAttached>${shade.shadedArtifactAttached}</shadedArtifactAttached> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we define this in the parent pom globally for all shade plugin instances?
<profile> | ||
<id>coverage</id> | ||
<modules> | ||
<module>flink-examples-batch</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the streaming examples not in the module list?
There is a separate "flink-test-utils-coverage" package that expects the all flink packages | ||
have built before. | ||
We need to depend on all modules if we want to get full coverage report | ||
including coverage from tests in flink-tests module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabs vs spaces for indentation
Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the How To Contribute guide.
In addition to going through the list, please provide a meaningful description of your changes.
General
Documentation
Tests & Build
mvn clean verify
has been executed successfully locally or a Travis build has passedI hope it's nice to have ability to collect test coverage.