本文介绍了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.
推荐答案
- 在测试计划中添加另一个线程组.
- 将其配置为永久运行(或具有足够的循环以持续足够长的时间)
- 向第二个线程组添加常量计时器.要使其每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中的定期后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!