0

We are trying to find code coverage of our java services using automation tests that are written in Python. We want to use jacoco for recording the coverage data using on-the-fly instrumentation.

Details of setup :

  1. We have our application deployed and running on Remote Machine A (Its actually in kubernetes cluster but let's just assume a remote machine for now.)
  2. We are executing our automation tests from another Remote Machine B.

We are able to get the code coverage data when we are running on our local system using below commands.

  • Command to start the recording of coverage in tcpserver mode:-

java -javaagent:<path/to/jacoco>/jacocoagent.jar=port=9005,output=tcpserver,address=* -jar app.jar

  • Below is the command to dump the execution data:-

java -jar <path/to/jacoco>/jacococli.jar dump --address localhost --port 9005 --destfile jacoco_report.exec

Now we want to move the setup to our respective machines (A & B) as mentioned above. Can anyone please help as to what would be the address we need to provide to the jacocoagent.jar whether it would be IP address or host of Machine A or Machine B?

Saurabh Rai
  • 45
  • 1
  • 6

1 Answers1

0

Your command line for jacocoagent can stay the same, because address=* already tells the agent to listen on all network interfaces, i.e. localhost as well as remotely reachable ones.

You simply need to adjust --address for the jacococli dump command, specifying a host name such as my-remote-machine or an IP address such as 1.2.3.4. Of course, you also need to make sure that the port on the remote machine is reachable from the network segment on which jacococli is supposed to run.

I do not speak Kubernetes, but usually you need to configure VM or cluster network settings in a way which passes through connections on the target port to the corresponding VM or server. But with regard to JaCoCo, this is really all there is to do. It is rather trivial.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • So for the jacococli.jar the address would be the host or IP of the remote server on which my application is running? – Saurabh Rai Jan 14 '22 at 04:08
  • Exactly. If the cluster has a single IP and the instrumented target VM is running on another IP inside it, you need to make sure that the cluster IP passes through the connection to the target JVM's node on the corresponding port. – kriegaex Jan 14 '22 at 04:19
  • So after you have evaluated my answer, would you please accept and upvote it, if it is correct? You simply click on the grey check mark beside the answer, turning it green. Thank you. – kriegaex Jan 16 '22 at 04:22