Automated testing using Maven Jenkins and JMeter

Source: Internet
Author: User
Tags apc

There are two plugins that can be implemented in the MAVEN build integration JMeter test, Jmeter-maven-plugin and Chronos-maven-plugin. Depending on the situation, here are some criteria for judging:

    1. The plug-in should not rely on the local jmeter installation.
    2. It must be able to start the JMeter test (no GUI) from the command line.
    3. JMeter's graphical user interface should also be implemented directly through plugins (for example, through a single maven target).
    4. It contains plug-ins for jmeter.
    5. The plugin should produce a meaningful report.

The first and second two are satisfied, Jmeter-maven-plugin can use a simple additional dependency without graphics Kg.apc:jmeter-plugins use JMeter directly, this is Jmeter-chronos-maven-plugin not.

The following is a configuration from jmeter-maven-example:

<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.8.1</version>
<configuration>
<!--
By default the test results is saved in a file
/target/jmeter/results/<testname>-<timestamp>.jtl
Further processing is easier without timestamp though.
-
<testResultsTimestamp>false</testResultsTimestamp>

<!--
To simplify debugging, it's advisable to adapt the loglevel.
The JMeter logs is written to the file Jmeter.log.
-
<overrideRootLogLevel>DEBUG</overrideRootLogLevel>

<!--
By default, the console output during a JMeter test run is suppressed.
We want to display the progress using the listener "Generate Summary Results"
(which periodically prints stats to stdout). Therefore we have the make sure,
That the JMeter output was not suppressed.
-
<suppressJMeterOutput>false</suppressJMeterOutput>

<!--
If tests fail (e.g. a http-request running into a timeout), the corresponding Maven
Goal also fails (and subsequent goals aren ' t executed anymore). We want to create graphs
From Test-results, no matter if some requests failed or not, so we ignore jmeter.
-
<ignoreResultFailures>true</ignoreResultFailures>
</configuration>
<dependencies>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
<version>1.0.0</version>
<exclusions>
<!--
Unfortunately some transitive dependencies cannot be found on mvncentral
And we have to explicitly exclude them.
For a complete list, see https://github.com/mlex/jmeter-maven-example/
-
<exclusion>
<groupId>kg.apc</groupId>
<artifactId>perfmon</artifactId>
</exclusion>
<!--...-->

<!--
Because of a bug in the Jmeter-maven-plugin (see
HTTPS://GITHUB.COM/RONNIE76ER/JMETER-MAVEN-PLUGIN/ISSUES/77) We have the
Exclude jmeter dependencies here, too.
-
<exclusion>
<groupId>org.apache.jmeter</groupId>
<artifactId>jorphan</artifactId>
</exclusion>
<!--...-->
</exclusions>
</dependency>
</dependencies>
</plugin>

This test file must be placed in/src/test/jmeter and you can edit and execute the test.

The test environment can be various, where a job is created in conjunction with Jenkins, allowing one click to perform JMeter tests, first using Maven's properties and configuration files. The following example project defines two different MAVEN configuration files, one for local execution and one for execution from Jenkins. The features of Maven are passed to JMeter via the UserProperties option.

<profiles>
<profile>
<id>local</id>
<properties>
<performancetest.webservice.host>localhost</performancetest.webservice.host>
<performancetest.webservice.port>8080</performancetest.webservice.port>
</properties>
</profile>
<profile>
<id>jenkins</id>
<properties>
<performancetest.webservice.host>my.test.system</performancetest.webservice.host>
<performancetest.webservice.port>80</performancetest.webservice.port>
</properties>
</profile>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.8.1</version>
<configuration>
<propertiesUser>
<webservice.host>${performancetest.webservice.host}</webservice.host>
<webservice.port>${performancetest.webservice.port}</webservice.port>
</propertiesUser>
</configuration>
</plugin>
</plugins>
</build>
</plugin>

Use JENKINS-CI for JMeter tests

Now that we've made different maven profiles for a variety of environments, the configuration of a suitable Jenkins job only takes a small step. The parameterized build is another good feature of Jenkins and is very useful for jmeter testing. Parameters can be used, for example, to allow the user to define the size of the load test (that is, the number of threads and the number of iterations).

Report

Using the Jmeter-graph-maven-plugin collection JMeter Cmdrunner tool, you can let us output graphical results in Maven build.

Https://github.com/codecentric/jmeter-graph-maven-plugin

Automated testing using Maven Jenkins and JMeter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.