Different between Critical Section Controller and Simple Controller in JMeter - jmeter

Could you tell me the different between Critical Section Controller and Simple Controller in JMeter?
I don't understand about them clearly.
I created example but their results are same.

Simple Controller does nothing but group the samplers below it
lets you organize your Samplers and other Logic Controllers. Unlike other Logic Controllers, this controller provides no functionality beyond that of a storage device
While Critical Section Controller used to block threads executing in parallel
ensures that its children elements (samplers/controllers, etc.) will be executed by only one thread as a named lock will be taken before executing children of controller.
Note that it doesn't work on distributed testing
Critical Section Controller takes locks only within one JVM, so if using Distributed testing ensure your use case does not rely on all threads of all JVMs blocking.
If you work with one thread you won't notice the difference between controllers

Simple Controller is just a container, you can put Samplers as a child of it. It doesn't do anything at all, the only valid use case is using it in combination with Test Fragment and Module Controller when you want to avoid code duplication
Critical Section Controller ensures that its children are executed by only one thread at a time, it can be used a a global lock to avoid race conditions (for example concurrent writing to the same file by several threads or something like this)

Related

How to execute multiple parallel controllers simultaneously?

I am having 2 parallel controllers in my thread group, in both parallel controllers I have added 1 simple controller in which there are 10 API requests. When I execute the script with 2 threads and 2 sec ramp up time to check the start time of the thread groups then I observe that script completes 1 thread's parallel controller first then 2nd thread's parallel controller.
Scenario - To scan the barcodes from csv file.
Expected Result: Expected_Result_table_ss
and in the meanwhile when Parallel 2 is processing the barcode, the first controller should also pick the next barcode to scan. For ex when the 2nd parallel controller is scanning 110121 at 12:00:01:190 at the same second or after some milliseconds parallel controller 1 should pick next barcode 110123 to scan.
Actual Result: ActualResult_TABLE_ss
Jmeter Script Flow : Jmeter_Script_Flow_ss
I may be wrong but I think this execution will be more precise if I am able to execute these parallel controllers simultaneously. Please let me know if any other logic can be applied for the same to scan the barcodes simultaneously using script
Parallel Controller executes its direct children in parallel, your "Jmeter Script Flow" means sequential execution of all "API requests" by each thread (virtual user)
I don't think you understand the concept and use case for the Parallel Controller, it was implemented as a JMeter Plugin to overcome JMeter limitation of not being possible to kick off extra threads within the bounds of one virtual user making simulating AJAX calls quite hard. If scanning the barcode really produces 10 requests at exactly the same moment then your setup is good and you just need to move the "API requests" out of the "Simple Controller" so they would be direct children of the
JMeter threads are absolutely independent and know nothing about each other unless you use Inter-Thread Communication Plugin so each virtual user will be executing Samplers upside down as fast as it can
If you want to execute both scenarios at the same time with 2 users - take a look at Synchronizing Timer

JMeter - When not to use Once Only controller

Once Only controller component finish with a strange warning:
Once Only controller under anything other than the Thread Group or a Loop Controller is not currently defined. Odd things may happen.
I check and it works in setup/tearDown Thread Group and other Controllers and it works fine and in other components (as Pre/Post processor/Config...) it can't be added.
What is the use case for this disturbing warning?
OnceOnlyController reacts to its parent loop and runs only if it's the first iteration.
It expects its parent to be a LoopController or a Thread Group which contains a Loop Controller but it now handles also other elements.
There used to be a bug which has been fixed:
https://bz.apache.org/bugzilla/show_bug.cgi?id=39509
I suspect the comment is now outdated, but if you can test more and possibly provide some Test plan testing all combinations it would help the project strengthen this part.
Note removed by:
http://svn.apache.org/viewvc?view=revision&revision=1813138

How can i execute several scenarios simultaneously without using several thread groups

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

Call function in user parameter definition

I'm running a set of thread groups (consecutively) and I need to reset a number of parameters at the start of each thread group so that they have a unique value.
Presently I'm referencing a User Paramaters node using a test fragment, and setting the value to value-${__time()}. Unfortunately, this results in the value being used verbatim (without resolving the time).
Is there a better way to achieve per-thread group variables that include function calls?
Works fine for me (Jmeter 2.5.1), as per below example.
Sample params set to ${__time(HMS,)} and value-${__time()} successfully resolved, generated and updated (once per iteration) for each thread (in this case:3 Thread Groups, 5 threads # 3 loops).
Can you please answer why are you using User Parameters via Test Fragment (as per your post)?
...And several articles, just fyi:
Parametrization in JMeter with user parameter
JMeter Variables vs. Properties. vs. Parameters
UPDATED:
Please find below results for example with both User Params and test logic put into Test Fragment and called from Module Controllers.
Works the same way as in sample above: successfully resolved, preserved between samplers in separate loop and updated (once per iteration) between loops for each thread (well, I 've commented in screen the rest of thread groups to get output for the first only; works fine with all TGs enabled too).
I think you could also try to put User Params config from Test Fragment to each thread group and leave in Test Fragment only test logic - if the above schema will still not work for you:
It's not very nice but both the Module Controller and Include Controller are still quite "buggy" and sometimes unpredictable.
You could also try to debug problem controllers in your scenario: select controller > click Help in jmeter's main menu > click Enable Debug > look into jmeter.log for details after execution.
You could also look onto custom Parameterized Controller - maybe it will work better.

Interleave controller Issue - JMeter

I am trying to simulate a sequential call to couple of webservices by putting them under Interleave controller. Although I have unchecked "ignore sub-controller blocks", jmeter still runs only one of the controllers living under interleave controller and alternates it for each iteration. What I need is a sequential call to all .
Any help is appreciated. Cheers
The Interleave Controller is running as it should do. It will alternate through one web service for each iteration
If you want a Sequential call to both web services on each request, then just put them directly under the Thread Group - without any logic controller or keep a Simple Controller
Unless I'm misunderstanding your question, why do you need the Interleave Controller?
Jose
Thanks for the answer. Keeping them directly under thread group did not call them sequentially. You can try it. I currently have about 10 webservices (let us call them 1..10) some are heavy and some are light there by resulting in different response times. However, I would like to run these in order that is from 1 to 10.
Directly placing them under thread group did not call them sequentially, so I used interleave controller with "ignore sub-controller blocks" unchecked.

Resources