Recently my team and I faced an issue where we were going to have do frequent early performance testing as part of a large upgrade project. Whilst it was great to be given the opportunity to do this early performance testing, we didn't want to get into the mess of trying to maintain performance tests for an application that was still being developed, in addition to maintaining our functional automated test pack.
To get around this we decided to use our functional automated tests to drive the application and use JMeter to record the traffic which would form the basis of our performance test scripts. The reasoning was that we could then focus on our automated test maintenance as normal, and carry out performance testing as required, but treat our performance test scripts as disposable assets that we could regenerate quickly as required.
There are 4 main parts to this process:
- Recording the Test Plan
- Correlation
- Post Processing Using Groovy
- Replay & Debugging
Git Repository
A GitHub repository is available containing all the files used in this blog post: here
Recording
Recording browser traffic with JMeter using a Proxy Recorder is well documented on the JMeter website and a sample test plan is available in the the Github repo above in src/main/resources/Recording.Template.jmx to make the job easier.
It might not be obvious how to route your automated tests through JMeter so that traffic can be recorded. To do this we will specify a proxy when creating the browser using Geb. Note that the same method is used with Selenium. An example GebConfig file can be found in src/test/resources that will send browser traffic through JMeter.
- clone the project and navigate to the root of the project on the command line.
- Run the following command: gradlew jmGui -Precord - jmeter should now be open.
- Navigate to the Workbench.
- Select HTTP(S) Test Script Recorder and click Start.
- Click Ok on the Root CA Certificate popup
- You are now ready to start recording traffic from an automated test.
- Open another command prompt and navigate to the root of the project folder again.
- Run gradlew firefoxJmeterTest - Firefox should open and run the demo test against Google.
- Once the test has finished, switch to JMeter and view the transactions that have been recorded under the Recording Controller and click Save.
- We have now recorded our initial test plan ready for correlation and post processing
Tune in for Part 2 where we discuss correlation and post processing.