I'm having the following scenario:
Thread group
1: http request 1
2: http request 2
3: http request 3
4: http request 4
I'm running this threadgroup with a fixed number of threads in a loop for a specified duration.
Now I'm trying to figure out a way to only execute a certain request each thread loop for a certain percentage.
Let's say I want to have something like 50%: request 1 & 2 and 50%: request 3 & 4.
Also within those 50%'s that I would like to have another dimension like request 1: 75% request :2 25% and request 3: 95% request 4: 5%
i'm not looking to divide the number of threads here (which a troughput controller would do) but to take a specific path each time the threadgroup loops arround.
Is there any controller that can do this out of the box? Or am I better of using an IF controller based on a variable that I up each time (perhaps even the threadloop number which I mod) and then run the correct "scenario" based on that loop number?
Any tips, let me know!
I think you're looking for a Switch Controller
If you
Provide ${__jm__Thread Group__idx} pre-defined variable as the "Switch Value"
Add i.e. Simple Controllers and name it like 0, 1, etc. and put the Samplers you want to execute under the Simple Controllers
This way 1st Thread Group iteration will trigger the children of the Simple Controller with the name 0, 2nd Thread Group iteration will kick off the children of the Simple Controller with the name 1, etc.
Sub-distribution can be established either the same way of using i.e. Throughput Controller. See Running JMeter Samplers with Defined Percentage Probability to learn more about different approaches to distributing JMeter's requests.
Related
I Have 5 HTTP request in single thread, I want to run first request multiple times and then other request only single time
I can't use multiple thread as all request are depends on each other.
Depending on what you're trying to achieve:
Put the request which needs to be run only once under Once Only Controller, this way the Sampler will be executed only during first iteration of the Thread Group
If you want more complex/flexible criteria - put the request which needs to be executed only once under the If Controller, this way you will be able to specify whatever criteria you want. For example if you want to run a Sampler only during 5th iteration use the following condition:
${__jexl3("${__jm__Thread Group__idx}" == "5",)}
this way the sampler(s) which is (are) under the If Controller will be executed only if the condition is met:
Put first request under Loop Controller with Loop Count as the times you want to repeat
JMeter will loop through them a certain number of times, in addition to the loop value you specified for the Thread Group. For example, if you add one HTTP Request to a Loop Controller with a loop count of two, and configure the Thread Group loop count to three, JMeter will send a total of 2 * 3 = 6 HTTP Requests.
Choose request(s) you want to execute multiple times and then:
Right Click -> Insert Parent -> Logic Controller -> Loop Controller
I have a single thread group which has 3 requests and have set the Number of Threads(users) = 2.
I would like all the requests to be executed in sequential order for each user before it repeats these steps for the next user and so on.
Output expected:
HTTP Request 1_Thread 1
HTTP Request 2_Thread 1
HTTP Request 3_Thread 1
HTTP Request 1_Thread 2
HTTP Request 2_Thread 2
HTTP Request 3_Thread 2
However, the output results vary differently for each run and are not in the order I expect. How can this be corrected?
I have tried following but with no luck in achieving my output
1. Enable/disable "Run Thread Groups consecutively
2. Running the test in non-GUI mode
I have attached a screenshot as an image as I am not able to embed into this message yet.
Appreciate if anyone can help me with this query
Thanks
Output Screenshot
For execution of Sampler Request by only Single Thread at a time use Critical Section Controller.
For more info about Critical Section Controller Critical Section Controller
The Critical Section Controller ensures that its children elements (samplers/controllers, etc.) will be executed by only one thread as a named lock will be taken before executing children of controller.
Critical Section Controller takes locks only within one JVM, so if using Distributed testing ensure your use case does not rely on all threads of all JVMs blocking.
Practical Example:
Place all your request under Critical Section Controller
Run the test for any number of Threads you want
Observe the Result in View Results Tree
Note : If you want to run it sequentially from 1 thread to N, make sure you provide Ramp Up Period properly.
Requirement: Load for a total of 100 users within an hour. Each user hits 3 different services different number of times at the same time.
for example: user 1 is going to hit service1- 3 times, service2- 5 times and service3 - 4 times at the same time. Same will be repeated for 100 users over 1 hour.
I have a thread with users-100, rampup time -60 (min). and then I am using parallel plugin and within that plugin created those 3 different sample requests. But I don't know how to configure the number of times, each of those service will be called per user at the same time.
Your test scenario doesn't make sense, normally 1 thread (virtual user) can hit only one endpoint at a time. The use when user executes 3 same requests to the same endpoint looks very suspicious as well. So I would recommend reconsidering your scenario and implement distribution using one of the following approaches:
Use different Thread Groups for different requests
Use Throughput Controller
Use Switch Controller
Use Weighted Switch Controller
If however I'm wrong and you're trying to implement some form of AJAX testing when requests are being triggered at the same time and in parallel - example test plan would be something like:
I have a requirement in JMeter, while executing several recorded HTTP Request (placed inside Transaction Controller) in Thread Group, They should start its execution from one by one ie) Controller 1, Controller 2, ... & Final Controller.
But when I gave 100 threads it start execute, Controller 1 for 100 times then Controller 2 for 100 times and it continues the same till last controller.
From the above shown image you can verify my results. And I need to know, how can I prioritize my controllers when I gave multiple thread counts. My exact output for 100 threads should be like as mentioned below,
1. Controller 1, 2, and till final controller should run as 1st thread count
2. Controller 1, 2, and till final controller should run as 2nd thread count
3. Same like it should continue till the 100th thread count
Please let me know how this requirement is possible in JMeter 4.0
Thanks in advance
This is default JMeter behaviour, JMeter threads (virtual users) are absolutely independent so:
When you start your test with 1 user it starts executing Samplers upside down, one by one
When you start your test with 100 users - all 100 users start executing samplers upside down. And given you have 100 concurrent users it might be the case that first sampler is being executed by multiple users at once.
Normally this is what the majority of people require. If you got the requirement to run all requests by 1st user followed by all request by 2nd user and having 100 users in parallel - suggest the person, who gave you this requirement to quit IT and become a lawnmower as the requirement doesn't make sense and is contradictory.
You can still achieve it using Concurrency Thread Group configured like:
Which will give you what you're looking for:
You can install Concurrency Thread Group using JMeter Plugins Manager.
how jmeter can distribute outbound traffic between the two user groups. For example the group #1 gets 30% of the traffic and the group #2 of 70%.
Not sure I understand your requirement as Oliver did, for me you just setup a Thread Group with 30% of the total threads and the second one with 70%.
Otherwise, you can read this article with is another way to do the way Oliver understood:
http://www.ubik-ingenierie.com/blog/jmeter_control_percentage_of_sampler/
It shows how to distribute but contrary to Throughput Controller it ensures at least one sample is executed.
There are various ways you can do this. You could use a Throughput Controller which is pretty simple, or, if you only ever want one request to fire, you could create a simple Random Variable, set it as a random number between 0 and 10 and then use an If Controller to control execution.
Something like:
Thread Group
- Random Variable 0 - 10
- If Controller set to ${myVar} <= 3
HTTP Sampler
- If Controller set to ${myVar} > 3
HTTP Sampler