Performance Testing of AJAX calls via JMeter

♀尐吖头ヾ 提交于 2019-11-29 05:06:17

I'm not aware of any existing plugins which are capable of handling AJAX calls. Technically AJAX requests are basic HTTP Requests but they need to be executed in parallel using one extra thread per call.

For the moment it is not possible to have nested thread groups in JMeter so you'll have to do some extra coding using JSR223 Sampler to kick off AJAX requests. Main request and nested AJAX calls should be placed under Transaction Controller to look like a real-browser behavior.

Alternatively you can develop your own JMeter Sampler which will be able to spawn extra threads to simulate AJAX requests.

For details on 2 approaches above see How to Load Test AJAX/XHR Enabled Sites With JMeter guide.

Although it looks a bit dormant, I built this sampler and it is working fine for me. It creates a single sampler that you can add multiple requests to and they are all fired in parallel. Cookie/header managers/variables are available to the requests:

https://github.com/blackboard/jmeter-common/tree/master/src/main/java/blackboard/jmeter/sampler/ConcurrentHttpRequests

p.s. I added a line to the processResult method in ConcurrentHttpRequestsSampler.java to write the response body to a jmeter variable prefixed with the sub-sample name, as the response bodies from the sub requests aren't available to post-processors on the ConcurrentHttpRequests sampler:

try{
    jmeterContextOfParentThread.getVariables().put(subResult.getSampleLabel()+"_responseBody",new String(subResult.getResponseData(),"UTF-8"));
  }
  catch(java.io.UnsupportedEncodingException e) {
    jmeterContextOfParentThread.getVariables().put(subResult.getSampleLabel()+"_responseBody","Unable to read response data");
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!