testngprofilingprofilermaven-surefire-pluginjprofiler

How to profile tests running on remote machine using JProfiler


I have a java project that runs thousands of test cases. I am using maven-surefire-plugin with testng. I want to profile these tests while they are running on the remote machine. It's basically a typical maven build process followed by running of test cases. I tried using the remote attach feature of JProfiler but that causes my test cases to keep executing. Is there a way that I can create a snapshot on the server while they are executing and analyze it later. Like some plugin/dependency that I can add to my project. I could see the options to take a heap dump with JProfiler but could not find the documentation for snapshots.

Tried using remote attach, but it's taking too long and test cases keep executing and never complete.


Solution

  • Profiling tests is best done in an automated way with triggers and profiling actions.

    You pass the profiling parameters as VM parameters to the JVM that runs the test, these include a reference to a config file that contains the configured triggers and actions. As triggers you can use the "JVM startup" and "JVM exit" triggers. In the "JVM startup" trigger you can start recordings and in the "JVM exit" trigger you can save a snapshot.