Dependency among multiple thread groups in JMeter - jmeter

I have set up a load test plan with multiple thread group, i.e. -
Registration (50% of the threads)
Place Order (10% of the threads)
Some more operations (remaining threads)
Herein if Registration thread does not succeeds than I don't want to execute remaining thread groups. In case of a single thread group I can use if controller and discard samples if one sample fails but how do I achieve it when I am using multiple thread groups.

JMeter Variables scope is limited to current Thread Group only, if you want to use If Controller basing on the condition which is set in another Thread Group - you should be using JMeter Properties instead (JMeter Properties scope is global for the whole JVM). See How to Use Variables in Different Thread Groups article for details on converting JMeter Variables into JMeter Properties.
You may also find InterThread Communication plugins useful when it comes to passing data between thread groups and setting up dependencies.
However, given your scenario you either need to pass the whole thread context (cookies, cache, whatever) which might be tricky so it would be much better putting all the samplers under the same Thread Group and use Throughput Controller, Switch Controller or Weighted Switch Controller, whatever matches your scenario the closest way. See Running JMeter Samplers with Defined Percentage Probability guide for more information.

Related

JMETER Test plan with multiple thread groups

Can a jmeter test plan(JMX) with multiple thread groups have same name for all the thread groups and samplers inside??
What's the downside if we use this way
Yes, different thread groups with the same name may exist in a JMeter test plan. There is no technological barrier stopping this. When evaluating the test plan or examining the test results, it could become more challenging to recognize and differentiate distinct thread groups if there are several ones with the same name. Additionally, it can be more perplexing for other individuals who might be utilizing the test plan.
The test plan can be made more logically and simply by using distinct names for thread groups and samplers. Additional information, like as descriptions or comments, may be beneficial in order to provide more context and make the purpose of each thread group and sampler more clear.
There are no limitations when it comes to naming Thread Groups or Samplers, you can use the same label everywhere.
If needed you can trace down the problematic or failed SampleResult to this or that Sampler by looking at threadName column of the .jtl results file.
The only potentially dangerous limitation I can think of is properly naming Transaction Controller's children as if it will differ from the transaction Controler's name followed by dash followed by zero-based index of the Sampler - JMeter will fail to properly calculate the throughput and you will be seeing extra sample results in i.e. HTML Reporting Dashboard

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

Running Jmeter Test in multiple accounts parallelly

I have set of sampler under one Thread Group as
TestPlan
ThreadGroup
SimpleController
Login(HTTP Sampler)
FetchCSRFToken(HTTP Sampler)
LoopController(Count -> 5)
Testcase1(HTTP Sampler)
Testcase2(HTTP Sampler)
Testcase3(HTTP Sampler)
Now I got a requirement to run the above test cases in multiple accounts parallelly.
I googled and find out having Multiple Thread Group is a better idea since I suppose to run it parallelly and I have to pass CSRF token in all test cases header.
Is it possible to have two thread groups without duplicating the test cases inside Loop Controller of Thread Group-1 to Thread Group-2?
Kindly suggest if any other way as well.
If you want to avoid code duplication - just put the "shared" code under a Test Fragment and reference it using Module Controller(s) where required
In general a Thread Group should represent a logical/business group of users, if you just need to add more users doing the same actions - you can parameterize credentials, URLs, parameters, etc. so each thread will use different set of data on each iteration, the most commonly used approach for parameterization is CSV Data Set Config

How to get Sample count per thread in Jmeter5.1

Need to count samples generated in thread level. I am using 8 thread groups and each thread group contains multiple transaction controller and each transaction controller contains multiple requests. Problem is here that I am able to get the samples to count for each transaction controller but not for thread level.
I am using 8 ultimate thread group in my test plan for load test executing for 1hr.
You could consider adding __threadNum() function somewhere to your Sampler's name
The function will be evaluated in the runtime and resolved into current thread (virtual user) number.
This way you will be able to see how many Samplers did this or that thread execute in a listener of your choice, i.e. in Aggregate Report
Check out Apache JMeter Functions - An Introduction article for more information on JMeter Functions concept.

JMeter Thread Communication Pre and Post Process delay

My Test Plan have 3 Scenarios,
Submit Quote
Check Status
If Status Complete get Quote Details.
If I keep all these 3 scenarios in one thread then CTT is not putting constant throughput, when I remove create 2 thread 1 for Submit and other for Status and Get Details I am able to maintain CTT, but my 2nd and 3rd Scenario volume drops almost 50%. As I have dependency on 1st step I am using Thread communication and not sure how I can either get CTT in one thread or get same volume from 2 different threads.
Constant Throughput Timer is useful to shape the load where there is > 1 test iteration. If your thread group has only one iteration consider using Throughput Shaping Timer instead or play with ramp-up and thread number values. It is recommended to have only one instance of the CTT in your Test Plan as it's rather resource consuming by nature.
If your scenario assumes different throughput for different thread groups you can add a CTT per Thread Group (make sure that you select All active threads in current thread group (shared) in "Calculate Throughput based on" dropdown
If ITC test elements are throttling your test below desired throughput value consider using
__setProperty()
__property()
__threadNum()
functions to implement inter-thread communication instead. JMeter Properties are global, can be accessed from different thread groups and persist all the time while JMeter is running.
See How to use JMeter's Throughput Constant Timer for details.
If above information is not enough try to elaborate your query and include i.e. thread numbers, target throughput and what kind of information needs to be shared across thread groups.

Resources