Finish and start with other Threadgroup - jmeter

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:

Related

How do I maintain sessions between Thread Groups in JMeter

I have 5 thread groups (Ultimate Thread Group) in JMeter. When I run the entire test, the samples in the first thread group work fine, those in the second thread group invoke the web sites timeout page, but when the same samples (in the second thread group) are put in the first thread group and the test run, they work fine and do not invoke the timeout page. I realise that I need to pass the session from the first thread group to the other thread groups, please how do I do this?
The following is the cookie data:-
The following are the thread groups:-
If you need to pass data between different Thread Groups most probably your test is badly designed.
Each JMeter thread (virtual user) must represent a real user with all its stuff (Cookies, Cache, Headers, think times, etc). If these 5 business actions are a part of a single used workflow - they need to be put under the same thread group.
Use different thread groups to represent different groups of business users.
If you really need to pass cookies between thread groups it can be done using JSR223 Scripting or Inter-Thread Communication Plugin

Custom JMeter number of iterations per request

Suppose that there's a request set, composed of requests A and B, used as a set up for a business case and there is the request that should be measured C.
Is there a way to tell JMeter to run A and B requests only once, and C as many times as defined by Thread group or Ultimate group?
To run once either put A,B in setUp Thread Group
A special type of ThreadGroup that can be utilized to perform Pre-Test Actions. The behavior of these threads is exactly like a normal Thread Group element. The difference is that these type of threads execute before the test proceeds to the executing of regular Thread Groups.
Or under Once Only Logic Controller
process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.

JMeter handle "test-completed" event

I calculate some statistics (e.g. average request duration) while my tests are running using code similar to this:
https://stackoverflow.com/a/27446405/2173353
However, I want to know when the test is done running (all the samplers have executed), so that I act upon the statistics then, and not before that. Essentially, I want to assert on the average duration of the requests when all requests are done.
Is there a way to execute code when the test is about to finish?
You must probably be looking for the tearDown Thread Group. It is some form of "special" thread group, the difference from "normal" Thread Groups is that the tearDown Thread Group is being executed after all other Thread Groups therefore you will be able to perform your "near the end" actions there.
More information: How to Use the SetUp Thread Group in JMeter When Preparing a Load Test

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: How to repeat two thread groups in test plan?

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

Resources