https://issues.apache.org/bugzilla/show_bug.cgi?id=51999
Bug #: 51999
Summary: Counter increments by 2 when used in while controller
condition
Product: JMeter
Version: 2.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Main
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Maybe this is related to bug 28751 or not, or if already bug submitted but
don't think so.
I encountered an interesting bug/use case that's not documented for JMeter
(unless I overlooked the JMeter documentation somewhere).
I have a test plan with 1 thread group where I only need to use and thus only
want to increment a counter within a while loop. To use such, I would need to
define counter prior to use in while loop, but I wanted to compact and
streamline things so felt defining the counter before the while loop was
unnecessary. So this is what I did:
Create the counter, increment it, and evaluate its value in a condition all at
once as the while controller's condition
${__javaScript( ${__counter(TRUE,cnt)} <= 10 )}
then within the while loop, samplers can reference the counter ${cnt} value as
needed, which won't increment the counter.
But I found doing so incremented the counter by 2 instead of 1. It did start
with a value of one as expected. And it does work on a per thread level when I
tested with 2+ threads. And the loop does end after condition is false.
I also tried alternative of defining a user defined variable "cnt" with value
of 1 before and outside of the while loop then incremented it in the while
condition like this
${__javaScript( ${__intSum(${cnt},1,cnt)} <= 10 )}
but ended with same behavior of increment by 2.
I posted to JMeter list but got no response regarding whether this is a bug or
not. But a user found that if the counter is incremented within the while loop,
in a sampler, etc. it will then increment correctly for the loop.
But I find that rather less optimal. I don't see why putting the counter
incrementation as part of condition would be bad, same as how one uses a for
loop like for(i = 0; i < count; i++){}. I would have preferred a for controller
in JMeter, but there is only the While and ForEach controllers.
Unless there is a valid JMeter design choice for this behavior, I would think
this is a bug.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]