Bug 51923

Summary: Counter function bug or documentation issue ?
Product: JMeter - Now in Github Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: trivial CC: p.mouawad
Priority: P2    
Version: 2.5.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Test Plan that reproduces the issue
Patch to function documentation
Patch to documentation
Simplified test case

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