Simplify/Automate JMeter scripts creation process
- PERF-23Getting issue details... STATUS - POC to simplify/automate JMeter scripts creation process
Overview
Currently, when writing JMeter scripts, we are manually capturing the requests in JMeter script which are triggered by the browser. It works fine for workflows which are relatively small(10-20 requests to backend) but are not feasible if there are 100 or more requests. We should come up with an approach to automate the capturing process.
For example, below query
GET /instance-storage/instances?query=(item.status.name="In transit") sortby title&limit=100&offset=0
The browser makes a call to at least 20-30 BE requests
Investigate and come up with alternatives to capture these queries at the browser level and import them to JMeter script.
Requirements
- Improve JMeter scripts creation process
- Automate manual steps
Approach & Design
There are 2 approaches:
(A) Record HTTP(S) requests using Apache JMeter HTTP(S) Test Script Recorder as documented
https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html
Pros:
- Easy to follow as it is already documented
- Works fine for HTTP websites as it does not require SSL Certificate
Cons:
- There are multiple steps to follow and could get lost if you miss anything
- Manually open up a port for JMeter and update network proxy in browser settings/preferences - once you update network proxy settings, requests to outside network will stop working unless you revert to default proxy settings
- For HTTPS websites, have to manually install SSL Certificate in browser
- We have to manual set URL Patterns to exclude being captured by JMeter script
- It captures a lot of redundant files such as HTML, gif, banners, images, config files
- Need FOLIO UI modules installed
(B) Use open-source Blazemeter Chrome plugin
The plugin can be downloaded from https://chrome.google.com/webstore/detail/blazemeter-the-continuous/mbopgmdnpcbohhpnfglgohlbhfongabi/related
You will have to sign up to start using it. Sign-up is free.
Start recording: execute the workflow
Stop recording and import to JMX file:
Open imported JMX file in JMeter:
Pros:
- Easy to install
- Easy to record HTTP(S) request in browser and import to JMeter script
- No need to set up proxy manually, everything is handled by the plugin
- It is open-source with 70k+ users
- The plugin is frequently maintained and upgraded
- The plugin generates clean and accurate JMeter script with almost no junk files
- Replay recorded JMeter script without any changes
- Captures HTTP(S) calls to the backend which is difficult to track manually
- The JMeter script can be edited in the browser before importing
- Automates and simplifies JMeter script creation process
Cons:
- Recorded JMeter script need to be refactored to comply with best practices
- Need FOLIO UI modules installed
This plugin was tested against the check-in-check-out workflow and works well with all HTTP(S) verbs.
Outcome:
After weighing in both approaches and after discussing with the team, approach B was accepted.
Links
https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html