Building thinking time delay with time based tasks?

社会主义新天地 提交于 2019-12-11 05:40:47

问题


I have this meter job for which I need to build some think time between certain HTTP Requests. But during those thinking time I still need to send a keep alive request on specific interval.

For example:

  • User login
  • get some profile information.
  • Then he start to do some work.

each unit of work is delayed by some random delay varying from 1 to 30 minutes. During that time we still need to send to there server a ImAlive request at fix interval (like 5 minutes). Once the thinking time is expired which could be at 17m12s for example, then the loop exit.


回答1:


For simulate the delay you can use Runtime Controller which will be executed with given seconds you define the keep alive requests, inside Runtime Controller add Timer as Gaussian Random Timer to add delay between keep alive requests.




回答2:


You can use While Controller with condition like:

${__groovy(${__time(,)} - ${TESTSTART.MS} < 1032000,)} 

Where:

  • __time() function - returns current time in milliseconds since start of Unix epoch
  • ${TESTSTART.MS} - pre-defined JMeter property where test start time lives
  • __groovy() function - allows execution of arbitrary Groovy code
  • 1032000 - milliseconds representation of 17m12s - (17 * 60 + 12) * 1000

So children of the While Controller will be executed for 17 minutes and 12 seconds after test start. If needed you can add another condition just in case you want to exit the loop earlier. See Using the While Controller in JMeter guide for more details.



来源:https://stackoverflow.com/questions/47516473/building-thinking-time-delay-with-time-based-tasks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!