jmeter: How to repeat two thread groups in test plan? - jmeter

I have two thread groups:
setUp Thread Group - executed only once
Thread Group - executed for number of users defined in CSV file.
The first thread group prepares data once, which will be used by all users in the second thread group.
After finish of the second thread group, I want to repeat the whole process again. This seems not possible, since there is no Forever check box for the test plan itself? Using jmeter 2.9

This is not possible using this way.
You would need to find some hack to do the same thing.
It could be something like:
While controller that tests a stop condition And has 2 If Controller children
- if controller (tests if first thread and does the setup job, when done sets while controller condition to false
- if controller ( tests if other threads and if not wait 10s)
While controller that contains test code

Related

JMeter - Control the Iteration count with in a Thread Group which has Multi Actions

No.Of Iterations in a thread Group is : 3
Thread Group Name from the below screenshot is : TCByEmployee
Thread Group performs various steps using If Controller
I want to Achieve "Loop Controller-TCbyEmployee-Login by Employees"
& "If Controller-TCbyEmployee-Login by DH" should start Next Iterations once it's completes "If Controller--TCbyEmployee-Login by PA" Iteration 1
Now the issue is : "Loop Controller-TCbyEmployee-Login by Employees"
& "If Controller-TCbyEmployee-Login by DH" continues the up to Iteration 3 before "If Controller--TCbyEmployee-Login by PA" begins
Please see the below screenshots
Your question in its current form doesn't make any sense, you need to either re-phrase it or provide minimal reproducible example
So far I can only inform you that:
Once started each JMeter thread (virtual user) starts executing Samplers upside down (or according to the Logic Controllers)
When thread executes last Sampler in the Thread Group it starts over from the beginning
If there are no more Samplers to execute or loops to iterate the Thread is being shut down.
If you're looking for a way to implement a GOTO statement - take a look at Test Fragments and Module Controller, this way you can change the flow from upside down to some custom
Also be aware that threads (virtual users) are absolutely independent and if you think that the execution order is broken might mean that another user executed another sampler at that moment
And last but not the least, don't run your test in GUI mode

Finish and start with other Threadgroup

I'm using Jmeter to test multiple microservice.
The basic idea is to test a circuit breaker in a microservice environment.
Right now, I'm using two threadgroups, a master and slave remote concept.
One thread group creates uses 100 iterations and 1000 thread and creates
load against a front-end service, which sends request to a backend service.
The other group probes the backend service with 100 iterations but 1 thread.
If I’m not wrong the second threadgroup finishes way more early than the first one.
Is it somehow possible to sync those two?
And maybe another question.
As I scale the threads with the remotes, also the second thread group scales, is it possible to force the second threadgroup to use only one slave?
In order to execute "probe" thread group until "main" thread group is executing put the "probe" request under the While Controller and use the following __groovy() function as the condition:
${__groovy(org.apache.jmeter.threads.JMeterContextService.getThreadCounts().activeThreads > 1,)}
If you want to execute the "probe" thread group only on one machine of the JMeter cluster - put the whole construction under the If Controller and use the following jexl3() function as the condition:
${__jexl3("${__machineIP()}" == "IP address of the slave",)}
The whole Thread Group should look like:

Starting second controller after first controller has finished its task in a single thread group

I have a structure where in I have multiple controllers in a thread group. Second controller is depended on first. Controller 1 and 2 csv file will have multiple records.
I have divided the tasks in multiple user threads.
As of now, I am enabling first then executing the tasks. Then once the first is done, I am disabling that and enabling teh second one and starting.
Is there a way where we can say that the second will only run once first has completed the operation?? Does Jmeter allow this type of execution ?
JMeter executes test elements upside down so you don't have to do anything
If you want all virtual users to execute Controller 1 and only then start executing Controller 2 add Synchronizing Timer as a child of the last Sampler of the Controller 1 and set Number of Simultaneous Users to Group by to be equal to the number of Threads in your Thread Group

How to enforce run Once Only Controller in Jmeter

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,)}

JMeter Include controller

First script
Thread-1
|--Http Sampler
|--Include Controller <second script>
Second script
TestPlan
|--Thread-2
| |--Http Sampler
|--Thread-3
|--Http Sampler
I run the first script which does few steps and uses include controller to call the next script. I need the second script Thread groups (Thread-2 and Thread-3) run simultaneously and not consecutively.
I understand the thread run concurrently by default. But when I execute my code i see:
Thread-1 successful
Thread-2 successful
Execution never gets to thread-3
Can you please help me? I want to know how to run the second script's thread group simultaneously?
You are misusing IncludeController, you need to use Test Fragment element in the included test plan (second script)
First and second script are separate test plans.
First Test Plan contains one thread, which contains a include controller to call the second script or the second Test plan
Second test plan contains 2 thread groups
Solution:
In both the Test Plan untick "Run threads consecutively"
In the second test plan tick "Delayed thread creation" - this means that the memory requirements are proportional to the number of concurrent active threads, rather than the total thread count
Threads in JMeter run simultaneously by default.
Understand the difference between concurrency and simultaneous. Here is a helpful link: How to generate Concurrent User load in Jmeter

Resources