Running Jmeter Test in multiple accounts parallelly - jmeter

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

Related

Jmeter - How to pass multiple tokens from http login request to another http request

I am currently designing a test case for multiple users testing using jmeter and I kind of need some help.
Here's the scenario:
Suppose I have 2 different login portals with 500 different users on each portal. I want to do login, access getExamSchedule, startExam, getListQuestion, getOneQuestion, submitOneQuestion and finishExam so I create one new thread group for each request. Each thread has 2 samplers (1 for portal A, 2 for portal B).
My question is how am I supposed to pass the multiple generated tokens from login thread so that I can access the rest of the thread with different tokens. And also each http request has some response I need to extract to be used on another thread. I tried to extract the tokens and the responses to csv file but somehow it didn't work. Let me know if there's any best practice for this scenario. Thank you in advance!
so I create one new thread group for each request - normally you should create separate/different Thread Groups only for new logical groups of virtual users, for your use case I think everything could be in one Thread Group.
As per JMeter Documentation:
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.
So if you really need to pass values across different Thread Groups - you can take a look at following solutions:
__setProperty(), __threadNum() and __P() functions combination like:
To set the property:
${__setProperty(token_${__threadNum},${jmeter-variable-holding-the-token},)}
To read the property: ${__P(token_${__threadNum},)}
Use Inter-Thread Communication Plugin

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

JMeter how to load certain group of users

I am loading a csv file with usernames and passwords of users.
Each user belongs to a certain group eg. Group1_user1, Group1_user2,.... Group7_user1, Group7_user2 etc.
I have recorded with my Script Recorder in JMeter the HTTP requests for log in of all the users and then the steps of a HTML stepper process.
Only one group has the permission to complete a step.. there is an hierachy in the groups.
So, my question is.. since I am loading all the users, how am I going to test each step for the users who belong only to the right group?
I cant use plug-in and I cant break my Test Plan into smaller Test Plans.
Normally you should be using different Thread Groups for representing different groups of logical users, so I would suggest moving at least those guys who have permission to complete a step into a separate thread group.
You can implement synchronization and passing data between thread groups if needed using Inter-Thread Communication Plugin
If you have to stay with the single Thread Group you can use If Controller or Switch Controller to conditionally decide which step can be taken by which user.
For example if you use the following __jexl3() function as the If Controller's condition:
${__jexl3("${username}".contains("Group1"),)}
then If Controllers child(ren) will be executed only if ${username} variable will contain Group1
Demo:

Dependency among multiple thread groups in 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.

Test concurrent users with different browsing patterns

So using Jmeter today and whilst I know i can load test a website with concurrent users using threads, loops etc I was wondering if it is possible to setup a test where say 50 users access the website and then each of them browse the site in a different way?
Has anyone done this before or would jmeter not be the tool to use?
Looking for some suggestions or an idea how to do it in Jmeter.
Suppose you have at least the following simple possibility:Random Order Controller.
Implement set of navigation/browsing steps via separate samplers or group of samplers (grouped via e.g. Simple Controller or Transaction Controller - if some steps should be always executed in defined sequence).
This will be "pool" of navigation steps.
Adding all these steps as child samplers to the Random Order Controller let you have different, per user, randomly generated sequence of navigation steps.
In this case you possible have to put your login/logout samplers (if any) out from Random Order Controller. As well you can e.g. use both scenarios with and without login/logout, etc.
Thread Group
...
Login Sampler
Random Order Controller
Sampler A
Sampler B
...
Sampler X
Logout Sampler
...
As well you can also additionally look onto
Random Controller
Switch Controller: e.g. define in csv-file per-user navigation scenarios, read these scenarios during script execution and assign extracted actions to each thread;
Include Controller.

Resources