Jmeter :- Running a bundle of samplers sequentially within concurrent threads - performance

I have a single Thread Group with 2 samplers. Lets say Sampler A and Sampler B.
Sampler B is dependent on response of Sampler A.Thus these 2 samplers always have to run sequentially , First - Sample A and then Sample B.
Now my requirement is run this thread group for multiple users concurrently.
When I execute this for one user , it runs fine. However when I run for more than one user , the samplers are not executed sequentially within individual thread group thereby causing Sampler B to fail most of the times.
I need an advice on how can I achieve this.
I tried using Syncronisation Timer , Transaction Controller to bundle the Samplers but it dint work

Found a solution - Used Critical Controller to bundle up the Samplers together. Hereby the link which provides an example - https://jmeter.apache.org/usermanual/component_reference.html#Critical_Section_Controller

You can achieve desired results by using the controllers in your test plan. You can use If Controller for this.
https://jmeter.apache.org/usermanual/component_reference.html#Simple_Controller

Critical section controller still doesn't fulfill this requirement.
It will still run the threads sequentially in the below order(thread 1, 2 and 3 are executed sequentially) due to name lock on sampler A and sampler B defined within the critical section controller. But the requirement is to run all threads(1, 2 and 3) in parallel, but sampler A and sampler B should execute sequentially for each thread.
Critical section controller behavior:
thread 1 - (sampler A then sampler B),
thread 2 - (sampler A then sampler B),
thread 3 - (sampler A then sampler B),

Related

running 2 samplers consecutively like a bundle in Jmeter

I am trying to ensure that 2 samplers(A&B) in a thread are always ran consecutively like a bundle.
The thread group I wanted to do is:
where the controller makes sampler A&B a bundle and always runs them sequentially/consecutively, and where sampler C,D,E are other samplers in thread group 1.
and the desired results in chronological order should be similar to this:
in a way that no matter in what order the rest of the samplers are ran, B is always ran right after A is ran.
I have tried several controllers:
critical section controller would allow me to run B right after A everytime, however it seems that it cannot work with multiple threads and only works when I give enough ramp up time, and I don't find enough information that makes enough sense on this controller (please correct me if you have a better understanding of critical section controller)
loop controller would run B right after A only if I give enough ramp up time
interleave controller would run B right after A only if the only controller in the thread group
I have also read multiple posts on stackoverflow on this creating a bundle matter, however couldn't find a solution to it.
The samplers in a thread are executed in the order they appear in the tree.
I'm not sure if you want C, D and E to execute randomly in the same thread. If they are independent from A&B you can move them to other threadgroups.
Execution order
If you want to exclude all samples from other threads between A and B, you could try setting a property before A, and resetting it after B.
Also A and B should be in a Critical Section controller.
With an if controller you could check if the property is set, to exclude other samples between A and B.
With only one ThreadGroup I think something like this should work:
TG
Critical Section
sampler A
preprocessor Set X=1
sampler B
postprocessor Set X=0
if X!=1
sampler C
if X!=1
sampler D

How i can be sure that JMeter is not using the same sample more than one time at same time?

I'm using JMeter to test my applications, and I desire to use the same sample N times.
For example, lets say I have 100 different samples how I'll use to test my Login, and want to use these samples 10 times.
I'm using 100 threads, and 10 loops for that.
How I can be sure that the second loop using a sample will start just after that the first loop of that sample has finished (and not have the same sample running simultanious)?
I'm having some troubles to understand how JMeter lead to this scenario.
JMeter acts as follows:
Each thread (virtual users) executes Samplers upside down (or according to the Logic Controllers)
When there are no more Samplers to execute:
-if there is > 1 loop in the Thread Group - the thread starts executing Samplers once again
if there are no more loops to iterate - the thread is being shut down
You can track which thread is executing which sampler by adding __threadNum() function to the sampler name. The Thread Group iteration can be tracked by adding the special JMeter Variable ${__jm__Thread Group__idx}
If you don't want user 1 and user 2 to execute sampler1 at the same time - put this sampler under the Critical Section Controller, but in this case you will not have any concurrency.

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.

Running sampler of jmeter in isolation

Suppose my threads are 30 and iteration count is 1 and I have samplers such as:
sampler1
sampler2
sampler3
....
sampler10
Whenever I run the test plan with corresponding ramp up period some of my samplers are being executed concurrently I meant user 1 is executing sampler1 and also user 20 is executing same sampler which is absolutely fine but I want sampler3 to be executed in isolation i.e. when that sampler is being executed by someone no other user should try to access it.
Is there any way?
I am using Jmeter.
Thanks in advance
As per Using the HTTP Cookie Manager guide you can put your Sampler 3 under Once Only Controller
From 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.

How to configure jmeter to run sampler tests through percentage of threads not all of them

I would like to run multiple samplers with different frequencies. For example in a test plan I have two samplers A and B and I want to 80% of threads run sampler A and 20% of threads run sampler B. How can I configure this situation instead of running all thread on all samplers?
The quick and dirty way would be to use an Interleave Controller and add Sampler A 4 times and Sampler B 1 time. But, that is very, very dirty.
A better way would be to use the Switch Controller. Then you can execute Sampler A or B depending on a variable you can set and change on a test and thread basis. (Initialise per test and change per thread.)
The variable you need can be found under the Config Elements and is named Counter.

Resources