Tuesday, May 12, 2015

Automate Jmeter load tests with Jenkin and Maven

As you know is Jenkin is widely used  tool for Continuous Integration in performance testing, So given tried for installation/configuration of Jenkin. Following are short step to automate load testing process(jmeter scripts) in Jenkin.

1. Configure apache-maven for jmeter script repository
  #cd /usr/local/apache-maven-3.1.1
  #export PATH=$PATH:/usr/local/apache-maven-3.1.1/bin
2. Create pom.xml in above repository(/var/tmp/jmeter-demo)
  #/var/tmp/jmeter-demo
3. Verify repository by - mvn verify
   -  Maven will download and install jmeter related jar in repository
   - e.g Repository path :
[root@Cassandra jmeter-demo]# ls
pom.xml  src  target
jmeter jar: target/jmeter/lib/ext/
Content of pom.xml
---------------------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>jmeter-demo</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>jmeter-demo</name>
        <url>http://maven.apache.org</url>

        <build>
                <plugins>
                        <plugin>
                                <groupId>com.lazerycode.jmeter</groupId>
                                <artifactId>jmeter-maven-plugin</artifactId>
                                <version>1.4.1</version>
                                <executions>
                                        <execution>
                                                <id>jmeter-tests</id>
                                                <phase>verify</phase>
                                                <goals>
                                                        <goal>jmeter</goal>
                                                </goals>
                        <configuration>
                                <proxyConfig>
                                    <host>proxyhost</host>
                                    <port>8181</port>
                                    <username>username</username>
                                    <password>password</password>
                                    <hostExclusions>localhost</hostExclusions>
                                </proxyConfig>
                            </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
---------------------------

4. Install jenkin rpms and start jenkin ( #/etc/init.d/jenkins start)
5. Load performance plugin through jenkin UI
6. Create Project from jenkin UI
7. onfigure project for jmeter
    - In Build section, add pom.xml path
    - In Post-build Action > Add New report > Jmeter > give path for .jtl file
- Save the configuration
7. Start build. Once build complete check performance Trend


Reference:-
https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin 

No comments:

Post a Comment