Paralell HTTP Request dynamically

点点圈 提交于 2021-01-29 19:31:19

问题


I need perform some requests in paralell, I saw jp@gc - Parallel HTTP Requests, but I can´t found a way to load dynamically the URL´s in to the controller; my problem is the URLs to hit come from a JSON response; What is the way to indicate the URLs in a variable? Exist any way to manipulate the sampler using a JSR232 or beanshell to include the URLs? Or maybe how can I do a Thread Group and a HTTP sampler in execution time?

Kind Regards,

Alejandro Longas H.


回答1:


Put the variable as${url} in Path field in HTTP Request and keep protocol and server name fields empty

If you save in url variable name full URL, it will execute URL as is

As a special case, if the path starts with "http://" or "https://" then this is used as the full URL.




回答2:


If you're looking for a code to add URLs to the Parallel HTTP Requests sampler in the JMeter runtime:

  1. Add setUp Thread Group to your Test Plan
  2. Add JSR223 Sampler to the setUp Thread Group
  3. Put the following code into "Script" area:

    SampleResult.setIgnore()
    def testTree = ctx.getEngine().test
    def parallelSamplerSearch = new org.apache.jorphan.collections.SearchByClass<>(com.blazemeter.jmeter.http.ParallelHTTPSampler.class)
    testTree.traverse(parallelSamplerSearch)
    def parallelSampler = parallelSamplerSearch.getSearchResults().first()
    parallelSampler.addURL('http://example.com')
    parallelSampler.addURL('http://jmeter.apache.org')
    
  4. That's it, now Parallel HTTP Request sampler should fire 2 requests to the above URLs simultaneously.



来源:https://stackoverflow.com/questions/61976546/paralell-http-request-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!