Maven JMeter plugin and report generation (the last steps to get it working) html

Maven JMeter plugin and report generation (the last steps to get it working)

JMeter (http://jakarta.apache.org/jmeter/)is a powerful tool for functional and performance testing web applications. JMeter, opposed to selenium, also works perfectly on generated applications (like Oracle ADF ). One of the key strengths of JMeter is the automation. The same test can be repeated after each (minor) release. This is a great help in executing time consuming regression testing.

We use Maven 2 (http://maven.apache.org/) in combination with Continuum (http://maven.apache.org/continuum/) as the basis of our AMIS-SoftwareStudio. With the build schema in Continuum we are able to execute both performance and functional regression testing every night (or even each hour if you like) on the most recent version of the application from our source repository.

The documentation on the JMeter wiki (http://wiki.apache.org/jakarta-jmeter/JMeterMavenPlugin) is to limited to get the JMeter plugin working at once. It does not handle the generation of reports and installing the plugin into your company repository. Most of the samples on the internet (use the Google to find Maven 2+JMeter) are based on extensive Ant scripts. The sample below shows how to get the Maven-JMeter-Plugin working in Maven2 with a minimum of extra code in your projects pom.xml.

Assume you have:

  • Java 1.5 and Maven 2.0.7 already installed
  • An internal central Maven2 repository in your network
  • And your maven settings.xml a reference to your local company repository (see below)

Add to settings.xml

<…>
<distributionManagement>
    <!--   Internal repository for deployment of AMIS artifacts -->
    <repository>
      <id>AMISMaven2Repo</id>
      <!--   Put the name of your company repository here-->
      <url>file:\\mavenrepository.amis.nl\maven2</url>
    </repository>
</distributionManagement>
<….> 

Install the Maven-JMeter-Plugin:

Install the plugin:
1.    Download the Maven-Jmeter-Plugin form the apache wiki (there is no official distribution yet)  Link here.
2.    Untar these files with e.g. WinRar or WinZip.
3.    Edit the pom.xml:

a.    Remove the reference to the yahoo music repository
b.    Add a compile plugin to force usage of jdk1.5 (to avoid compile errors)
The pom.xml should look like this (Link download):

4.    Go to the maven-jmeter-plugin folder and deploy the plugin in your local company repository:   mvn deploy (you can check first  if it works by using mvn install)

5.    The Maven JMeter plugin is now installed and available in your internal repository.

 Getting your project working with the JMeter plugin:

 This section is an extension on the information from the JMeter Wiki.

  1. Create a src/test/jmeter directory, and place your JMeter load tests there.
  2. Create a jmeter.properties file in src/test/jmeter. Just copy the default properties file from the JMeter install.
  3. Edit the jmeter.properties  and change the jmeter.save.saveservice.output_format to XML (jmeter.save.saveservice.output_format=xml) to force JMeter to produce XML files in stead of CSV files.
  4. Optionally configure includes and excludes in your pom.xml for which tests to run. If you don’t, it will just run **/*.jmx.
  5. Add a reference to http://maven.geotools.org/repository/ in your pom. This is some place where maven can download jmeter-2.2.jar. (other locations are also valid (use the Google)).  
  6. Add the Maven JMeter plugin and link it to the Verify phase of your project. This way it is automatically executed after deployment of the application on the target platform.
  7. Run the mvn verify command to start the JMeter tests.
        
    <build>
     <...>
       <plugins>
        <plugin>
           <groupId>org.apache.jmeter</groupId>
           <artifactId>maven-jmeter-plugin</artifactId>
          <executions>
                     <execution>
                         <phase>verify</phase>
                         <id>jmeter-tests</id>
                         <configuration>
                           <includes>
                            <include>amistest.jmx</include>
                           </includes>
                           <reportDir>target/jmeter-reports</reportDir>
                         </configuration>
                         <goals>
                             <goal>jmeter</goal>
                         </goals>
                     </execution>
                 </executions>
         </plugin>
       <plugins>
      <...>
    </build> 

Creating the JMeter results report:

This section explains how to generate a JMeter Report after executing the tests.
 

  1. Create a test_resources\jmeter\jakarta-jmeter-2.2\extras folder and add the following files form the JMeter Extras install: collapse.jpg; expand.jpg; jmeter-results-detail-report_21.xsl ; jmeter-results-report_21.xsl
  2. Add the xml-maven-plugin to force transition of the jmeter results.xml to HTML.
  3. Use the Filemapper option to rename the files to HTML
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>xml-maven-plugin</artifactId>
         <executions>
           <execution>
             <phase>pre-site</phase>
             <goals>
               <goal>transform</goal>
             </goals>
           </execution>
         </executions>
         <configuration>
             <transformationSets>
             <transformationSet>
               <dir>src/test/jmeter/testresults</dir>
               <stylesheet>test_resources/jmeter/jakarta-jmeter-2.2/extras/jmeter-results-detail-report_21.xsl</stylesheet>
               <outputDir>target/site/jmeter-results</outputDir>
                <fileMappers>
                 <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                 <targetExtension>html</targetExtension>
                </fileMapper>
               </fileMappers>
           </transformationSet>
          </transformationSets>
       </configuration>
    </plugin>

 

4.    Finally use antrun to copy the expand and collaps images to the generated target files. (see sample below)

5.    In continuum you can use the command mvn verify site-deploy to run the jmeter tests and deploy the results within the project site.

<!-- make sure the jmeter icons are copied to the site folder -->
  <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
               <execution>
                  <phase>site</phase>
                  <configuration>
                    <tasks>
                     <copy file="test_resources\jmeter\jakarta-jmeter-2.2\extras\expand.jpg"
toFile="target/site/jmeter-results/expand.jpg"> 
                     </copy>
                     <copy file="test_resources\jmeter\jakarta-jmeter-2.2\extras\collapse.jpg"
toFile="target/site/jmeter-results/collapse.jpg">
                     </copy>
                   </tasks>
            </configuration>
          <goals>
            <goal>run</goal>
          </goals>
         </execution>
       </executions>
   </plugin> 
 


9 Comments

  1. Ardesco February 9, 2012
  2. Marco October 4, 2007
  3. Lean October 1, 2007
  4. Lean August 30, 2007
  5. Robbrecht van Amerongen August 14, 2007
  6. Lean August 13, 2007
  7. Robbrecht van Amerongen August 13, 2007
  8. Robbrecht van Amerongen August 13, 2007
  9. Lean August 10, 2007