0
votes

I am working on Jmeter load test. I want to maintain the incremented counter value for the next parallel requests [each request defined under throughput controller], however, the counter value resets to 0 again for the subsequent requests.

Here is how my test plan looks like -

+Thread group

+counter (starts from 0 and increments by 1 ; ref name : index)

+Throughput controller [total execution : 1]

  • http request1 - uses index with value 0 in the request which is fine.

+Throughput controller [total execution : 2]

  • http request2 - should use index with value 1 and 2 , however the counter again resets to 0 and uses value 0 and 1 for 2 executions.

+Throughput controller [ total execution : 3]

  • http request3 - should use index with value 3 , 4, 5 ; instead uses value 0,1,2 as counter resets for this as well.

How do i maintain the counter value so that i can run these requests with the desired index values.

Thanks for your help here.

2

2 Answers

0
votes

There is no direct functionality in JMeter Counter to handle your problem. Either you can use Beanshell sampler OR you can handle your scenario through a workaround with Counter as explained below:

Control the number of Throughput controllers execution via variables.

For example create 3 variables:

Controller1_ExecutionTimes: 1
Controller2_ExecutionTimes: 2
Controller3_ExecutionTimes: 3

Now you can use these variables to set starting point of your counters.

  • Set start point of counter1 as 0
  • Set start point of counter2 as ${Controller1_ExecutionTimes}
  • Set start point of counter3 as ${Controller1_ExecutionTimes} + ${Controller2_ExecutionTimes}

and so on.

0
votes

Thanks Arif,

I used the beanshell sampler, extracted the counter value and applied logic to solve my problem.