Bug 32252 - Counter isn't evaluated on first time through ForEachController
Summary: Counter isn't evaluated on first time through ForEachController
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.0.1
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2004-11-15 19:54 UTC by Peter Dolberg
Modified: 2005-07-10 17:19 UTC (History)
0 users

Demonstrates the bug with ForEach controllers and counters (53.95 KB, application/octet-stream)
2004-11-17 19:21 UTC, Peter Dolberg

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Dolberg 2004-11-15 19:54:24 UTC
If I add a counter to a forEach controller then the value set by the counter
isn't created until the second time through.  For example, I have a forEach
controller and under it I have a counter that sets the value of the "myCount"
variable. If I use the myCount variable in a sampler then ${myCount} evaluates
to ${myCount} in the output rather than, for example, the number 1.  If I add
the counter and the sampler into a loop controller under the forEach controller
then in the first loop ${myCount} evaluates to ${myCount} but on the next loop
${myCount} evaluates to 1. All other controllers work properly with the counter.
This setup should show the bug:

TestPlan (inputVar_1 is set to a value)
ThreadGroup 1 
   - ForEach Controller (input variable: inputVar)
      - Counter (start: 1, variable reference: forCount)
      - Http Sampler (uses ${forCount} somewhere)
ThreadGroup 2 
   - ForEach Controller (input variable: inputVar)
      - Loop Controller (loop count: 2)
         - Counter (start: 1, variable reference: loopCount)
         - Http Sampler (uses ${loopCount} somewhere)
ThreadGroup 3
   - (Not a ForEach) Controller
      - Counter (start: 1, variable reference: myCount)
      - Http Sampler (uses ${myCount} somewhere)

The results are as follows (where -> indicates evaluation of an expression):

ThreadGroup 1: ${forCount} -> ${forCount}
ThreadGroup 2, iteration 1: ${loopCount} -> ${loopCount}
ThreadGroup 2, iteration 2: ${loopCount} -> 1
ThreadGroup 3: ${myCount} -> 1

Of course, each run should should evaluate like ThreadGroup 3.

I am running on Windows XP SP2, using Java 1.4.2_05, and running Jmeter 2.0.1. I
also tested the most recent nightly build (Jmeter 2.0.2 RC1 build 11/8/04) and
it had the same behavior.  I can provide a testplan that shows this behavior, if
Comment 1 Peter Dolberg 2004-11-17 19:21:59 UTC
Created attachment 13482 [details]
Demonstrates the bug with ForEach controllers and counters

Attached is a JMX file which gives an example of this bug.
Comment 2 Sebb 2005-03-17 04:13:16 UTC
Thanks for the report - bug has been fixed in 2.0 branch