jmeter stop current iteration

别说谁变了你拦得住时间么 提交于 2019-12-07 19:06:01

问题


I am facing the following problem:

I have multiple HTTP Requests in my testplan. I want every request to be repeated 4 times if they fail. I realized that with a BeanShell Assertion, and its already working fine. My problem is, that I don't want requests to be executed if a previous Request failed 5 times, BUT I also dont want the thread to end.

I just want the current thread iteration to end, so that the next iteration of the thread can start again with the 1st request (if the thread is meant to be repeated).

How do I realize that within the BeanShell Assertion? Here is just a short extract of my code where i want the solution to have

badResponseCounter is being increased for every failed try of the request, this seems to work so far. Afterwards, the variable gets resetted.

if (badResponseCounter = 5) {
        badResponseCounter = 0;
     // Stop current iteration
    }

I already checked the API, methods like setStopTest() or setStopThread() are given, but nothing for quitting the current iteration. I also need the preference "continue" in the thread group, as otherwise the entire test will stop after 1 single request failed. Any ideas of how to do this?


回答1:


Try this.

ctx.setRestartNextLoop(true);

if the thread number is 2, i tried to skip. I get the below result as i expected (it does not call b-2). It does not kill the thread either.




回答2:


In my opinion the easiest way is using following combination:

  1. If Controller to check ${JMeterThread.last_sample_ok} and badResponseCounter variables
  2. Test Action Sampler as a child of If Controller configured to "Go to next loop iteration"


来源:https://stackoverflow.com/questions/24207638/jmeter-stop-current-iteration

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