To create a Continuous Delivery Pipeline which includes Performance Testing process to detect any performance related issues as early as possible.
Usually the full scale Performance Test will be done in the Staging/Pre-Production environment which could be identical to your Production environment. Code push to Staging happens after thorough QA functional/regression verification is done. So even if QA certifies the build, there is a chance that code might not work as expected at certain load which could be found only in Staging environment. This performance issue requires code change -> build -> QA verification once again which could postpone your Production push!
So, Can we fit the performance testing into the existing continuous development & testing process to detect the performance issues as early as possible?
Yes! We absolutely can! The idea here is to run the performance test in the lower environments [Dev/QA] (we might have to adjust the load accordingly) & to compare the results against some baseline metrics. Note that this is NOT going to replace the full scale performance test which we will do in the Staging environment.
Lets see how we can implement the above process in this post by using JMeter + Ant + Jenkins.
ANT: It is a build tool – here we will be using ANT to execute a set of tasks in the given order. For ex:
You would be calling these tasks once you are done with the build and unit/integration tests.
Create ANT-JMeter Project:
Now we are going to create an ANT project as given below. [I have shared this sample project in GitHub]
test folder is going to contain your .jmx file
lib folder will have all the libs required for ant-jmeter task + any other libs you want to include for your jmeter test.
function folder will have all the beanshell scripts for your test.
build.properties A property file which is going to pass the values for JMeter UDV.
This is an important part. Ant needs a build.xml file (it does not have to be ‘build.xml’ – but that is a default name ant will expect) where you have all the tasks defined.
Lets create a build.xml file as given below. [I have shared this sample project in GitHub]
We have 3 targets here.
Now in the command prompt/terminal, go to the project folder and type ‘ant show-test-properties‘. You should see below output.
ANT: Run JMeter Test:
Lets run the test by issuing command:
Now we can see we have the log and result files created.
Run below command to generate the HTML report under output folder
ant console log:
The above HTML file itself has nice charts. However you still might want to create charts through command-line to send via emails/slack etc.
To create charts, we need few external plugins.
Run below command to install the required plugins.
Once plugins are installed, Generate charts by issuing command:
Once the job is complete, We can see all the charts we wanted are generated and placed under the result folder.
Run all ant tasks by issuing a command: ant all
ant -v run
Now we will be able to run our JMeter test by passing the test properties from a property file through ANT. We also have automated creating HTML file and creating charts from the result file.
We will see how to invoke this test from Jenkins in the next post.
Thanks to [Ref: http://www.programmerplanet.org/projects/jmeter-ant-task/]