JMeter While-Controller with terminal delay - jmeter

I have a JMeter (5.3) While Controller in a 1-user Thread Group, it reads a CSV and makes http calls for each row. I want all of these to complete as fast as possible (i.e. the loop completes uninterrupted), then the thread-group should pause, then I want the csv-loop to repeat*.
This is proving oddly difficult. Adding a Constant Timer below the While and it's (counter-intuitively) executed before the loop, yet I need it run immediately at start-up then subsequently delay. Similar SO posts advised a Flow Control Action, however the Pause doesn't actually pause for me.
Others suggest adding a Constant Timer child to Flow Control, but it's utterly ignored. In both cases, the csv rows execute repeatedly with no delay at all.
Has anyone got a recipe for this: Process full csv file every few hours?
Simple to say, strangely hard to do.
My setup: The 'CSV Data Config' uses 'Recycle on EOF':True 'Stop thread on EOF':False. Flow Control Action has 'Pause' Duration: 0 with the child timer set to the desired delay.
Thank you.
* please don't ask why, just assume I truly want this.

Flow Control Action, however the Pause doesn't actually pause for me.
This is kind of weird as it does work and introduces the pause when the thread reaches the sampler.
See the below image, with the Flow Control Action sampler disabled JMeter runs requests as fast as it can and when I enable it JMeter runs requests each 2 seconds according to the configured delay
With regards to "counter-intuitively" behaviour:
As per Timers documentation:
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Flow Control Action Sampler.
Timers also obey JMeter Scoping Rules

Related

Please explain objective of Flow Control Action Sampler in 5.0 version

objective of Flow Control Action Sampler in JMeter. what we can achieve with this Sampler during load test?
Flow Control Action sampler is used along with the logical controllers to control the sampler execution.
To pause (sleep) current or all thread for specified amount of time (duration is set in milliseconds). You could use a JMeter variable or property to set a dynamic value
To stop the current or all threads after completing the execution of samples in progress
To stop the current or all threads immediately without waiting for samples in progress to complete. Stop Now option should be selected.
To move to the next iteration
Also you can use Flow Control Action sampler to introduce a Timer in between two samplers. Please see the suggestion from official website.
Sleep for specified amount of time (for example you can implement pacing in JMeter using Flow Control Action Sampler)
Start next iteration of the current loop (for example can be applied for Loop Controller, While Controller, ForEach Controller)
Start next iteration of the Thread Group
Gracefully or immediately stop current thread or all threads (the whole test)

JMeter test action not pausing

I have a JMeter test executing a series of actions that I'd like to pause between.
It's currently set up like this:
Thread Group
+---Transaction controller
+---Sampler executing request
+---Test Action
+---Uniform Random Timer
+---Sampler executing request
+---Test Action
+---Uniform Random Timer
(etc.)
The test actions don't seem to cause any pauses. I have the test actions themselves set to pause the current thread for 0 milliseconds, and the timers to 60 seconds constant pause + up to 30 seconds random pause.
The actual result of running this is that it hops directly from sampler to sampler without pausing at all. What am I missing?
(ETA: This is JMeter 2.13, if that matters.)
Can you confirm that you use time in milliseconds in the Uniform Random Timers, to wit:
Random Delay Maximum: 30000
Constant Delay Offset: 60000
As if you have 30 and 60 correspondingly - the delay happens, but you are not detect it visually. Check "Sampler Start" times in View Results Tree listener to see start times.
Can you double check Transaction Controller configuration? By default timers, pre and post-processors execution time is not being included into report so the delay might happen but you just don't see it. You can include timers duration by checking "Include duration of timer and pre-post processors in generated sample" box
And finally you can also remove Test Action samplers as they're not required. If you put timers as children of "Sampler execute request" the timers will be executed before the requests. See A Comprehensive Guide to Using JMeter Timers guide for more detailed information on timers use cases.

Jmeter execute Logout Action during ramp down

I'm trying to run a scenario that ramps up each thread by logging them in once, loops through an business action for an hour with pacing, and logouts as it ramps down.
Ideally the threads should not log out all at once, as such it I wanted to find a way to execute a logout action for each thread ramping down.
I have tried using stepping and ultimate thread groups, however for ramp down, the threads are being stopped.
In addition, I have tried the following scenario: 1) login, 2)runtime controller scheduled for one hour with the business action, 3) logout. This however, results in premature aborts for the threads that are still executing the business action once it reaches one hour.
Any help, even implementing this in beanshell, would be greatly appreciated.
You can just use a TearDown Threadgroup. That will always be executed once your test is over.
You can use a thread group which sets a jmeter property, let's call the property "isRunning", in a pre or post processor, next that thread has a test action set to pause for the duration of the test. After the pause set the property "isRunning" to false.
When the user logs on in another thread group (your test case) grab the "isRunning" property and store the value in a jmeter variable for the thread. Once the user logs in put your business case in a while loop with the jmeter variable created using the "isRunning" property as the condtion.
Get the value of the "isRunning" property somewhere towards the end of your business case and update your jmeter variable. Put the log out controller outside of the while loop. When the first thread group sets the "isRunning" to false, the while loop in your other threads will finish executing the use case and log out when it sees that the while condition is no longer met.
If you use any type of random think timers and ramp time, the threads should essentially step down on their own, due to ramp time offsetting the start of the use case and random think times.
Not sure if this is the best way to go about this, but I needed to do the same thing you are looking for and this proved to be a feasible workaround.

How to add different time delays between page requests in JMeter?

I've a JMeter Script that does the following:
User registers to the site filling out a form with personal information
Reads through Terms, Condition and agrees to the Agreement
Reads through the instructions and answers practice questions before taking the test (next step)
Takes a timed test of multiple choices for 10 minutes and submits answers.
As you can imagine, they require different delays. Users take 1-2 minutes to fill-out the form. Usually goes really quick through the terms and conditions (less than 30 seconds) and hits 'I Agree' button. Then spends 4-5 minutes in reading the instructions and taking the practice tests (I measured, takes approximately 4-5 minutes) and finally takes the 10 minute timed test.
Now, question is: how do I insert these different time delays between different page requests? I saw some posts that shows how to insert variable time delays to 'ALL' pages. But for me that doesn't help. Please see attached image of what I ideally intend to do.
Can anyone please help? Thanks in advance!
--Ishti
I think I got the answer. It's actually in the Manual itself at:
http://jmeter.apache.org/usermanual/component_reference.html#timers
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Test Action Sampler.

jMeter timers - loop delays

I have the following scenario to emulate in jMeter:
100 users logging in once and doing search every 30 secs, with think time 5 secs.
How do I implement this?
Right now I have something like this:
ThreadGroup(100usrs)
+-- OnceOnlyController(LogIn)
+-- LoopControler(Search)
+-- Timer(5s)
But I have no idea how to do the 30 secs delay between the Search instances.
Is it even possible or do I have to use some workaround?
Any help appreciated.
I think you have to add another timer as a child of LoopController: Timer(30). Your search requests are under the scope of that controller and your 30s timer should be there too.
http://jmeter.apache.org/usermanual/component_reference.html#timers
If you want to have a fixed delay between the search samples whatever response time of the Sample is then Orkito solution is not the right one.
His solution will add a 30 s delay before the search sample, so if search takes more time than expected your request will run each 30s + Time taken by search sample.
If you want to have a fixed delay between the search samples whatever response time of the Sample then solution is described here:
http://blog.milamberspace.net/index.php/2008/08/15/jmeter-fixer-la-duree-de-repetition-dune-requete-87.html
It's in french but there are screenshots and translation service should do the job.
Another important point to note:
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Test Action Sampler.
Instead of use Constant Timer you should use Constant Throughput Timer, because this timer considers also Sample time(that is the execution time of each sample).
If you use a Constant Timer, you will have delay piled from each sample execution

Resources