Search code examples
mavenjmeterreportaggregatesummary

Show aggregate report info in console when running jmeter tests with mvn


I have a mvn project in which is also integrated jmeter, to test performance. So far I have 6 thread groups in my test plan, all of them contains HTTP Requests. I run the tests using the command "mvn clean verify" from jmeter-maven plugin. Among the results I found multiple rows like this:

summary + 1 in 00:00:02 = 0.6/s Avg: 208 Min: 208 Max: 208 Err: 0 (0.00%) Active: 6 Started: 12 Finished: 6

I would need some extra information in console, especially the name and the avg time of each thread group or of the HTTP Request that ran. For example, something similar with aggregate report from GUI mode :

Label Samples Average Median 90% Line 95% Line 99% Line Min Max ...

AppleCodeRequest 6 196 119 279 284 284 108 284
PearCodeRequest 3 382 485 490 490 490 173 490

I want this because I am using a sh script to run the tests and I would like to trigger some performance issues before opening the html reports.

Is there any way to obtain this? Maybe some user properties (even if I searched for one and no result) or some workaround ?


Solution

  • The easiest solution is going for a plugin like BlazeMeter Uploader, this way you will be able to observe real time test metrics in a fancy web UI. You can install BlazeMeter Uploader plugin using JMeter Plugins Manager

    enter image description here


    Alternative solution would be using JMeterPluginsCMD Command Line Tool.

    1. Add the next lines to your pom.xml file

      <configuration>
          <jmeterExtensions>
              <artifact>kg.apc:jmeter-plugins-cmd:2.2</artifact>
              <artifact>kg.apc:jmeter-plugins-synthesis:2.2</artifact>
              <artifact>kg.apc:jmeter-plugins-dummy:0.2</artifact>
              <artifact>kg.apc:cmdrunner:2.0</artifact>
              <artifact>kg.apc:jmeter-plugins-filterresults:2.2</artifact>
              <artifact>kg.apc:jmeter-plugins-cmn-jmeter:0.6</artifact>
          </jmeterExtensions>
          <!-- The plugin uses some broken dependencies
               An alternative is to set this to true and use excludedArtifacts, see below
          -->
          <downloadExtensionDependencies>false</downloadExtensionDependencies>
          <propertiesJMeter>
              <jmeter.save.saveservice.autoflush>true</jmeter.save.saveservice.autoflush>
          </propertiesJMeter>
      </configuration>
      
    2. Add another Thread Group to your Test Plan with 1 user and infinite number of loops

    3. Add JSR223 Sampler to your Thread Group
    4. Put the following code into "Script" area:

      SampleResult.setIgnore()
      def resultFile = new File('../results').list().first()
      "java -jar ../lib/ext/cmdrunner-2.0.jar --tool Reporter --generate-csv temp.csv  --input-jtl ../results/$resultFile --plugin-type AggregateReport".execute().waitFor()
      println("cat temp.csv".execute().text)
      new File("temp.csv").delete()
      
    5. Control how frequently you want to see this info using i.e. Constant Timer
    6. You should be able to see the results in the console window:

      enter image description here