刷新Auth令牌,同时使请求在JMeter 3.3中运行 [英] Refreshing Auth Token while keep the requests running in JMeter 3.3
问题描述
在使用 Jmeter 3.3的情况下,我有以下情况:
我想每2.5分钟运行一次Get auth token
,同时不间断地运行[GET]
线程组.
I would like to run "Get auth token
" once every 2.5 minutes and meanwhile to run [GET]
thread group non stop.
换句话说,[GET]
正在从第一个线程组获取auth令牌,我想并行运行它们,并且仅在2.5分钟时更改一次令牌.
In other words, [GET]
is taking the auth token from the first thread group and I would like to run them in parallel and only change the token once at 2.5 min.
我试图向第一个线程添加一个常量计时器,但是直到计时器过去,第二个线程才开始运行.
I tried to add a Constant Timer to the first thread but the second thread is not running until the timer passed.
如何保持[GET]
不间断运行并在2.5分钟内仅使"Get Auth token
"运行一次?
How can I keep the [GET]
running non-stop and "Get Auth token
" only once at 2.5min?
LE:
[GET]
线程用于负载测试,应与约100个活跃用户一起运行(都使用相同的令牌)
[GET]
Thread is used for load tests and should be run with ~100 active users (all using the same token)
常量计时器已添加到HTTP采样器下
Constant Timer was added under HTTP Sampler
> Get Auth token
>> [POST] Auth token
>>> HTTP Header Manager
>>> Regular Expression Extractor
>>> Response Assertion
>>> Constant Timer
LE2: 我尝试在第一个线程组下添加一个Test操作.我没有设法使线程2在不等待线程1延迟之后运行.
LE2: I have tried adding a Test action under the first thread group. I did not manage to make Thread 2 run without waiting after Thread's 1 delay.
推荐答案
按照函数和变量用户手册一章
属性与变量不同. 变量是线程本地的;属性是所有线程共有的,需要使用__P或__property函数进行引用.
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.
因此,我建议通过 __setProperty()将您的authToken
转换为JMeter属性Get auth token
线程组中的函数,并使用
So I would suggest converting your authToken
into a JMeter Property via __setProperty() function in Get auth token
Thread Group and refering the value in Get
Thread Group using __P() function so once the authToken
value is updated all the threads will be using the new value instead of the old one.
这篇关于刷新Auth令牌,同时使请求在JMeter 3.3中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!