JMeter – Challenges and my resolutions

Last few weeks I have been working with JMeter, to develop one performance testing framework. Purpose of the initiative is to test our cloud infrastructure with certain amount of load. When I started the project, there were roadblocks, challenges and needed to invent new ideas. In this post I’ll describe few of the challenges and resolutions I implemented to overcome those obstacles.
  • Data Driven Test – To inject JSON requests to our API requests, initially I started with hard-coded data in Body section of the HTTP request sampler. Then realized, hey, if I feed these data from file, then it would be easier for me to reuse same for different plan as I’ll be testing same API for different test purpose. So,

_FileToString is the function I was looking for. I wanted to read content of the file and post it during API call. So here is function to do that. But hang on! it’s not replacing ${__UUID()} part with unique id!
  • Function call and variables – That problem of UUID led me to another obstacle. It was literally a roadblock for me. But thanks for having Stakeoverflow in our life :). Initially I though to use beanshell preprocessor to read content of the file then replace the value from code. Then I came across this thread in Stakeoverflow, which solved my problem. I wrapped FileToString call with eval as follows:

So I know how to work with function calls and variables for the content fetched from file :).
  • Reuse Samples: I am not 100% sure whether my solution is proper or not, but at least this solved my problem. When I was designing my tests, then I realized there are few API calls I need to make multiple times. So I started to explore way to reuse JMeter samplers, like HTTP Request. So steps to have reusable controller is as follows:
    1. Add a Simple Controller from Add > Logic Controller > Simple Controller to your thread group.
    2. Then add the HTTP Request sampler under that simple controller. This HTTP Request will be used to send request to the API.
    3. Now add another Simple Controller (as we did in step 1) into your thread group.
    4. Add one Module Controller (Logic Controller > Module Controller) under the newly added Simple Controller.
    5. Select which controller you want the module controller to load for you.
That’s it! Now you should be able to reuse same HTTP Request as much as you want.
So far that’s from me for now regarding JMeter, I’ll be updating this post with new challenges and solutions because I am sure that a number of obstacles are waiting for me ahead in the alley :).

One thought on “JMeter – Challenges and my resolutions

Leave a Reply

Your email address will not be published. Required fields are marked *