I am a committer and member of the JMeter Project Management Committee at Apache. I work at SeLoger, the biggest French Real Estate platform. Performance matters at SeLoger and load testing is one of the ways we use to achieve good performance. In this post, I will talk about API Load Testing with cURL and RedLine13.
SeLoger faces many challenges when performing load tests:
- Many websites
- Many sprint durations
- Small performance team
But fortunately to achieve our goals we have lots of motivated people.
This process is possible thanks to:
- RedLine13 implemented some of our feature requests
- Ubik Load Pack implemented Import from cURL feature
Special thanks to Philippe Mouawad who improved “Import from cURL” feature after a discussion.
The first step is to configure RedLine13 to be allowed to use AWS account.
At SeLoger we use Cloud Custodian to:
- Check AWS resources tag/naming compliance
- Turning-off resources not used at night
It means that if an EC2 instance doesn’t have the expected tags, Custodian shuts it down.
Luckily RedLine13 allows us to set enough tags in our EC2 injectors to avoid it.
Last important configuration is to add some plugins.
In particular, JMeter Report which allows us to have the desired granularity in JMeter Reporting Dashboard.
More information on this blog post.
I will work with a developer during this step to script the test case quickly and share best practices with him.
Now it’s time to script our test case and we need to be as productive as possible to proceed with the execution and analysis of our tests.
There are many ways to write scripts in JMeter, but the fastest in our case is to use “Import from cURL” feature (in Apache JMeter 5.2 preferably).
I am asking the developer where I can find the swagger of the API.
Here we will script only one API endpoint (but you can add more).
This API allows us to get details from a real estate identifier.
We will get the cURL command from Swagger.
We can finally start JMeter.
Go to Tools -> Import from cURL and paste the cURL command line from Swagger.
Our script is generated.
And like we can see there are JMeter property function (__P()) in scripts. It allows us to modify these options without modifying our script when we execute our script.
We can execute this script without modification, but we will add some more best practices to improve it.
We will start by variabilizing the identifier of the real estate to have a more realistic script.
To do it we will put all our real estate identifiers in a CSV file and add a “CSV Data Set Config” to our script.
And use it in our “HTTP Request”.
Next step, add an assertion to validate the response with “JSON JMESPath Assertion”.
To have the easiest solution we will use a Constant Throughput Timer and __P function.
To finish our script we will use __P to have an independent environment script.
Our script is ready, it’s time to switch to RedLine13.
I still continue to work with a developer in this step.
Because RedLine13 injectors are in our AWS account, it’s easy to load test an internal API because the network is already configured.
This is great, because we want to test an internal API.
We import our JMeter script into RedLine13 and Start a Load Test.
Automatically RedLine13 will detect all the properties defined in our scrip with the __P() function.
Here we can modify all parameters we want (for example if we have used a different environment for scripting, we can change the host parameter).
The last thing to do before executing the test is to modify the granularity.
We can execute our load test and follow the progress with the RedLine13 realtime dashboards.
At the end of the load test I analyze the results with the “Apache JMeter Dashboard Report”.
To improve performance culture and allow the performance team to help other teams, it’s time to pass the responsibility to the team.
No need for advanced knowledge of scripting and/or preparation of an injection environment, now the developer can just clone the test.
Modify the duration, throughput, host, etc. in the “Advanced JMeter Test Options” -> “Option String”
And execute the load test.
Of course the performance team is still available to analyze the results.
We are still working on it, but the next will be to automate some load test in our CI/CD pipeline.
It will allow us to:
- Execute more tests
- Have the quickest feedback
RedLine13 and its API will help us to reach this new stage without exploding our test budget and by remaining easy.