动态Paralell HTTP请求 [英] Paralell HTTP Request dynamically
问题描述
我需要在paralell中执行一些请求,我看到了jp @ gc-并行HTTP请求,但是我找不到一种将URL动态加载到控制器中的方法.我的问题是要命中的URL来自JSON响应;在变量中指示URL的方式是什么?是否存在使用JSR232或beanshell包括URL来操纵采样器的任何方法?或者,也许我该如何在执行时做一个线程组和一个HTTP采样器?
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?
亲切的问候,
Alejandro Longas H.
Alejandro Longas H.
推荐答案
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')
就是这样,现在并行HTTP请求采样器应该同时向上述URL发出2个请求.
That's it, now Parallel HTTP Request sampler should fire 2 requests to the above URLs simultaneously.
这篇关于动态Paralell HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!