Thread groups will help to manage and configure loads of your APIs.
Now, we are going to add our Http endpoints under Thread Group. Right-click on it => Add => Sampler => HTTP Request element. Under this control, you will configure the API. Here, I named it “Get Students Request” and added my API URL into the path and method.
In case you have any specific headers that should be part of this get HTTP request, then right-click on the HTTP Request that you added just now => Add => Config Element => HTTP Header Manager => Add your header and value which is specific to this request on clicking on Add.
I have other endpoints for the POST request. Similarly, I added new Http Request on clicking on Thread Group and named it as “Create Student Request” and added JSON request body, on click on Body Data.
Here, I am generating a random string for the email address field to make it unique. But this completely depends on your requirement.
Until now, we have successfully configured our 2 HTTP Requests – GET and POST. In the same way, you can add your other requests like PUT and DELETE.
Now at this point, you may have a question on how we are authorizing those HTTP Requests. You may have common herders like “Ocp-Apim-Subscription-Key” or “Content-Type” that need to send across all endpoints. We can easily achieve this by configuring a common HTTP Header Manager under the thread group.
Right click on Thread Group => Add => Config Element => Select HTTP Header Manager. Add those headers one by one.
For authorization herder, there are multiple ways we can configure JWT token value in JMeter. For the simplest approach, I have increased the lifetime of my JWT token so that it won’t have an impact during load testing and generated JWT token using Postman and pasted here.
Adding Listeners
To view the results and statistics of performance testing, we need to add Listeners. This will help to monitor and view the results in a nice format. There are several types of listeners are available there but for this test, I have added View results tree, View Results in Table, Summary Report.
Right-click on the Thread Group => Add => Listener and select and add them one by one.
Running Load Test
Once you saved the project, a JMX file will be created. Check Thread group settings before running. It depends on your requirement of how much load you can put into. Here is my sample setup of Thread Group properties.
- No of Threads/Users: 100
- Ramp-up period (sec): 0
- Loop Count: 5
Now we can start the test by clicking the Green Play button on top (red box in screenshots). This will start all the thread groups as didn’t mention the Ramp-up period and the results will be capture on Summary Report as shown below. If you set a ramp-up period, then the thread will be started periodically, not at the same time.
If you have done the test plan set up correctly, then you should see the output as below. In case you want to re-run the test again, then clean up the previous result by clicking on the Clear All button on top (green box in screenshots).
Summary Report