1

I have below test plan in my jmeter

|Test Plan
|-Thread Group
|--HTTP Request 1
|--HTTP Request 2
|--HTTP Request 3

In Thread Group I have setted:

  • Number of Threads - 5
  • Ramp-Up Period (in seconds) - 0
  • Loop Count -1

When I run my test Jmeter executes each request five times. I'm looking for way how to execute each sampler only once in whole test run, I know I can achive it by setting Number of Threads to 1, but in that case execution of test will be very slow, so I would like to do this in parallel way.

Any ideas how can I do it ? I know I can't use Only Once Controller because each request is also executed by each thread.

Kamil W
  • 2,230
  • 2
  • 21
  • 43

4 Answers4

1

Another option is use Throughput Controller as the parent of each request

Throughput Controller allows the user to control how often it is executed.

Choose Total executions with Throughput value 1

Total executions causes the controller to stop executing after a certain number of executions have occurred.

It will execute only once each request as you needed

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
0

You don't need more than 1 thread, you can add JMeter plugin bzm - Parallel Controller

Add it as the parent of the three request and it will execute it in parallel

Community
  • 1
  • 1
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • @DimtriT Why downvoting ? it's a working solution for parallel requests – Ori Marko Sep 03 '18 at 13:16
  • Yes, your answer was helpful. But I will wait a little bit more time, maybe someone will provide solution as I described in https://stackoverflow.com/questions/52149578/jmeter-execute-sampler-once-per-test?noredirect=1#comment91252395_52150188 – Kamil W Sep 04 '18 at 07:44
  • @KamilW. see https://stackoverflow.com/questions/52149578/jmeter-execute-sampler-once-per-test/52161333#52161333 – Ori Marko Sep 04 '18 at 07:48
0
  1. Put your requests under the Switch Controller
  2. Use ${__threadNum} function as the "Switch Value"

Scenario outline:

JMeter Switch Controller

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • As I checked in this approach number of threads must match number of requests. In case when I will have a lot of requests my pc can be overloaded. It could be wonderful if we find a solution where we have e.g 5 threads and when one thread finish one request it moves to another request, until all request will be finished. Any ideas ? :) – Kamil W Sep 03 '18 at 13:56
  • Not necessarily, the number of threads can be lower, in this case some requests will be executed sequentially – Dmitri T Sep 03 '18 at 14:12
0

Take a look at the Once Only Controller this controller runs once per testrun. "The Once Only Controller will now execute always during the first iteration of any looping parent controller"

Janp95
  • 534
  • 8
  • 27
  • I put my requests under Once Only Controller which is under Loop Controller and unfortonetly each request is executed once per each declared thread. – Kamil W Sep 04 '18 at 06:48
  • Try a simple if controller with the statement "${__threadNum}" == "1" put your requests under it. – Janp95 Sep 04 '18 at 08:58