For example I set number of threads(users) to 100,
I have 3 requests in ThreadGroup and I want every user to invoke request1 and request2, but only each third user to invoke request3
You can add If Controller with a check for every third thread number:
${__groovy(${__threadNum()} % 3 == 0)}
It depends on what exactly you're trying to achieve, one of the options, most probably the easiest one, is putting your request3 under Throughput Controller and configure the Throughput Controller to run it's children for 30% of virtual users:
More information: Running JMeter Samplers with Defined Percentage Probability
Related
I have multiple Simple Controllers under Thread group. All controllers have 1 HTTP request. Only one controller have 3 requests. How can I chain 3 requests in one simple controller to run sequentially.
Test Plan
The screenshot above is my test plan. In v4/bootstrap call I have 3 HTTP requests. Result of these 3 requests is token which I extract from get_v4/restart and then this token used for all other requests. For correct token generation 3 requests from v4/bootstrap call should run sequently. On summary report shown that amount of run 3 requests is different.
Each JMeter thread (virtual user) executes Samplers upside down. The same applies to Simple Controllers.
So you don't need to do literally anything, each thread will execute samplers sequentially as they appear in the Test Plan.
If you have more than 1 virtual user in the Thread Group you might be confused by the "wrong" order of sample results:
However each user is still executing samplers upside down, you can check it by adding __threadNum() function to show the current virtual user's number and __groovy() function calling vars.getIteration() method
You will see that each user executes samplers sequentially and starts over when the last sampler ends and there are iterations still:
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.
I'm a newcomer to Jmeter and want to be able to run some setup requests once only, in which some variables are setup, before I then run a set of further requests for as many users as I set in the Number of Users Thread Group. These users are passed the variables created in the Once Only Controller.
I've inherited a script as follows, using a Once Only Controller:
If I set the Number of Threads as 10 to ramp up to 10 in one second and run for one minute, I expect the number of Samples (requests) made in the Once Only Controller to show as 1. I only want these requests to run once then subsequent requests to use the setup data.
Why then, when I run, do I see the samples as 10 in the requests that are set in the Once Only Controller:
Bear in mind there may be some fundamental misunderstandings given my I'm a newcomer to Jmeter.
I found the setUp Thread Group Controller which seems to be what I need. However, this does not seem to pass variables extracted using the JSON extractor into the next Thread Group 'Load Test'
Thanks
Use Once Only Controller for running specific samplers for every thread
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread
You can add samplers to setUp Thread Group so it'll be executed once before test
execute before the test proceeds to the executing of regular Thread Groups.
Note keep its default (especially Number of Threads = 1)
As per Once Only Controller documentation:
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.
So each your Thread will execute Once Only Controller's children only once, no matter how many loops your thread group will have.
As you have 10 threads each of 10 threads will execute the requests once.
If you want to execute the request by only one thread, no matter how many requests are in the Thread Group - I would recommend going for If Controller instead
Substitute Once Only Controller with an If Controller
Use the following condition:
${__groovy(ctx.getThreadNum() == 0 && vars.getIteration() == 1,)}
I have a scenario in which I want to hit first request with 3000 users and wait for all the users to come at a point and hit the second request at a same time.
How can this be achievable in jmeter.
JMeter's equivalent of rendezvous point is Synchronizing Timer. Add it as a child of the request you need to execute by all users and use 3000 as the "Number of Simulated Users to Group By"
You could write the first request in its own ThreadGroup wich loops 3000 times, then the 2nd request in an other ThreadGroup.
If you tick the Run Test Group consecutively check-box on the Test Plan configuration screen:
Then what you ask will happen.
You'll have to pass the user states somehow, maybe using variables?
Alternatively you could have a global variable user_setup_count and an absolute rendez_vous_time, to be used like this (for each Thread, in a single ThreadGroup):
Perform request1
Increment user_setup_count - Set rendez_vous_time to now + 20s
while (user_setup_count <3000) { Not everyone is ready yet!
Sleep for 5 sec
Sleep exactly until rendez_vous_time <-- Synchronization is here
Perform request 2
etc.
I am trying to use Stepping Thread Group..but I did nt get how to calculate the http request count.This is my Stepping Thread Group
I got total 3958 result.
If you want to count the number of http requests sended during the test, you can to add the next listeners: aggregate report or summary report. If you want to control the number of executions in the second - use throughput shaping timer.
Also you can use __counter() function to calculate http request count. This function starting with 1 and increasing incrementally by one each time it is called.
You can't predict the exact number of requests for the test that use Stepping Thread Group. The nature of STG is to provide desired test duration time. Thus, the number of requests made during the test will depend on service response times and delay timers you use.
However, you may use counters with If controllers to limit number of requests.