You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sebb <se...@gmail.com> on 2014/07/31 00:58:06 UTC

Re: Config Element:Counter based on Thread/User number?

On 30 July 2014 22:06, rxfillpharm <rx...@yahoo.com.invalid> wrote:
> Hello,
> New to JMETER , and have a question regarding Config Element->Counter.
>
> In my thread group, my first element is a Counter.  I want to
> use this counter to construct a logon id, where logon ids are
> user0001, user0002, user0003 etc.  When loop count > 1,
> the logon id will be the same for each loop of that user.
>
> I expected that Counter would always equal __threadNum, such that
> when __threadNum=2, Counter=2 as well.
>
> Instead, Counter is being incremented with each run of the
> thread group.
>
> As a test, I created a user parameter: threadrun=${__threadNum}${__counter(true)}
> The values when I run the test using Number of threads=2 and Loop Count=2 are:
>
>      Counter = 0001
>      threadrun = 11
>
>      Counter = 0002
>      threadrun = 21
>
>      Counter = 0003  (I want this to be 0001)
>      threadrun = 12  (correct!)
>
>      Counter = 0004  (I want this to be 0002)
>      threadrun = 22  (correct!)
>
> 1.  How can I get Counter to match thread number?

Have you tried:

Start = ${__threadNum}
Increment = 0

> 2. If that is not possible, how can I use __threadNum to construct my logon id.
>     __threadNum value is consistently correct, but it does not have the leading
>    zeros that I need.

Use one of the scripting functions (jexl, javascript, beanshell) or
scripting test elements to convert the threadNum string to a number
and then use a format to add the leading zeroes.

> I hope my post is clear, and I thank you for help in advance.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Config Element:Counter based on Thread/User number?

Posted by rxfillpharm <rx...@yahoo.com.INVALID>.
Thank you for reply. 

I created a BeanShell PreProcessor on testplan level that worked well. 
The other suggestion did not work -- the counter is not incremented, ie is always 1.


--------------------------------------------
On Wed, 7/30/14, sebb wrote:

 Subject: Re: Config Element:Counter based on Thread/User number?
 To: "JMeter Users List" <us...@jmeter.apache.org>
 Date: Wednesday, July 30, 2014, 6:58 PM
 
 On 30 July 2014 22:06, rx wrote:
 > Hello,
 > New
 to JMETER , and have a question regarding Config
 Element->Counter.
 >
 > In my thread group, my first element is a
 Counter.  I want to
 > use this counter
 to construct a logon id, where logon ids are
 > user0001, user0002, user0003 etc.  When
 loop count > 1,
 > the logon id will be
 the same for each loop of that user.
 >
 > I expected that Counter would always equal
 __threadNum, such that
 > when
 __threadNum=2, Counter=2 as well.
 >
 > Instead, Counter is being incremented with
 each run of the
 > thread group.
 >
 > As a test, I created
 a user parameter:
 threadrun=${__threadNum}${__counter(true)}
 > The values when I run the test using
 Number of threads=2 and Loop Count=2 are:
 >
 >      Counter =
 0001
 >      threadrun = 11
 >
 >      Counter =
 0002
 >      threadrun = 21
 >
 >      Counter =
 0003  (I want this to be 0001)
 >     
 threadrun = 12  (correct!)
 >
 >      Counter = 0004  (I want this to
 be 0002)
 >      threadrun = 22 
 (correct!)
 >
 > 1. 
 How can I get Counter to match thread number?
 
 Have you tried:
 
 Start = ${__threadNum}
 Increment = 0
 
 > 2. If that is not possible, how can I use
 __threadNum to construct my logon id.
 > 
    __threadNum value is consistently correct, but
 it does not have the leading
 >    zeros
 that I need.
 
 Use one of the
 scripting functions (jexl, javascript, beanshell) or
 scripting test elements to convert the
 threadNum string to a number
 and then use a
 format to add the leading zeroes.
 
 > I hope my post is clear, and I thank you
 for help in advance.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org