Bug 51923 - Counter function bug or documentation issue ?
Summary: Counter function bug or documentation issue ?
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.5.1
Hardware: All All
: P2 trivial (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-30 07:23 UTC by Philippe Mouawad
Modified: 2011-10-04 18:02 UTC (History)
1 user (show)



Attachments
Test Plan that reproduces the issue (12.36 KB, application/octet-stream)
2011-09-30 07:23 UTC, Philippe Mouawad
Details
Patch to function documentation (906 bytes, patch)
2011-09-30 15:18 UTC, Philippe Mouawad
Details | Diff
Patch to documentation (574 bytes, patch)
2011-09-30 18:46 UTC, Philippe Mouawad
Details | Diff
Simplified test case (10.49 KB, text/plain)
2011-09-30 18:47 UTC, Sebb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2011-09-30 07:23:13 UTC
Created attachment 27642 [details]
Test Plan that reproduces the issue

Hello,
Issue seen by deepak.
Per the documentation:
"The counter generates a new number each time it is called, starting with 1
and incrementing by +1 each time."

However
ThreadGroup
+${__counter(TRUE,ref)}HTTPSampler1
+DebugSampler
+${__counter(TRUE,ref)}HTTPSampler2
+DebugSampler
+View Results tree

Generates the number 1 in both cases.
Comment 1 Philippe Mouawad 2011-09-30 07:27:18 UTC
Hello,
I confirm this issue on 2.5 and 2.5.1.

Analyzing it, issue is due to the fact that if you have 2 __counter with same ref, you will have 2 instances of CounterConfig.

As perTheadNumber is not static, 2 counters will be incremented separately.

So either it's a feature then documentation should be fixed
Either it's a real issue, but fix can impact existing scenarios that excpect this behaviour.

Regards
Philippe
Comment 2 Philippe Mouawad 2011-09-30 07:31:46 UTC
(In reply to comment #1)
> Hello,
> I confirm this issue on 2.5 and 2.5.1.
> 
> Analyzing it, issue is due to the fact that if you have 2 __counter with same
> ref, you will have 2 instances of CounterConfig.
> 
Error : 2 instances of IterationCounter
> As perTheadNumber is not static, 2 counters will be incremented separately.
> 
But making it static is not the fix.

> So either it's a feature then documentation should be fixed
> Either it's a real issue, but fix can impact existing scenarios that excpect
> this behaviour.
> 
I think it's a feature
> Regards
> Philippe
Comment 3 Philippe Mouawad 2011-09-30 15:18:48 UTC
Created attachment 27650 [details]
Patch to function documentation
Comment 4 Sebb 2011-09-30 18:33:17 UTC
The docn already says:

>>>
The counter function instances are now completely independent. [JMeter 2.1.1 and earlier used a fixed thread variable to keep track of the per-user count, so multiple counter functions operated on the same value.] The global counter - "FALSE" - is separately maintained by each counter instance.
<<<

If anything needs to be clarified, it is that paragraph.
Comment 5 Philippe Mouawad 2011-09-30 18:46:40 UTC
Created attachment 27651 [details]
Patch to documentation
Comment 6 Sebb 2011-09-30 18:47:54 UTC
Created attachment 27652 [details]
Simplified test case

Here is a simplified test case using Java samplers instead of HTTP.

Also included is a PreProcessor that updates the COUNT variable for every sample in the thread
Comment 7 Sebb 2011-10-04 18:02:05 UTC
URL: http://svn.apache.org/viewvc?rev=1178883&view=rev
Log:
Bug 51923 - Counter function bug or documentation issue ? (fixed docs)

Modified:
   jakarta/jmeter/trunk/xdocs/changes.xml
   jakarta/jmeter/trunk/xdocs/usermanual/functions.xml
Comment 8 The ASF infrastructure team 2022-09-24 20:37:47 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2571