JMeter中的周期性后台任务 [英] Periodic background task in JMeter
本文介绍了JMeter中的周期性后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的测试计划中的请求使用我知道会在 1 小时后过期的授权令牌.我需要以某种方式每 59 分钟重新请求一次令牌,直到测试完成.有人可以建议最好的方法吗 - 看起来像 While Controller 测试永远不会完成停留在永恒的 while 循环中.
Requests in my test plan use an authorization token that I know expires in 1 hour. I need somehow to re-request the token every 59 mins until the test finishes. Could someone please suggest the best method for that - looks like with While Controller the test would never finish staying in eternal while loop.
推荐答案
- 将另一个线程组添加到您的测试计划中.
- 将其配置为永远运行(或有足够的循环来持续足够长的时间)
- 将 Constant Timer 添加到第二个线程组.要使其每 59 分钟触发一次,请将
3540000
放入线程延迟"输入 - 将您的令牌获取"逻辑置于计时器下方.
- 如果您的令牌被存储为属性 - 主线程组将能够使用它.如果它是一个变量,你需要将它转换为一个属性,以便它 可以跨线程组使用,因为 JMeter 变量范围仅限于当前线程组.
- Add another Thread Group to your test plan.
- Configure it to run forever (or have enough loops to last long enough)
- Add a Constant Timer to that second thread group. To make it fire each 59 minutes put
3540000
into "Thread Delay" input - Place your "token-obtaining" logic under the timer.
- If your token is being stored as a property - main thread group will be able to use it. If it is a variable you'll need to convert it to a property so it could be used across thread groups as JMeter variables scope is limited to the current thread group only.
希望这会有所帮助.
这篇关于JMeter中的周期性后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文