[ https://issues.apache.org/jira/browse/SLING-2810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Adamcin updated SLING-2810: -------------------------------- Attachment: madamcin_system_sling_jacoco_exec_servlet.patch SUMMARY: A JaCoCo agent REST Servlet, which exposes code coverage data to HTTP clients by calling IAgent#getExecutionData(boolean). A POST method will reset the agent after returning the execution data. A GET method calls the operation without resetting the agent. Requests to this servlet will return 404 if the JaCoCo JVM agent is not attached and registered as an IAgent MBean. IMPORTANT SECURITY CONSIDERATION: "The ports and connections opened in tcpserver and tcpclient mode and the JMX interface do not provide any authentication mechanism. If you run JaCoCo on production systems make sure that no untrusted sources have access to the TCP server port, or JaCoCo TCP clients only connect to trusted targets. Otherwise internal information of the application might be revealed or DOS attacks are possible." - eclemma.org INSTRUCTIONS: To configure jacoco on a standalone integration test server: 1. extract jacocoagent.jar from org.jacoco:org.jacoco.agent:jar:$VERSION to /path/to/jacocoagent.jar (e.g. jar -xf ~/.m2/repository/org/jacoco/org.jacoco.agent/$VERSION/org.jacoco.agent-$VERSION.jar -C /path/to jacocoagent.jar) 2. add the following option to server's java args: "-javaagent:/path/to/jacocoagent.jar=dumponexit=false,jmx=true" 3. add additional jacoco option args as necessary (see: http://www.eclemma.org/jacoco/trunk/doc/agent.html) > Provide JaCoCo agent servlet to expose code coverage data to HTTP clients > during Sling Junit Test execution > ----------------------------------------------------------------------------------------------------------- > > Key: SLING-2810 > URL: https://issues.apache.org/jira/browse/SLING-2810 > Project: Sling > Issue Type: New Feature > Components: Testing > Affects Versions: JUnit Core 1.0.8 > Reporter: Mark Adamcin > Attachments: madamcin_system_sling_jacoco_exec_servlet.patch > > > create a simple REST endpoint for the jacoco agent at > /system/sling/jacoco.exec to expose: > jacoco Agent Status > ------------------------------------------------------------------------------------------- > HEAD /system/sling/jacoco.exec > Content-Type: application/octet-stream > 200: jacoco agent is attached and exposed through JMX > 404: jacoco agent not found > return IAgent.getExecutionData(false) > ------------------------------------------------------------------------------------------- > GET /system/sling/jacoco.exec > Content-Type: application/octet-stream > 200: execution data returned as response entity > 404: jacoco agent not found > Reset execution data and return jacoco.exec file > ---------------------------------------------------------------------- > POST /system/sling/jacoco.exec [optional param ":sessionId" to set a specific > sessionId after reset] > Content-Type: application/octet-stream > 200: agent was reset (with new sessionId if specified) and prior execution > data returned as response entity > 404: jacoco agent not found > Jacoco instrumentation for OSGi is rather limited in the sense that there is > one agent per JVM, and resetting the execution data resets it across the > board, which means that concurrent requests to this service on a shared > integration test server will need to be restricted during test execution to > avoid corrupting coverage data. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira