问题
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:
- Add setUp Thread Group to your Test Plan
- Add JSR223 Sampler to the setUp Thread Group
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')
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