Bug 40851 - - Loop controller with 0 iterations, stops evaluating the iterations field
Summary: - Loop controller with 0 iterations, stops evaluating the iterations field
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.2
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2006-10-31 03:05 UTC by Nikolay Diakov
Modified: 2007-05-13 14:36 UTC (History)
0 users

Test plan to show the bug (5.89 KB, application/octet-stream)
2007-05-11 05:49 UTC, Alf Hogemark
Suggested patch (1.09 KB, patch)
2007-05-11 05:55 UTC, Alf Hogemark
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Diakov 2006-10-31 03:05:54 UTC
We have a "loop" controler, the number of iterations of which depends on a 
BeanShell function. That function returns random number in some integer range. 
When the function returns a 0, the "loop" controller code re-evaluating the 
iterations field! This means if we want to run a user thread of 1000 runs with 
a "loop" controler that does iterations 3, 2, 4, 1, 0, 3, 2, 4, 1, 0, ... and 
so on each user run, the first time the iteration number hits 0, it stays 0.

We made a work around with an "if" controller that checks whether we have a 0 
and does not pass it to the loop controller.

Comment 1 Alf Hogemark 2007-05-11 05:49:32 UTC
Created attachment 20177 [details]
Test plan to show the bug

You will need to make a CSV file named "no_iterations.csv", with the number of
iteration of the loop for each iteration of the threadgroup, for example like
this :

You will see that you only get 3 samples (2+1).
Comment 2 Alf Hogemark 2007-05-11 05:55:18 UTC
Created attachment 20178 [details]
Suggested patch

This suggested patch causes the the loop evaluation to be executed on each
iteration, even if the loop has had a "Loop count" of value 0 in earlier

This can be useful for example if you are looping over company and their
customers as an example. If some company has 0 customers, this bug means that
the "customers" loop will never again be entered, even if the next company has
4 customers.
Comment 3 Sebb 2007-05-13 14:36:33 UTC
Thanks - applied to SVN in r537660