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
Related
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.
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),
I have created seven thread groups which execute different scenarios in one application. I'm trying to optimize my scripts in order to be more maintainable and easy to master when someone else uses them.
The thing that i cannot figure out is how can i combine those thread groups into one or two and to still have the seven different execution paths and the possibility to control them, by control i mean to set how many users to execute scenario 1, how many to execute scenario 2 etc. till 7.
Currently the test plan looks like this
If you don't want several thread groups for some reason the alternative options are in:
Throughput Controller - with different global executions or execution percentages
Switch Controller - which provides random weighted values (in some cases Throughput Controller doesn't guarantee that samplers in scope will ever be executed)
See Running JMeter Samplers with Defined Percentage Probability guide for more information on configuration and implementation.
Well i just figured out how to do that i have added a Loop controller a Random Order Controller as child of the loop controller. And i have put seven throughput controllers as child of the Random Order Controller so now everything looks fine
I am new to JMeter and it maybe a stupid question but I still find it hard to understand the concept here.
I have a simple test.
Thread Group with a Single thread with loop count of 2
PreProcessor that place two
variables on the vars map
A loop that execute a request twice based
on the PreProcessor parameters
I expected that the preprocessor will initialize the parameter and it will use the same values twice in the request.
It looks like it’s executing the PreProcessor once pair call.
When I switch the PreProcessor with similar User Defined Variables it reuses the same value on every call.
Can anyone explain the logic here?
I am using JMeter 2.11
A PreProcessor is executed each time the HTTP Request is executed so if you have a total of 2 iterations, you should see log twice, you have it 4 times so maybe number of iteration is different than what your write or you have 2 threads.
When you use User Defined Variables, the value is computed once and then reused. Value will be different per thread.
After reading the documentations and with #UBIK LOAD PACK help I used User Variables and it worked
User Variables - are specific to individual threads.
Pre-Processor is attached to a Sampler element (e.g. http request in our case), then it will execute just prior to that sampler element running
So 4 request for different parameters because it runs before every request
User Defined Variables - It is processed at the start of a test, no matter where it is placed. For simplicity, it is suggested that the element is placed only at the start of a Thread Group. This is why I get the same value all the time
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.