Bug 45839 - Test Action : Allow premature exit from a loop
Summary: Test Action : Allow premature exit from a loop
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.3.2
Hardware: PC Windows XP
: P2 enhancement with 2 votes (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2008-09-18 15:30 UTC by Sebb
Modified: 2012-02-02 12:53 UTC (History)
3 users (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Sebb 2008-09-18 15:30:02 UTC
It might be useful to be able to exit a loop prematurely.
Comment 1 RobSay 2008-09-22 05:41:01 UTC
More than 'might be useful'(!)

In load testing of complex web applications with multiple scenarios consisting of multiple steps, the inability to terminate a loop is a big issue.

In order to end a loop based on a response (i.e. as part of the test design), a complex arrangement of controllers can sometimes be arranged (While, If etc).

Terminating a iteration loop in the event of error is next to impossible. Failure of a single test step frequently leads to a cascade failure of remaing steps in the loop. The problem is that this skews the results. What is in fact 1 error gets reported as many problems.

The ability to exit a loop (but maintain the thread) should be accessible programatically (beanshell?) and embedded within controllers (terminate loop on error)
Comment 2 RobSay 2008-09-22 05:46:54 UTC
Looks like this could be related to: #30563

(Although the fix attached to that issue appears to be doing something slightly different to the functionality described in the request)
Comment 3 Sebb 2008-09-22 06:32:36 UTC
Yes, Bug 30563 is slightly different in that it skips to the next iteration of the enclosing loop, rather than exitting the loop entirely.

It would be useful to have both NEXT and LAST functionality.

Maybe the NEXT patch can be extended.

As to BeanShell access, that should be fairly trivial to arrange once the functionality has been added.
Comment 4 Sebb 2008-09-23 04:03:38 UTC
Unfortunately, the patch provided in bug 30563 does not work properly.
Comment 5 Philippe Mouawad 2011-11-11 15:49:52 UTC
Start next loop option has now been fixed.

*** This bug has been marked as a duplicate of bug 30563 ***
Comment 6 Oleg 2011-12-22 11:21:04 UTC
"Start next loop" - good, but it is not the same as "exit from loop"
In some cases it is needed to exit loop.
Now we can use "While" controller with condition, and inside this controller we can set some flag so at next time condition of "while" controller will become false and loop will interrupt.
But it would be more clear and more comfortable to use "loop controller", and exit from loop by condition inside loop...
Is it planned to do it?
Comment 7 Ian Brandt 2012-01-26 22:53:25 UTC
I would like to see this reopened to cover starting the next thread loop without registering a sample error.  Per comment 3 this is different from what's offered by bug 30563.

In my test plan I have a login fragment that chooses a random user from all possible users in my test data.  A few of these users are setup with no data, which is a valid scenario in production for brand new users.  In this case they are given a no-data page in response to logging in as there is no functionality yet available for them.  I then have thread groups for each of my test scenarios that include the login fragment.

If I use an assertion to fail the login fragment when the no data page is returned, and the Start Next Thread option on the thread group from bug #30563, the issue is the Summary Report and View Results Tree listeners show the no data cases as errors, which they are not.

The only other option I can think of is to capture the no-data state with a post-processor, and use an If controller in every single thread group that uses my login fragment to test for the no data scenario before proceeding.  This is a lot of duplication in my test plan.

If I could place that If controller in the fragment, and use a "Start Next Thread Loop" Test Action that might do the trick.  If I could flag a given assertion to not register as a sample error, but still trigger the thread group's "Start Next Loop" functionality that might also do.

Referring to comment 3 I can also see a use for a "Start Next Loop" Test Action that would apply to the closest loop controller, or the thread loop as applicable (basically the equivalent of the "continue" keyword in Java).
Comment 8 Philippe Mouawad 2012-01-29 18:12:47 UTC
I have a fix for this one, will commit it once 2.6 vote is done.
Comment 9 Philippe Mouawad 2012-02-02 12:53:33 UTC
Date: Thu Feb  2 12:50:53 2012
New Revision: 1239590

URL: http://svn.apache.org/viewvc?rev=1239590&view=rev
Bug 45839 - Test Action : Allow premature exit from a loop

Comment 10 The ASF infrastructure team 2022-09-24 20:37:42 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2154