Load Testing is one of the major aspect which we all do for our applications, especially for those which have publicly available pages and has very heavy traffic. JMeter is a very commonly used tool for doing load testing. As developers, it is a very good tool to have in our skill set.
However we, as lazy productive developers are always trying to automate the processes so that we just need to configure it once and be able to run it from anywhere. Also added it to is the small matter of eliminating internet speed from the equation while load testing the pages. (Especially when we are concerned only with how the server responds to high loads). This means that we will be running the tests one of our remote servers which are closer to QA servers(or even the same machine!). We may also run schedule the tests to be run at night.
Himanshu and I modified some of the scripts he had written for one of the projects to make it more generic and generate Jmeter scripts and also a utility to run it for us and generate reports. The scripts(which run on *nix machines) are available here.
The steps to set it up are as follows
- Download Jmeter and install it at the location /opt/jmeter (The path to jmeter home would be /opt/jmeter)
- Install ant by doing (sudo apt-get install ant on Ubuntu)
- Clone/Fork the Git repository to your machine
- Add the ant-jmeter-<version>.jar file available at the Git Repo to /usr/share/ant/lib
The steps to configure and run the scripts are as follows
- Update conf.txt to suit your needs. It is a CSV file with the following parameters specified. URL,PORT,Path/?QueryParam=Value,TestName
- Update generate.groovy to configure parameters like number of threads, duration for the run, Test Name, Test Title etc
- Make generate.groovy and driver.sh executable (chmod +x generate.groovy driver.sh)
- Execute generate.groovy (./generate.groovy). This generates the required jmx files and updates the build.xml file
- Execute driver.sh (./driver.sh). This run the actual test
- The reports will be available under the target directory as TestName.html
The utility is very simple at the moment which caters only to simple get requests. In future, we would like to include Controllers, Config elements etc to be configurable, so that this utility can also be used for running Load Tests for secure pages.
We would be delighted to know what you would like to see in the future versions of this utility.