Jmeter Constant Timer with dynamic parameter - jmeter

I want to use HTTP request with timer.
Thread Group Config
CSV Data Set Config
HTTP Request work without timer. When I add a Constant Timer everything works but Constant Timer doesn't with delay time. I set Thread Delay 5000.
How can I solve this problem?

By default JMeter does NOT include the time, taken by PreProcessors, PostProcessors and Timers into Sample Result so you will not be able to see it anywhere unless you put your request under Transaction Controller and tick both boxes, to wit:
Generate parent sample
Include duration of timer and pre-post processors in generated sample
Once done you should see that your sampler duration should be increased by the amount of time you specify in the Constant Timer

Related

Get the initial expected test duration or end time of a Concurrency Thread Group at the beginning of the script

In Jmeter, I am using Concurrency Thread Group with ${__tstFeedback(ThroughputShapingTimer,1,10,10)} in combination with the Throughput Shaping Timer to dynamically change the target throughput throughout the test duration.
I want to have a JSR223 test element (Assertion or PostProcessor, does it matter?) in which to write custom logic to not log some specific error but only if it occurs near the end of the test script and I don't want to hardcode the time value.
For example if I get a java.net.SocketException in the last 2 minutes of the scheduled run time, I want to not log it, but I do want to log it in the rest of the time.
For this, I suppose that I need some way to grab the date when the test is supposed to end since the beginning of the test, evaluate it and subtract 2 minutes from it and then compare the current time with that time and then if the current time is higher, then start doing some logic to exclude the result from the logging.
Update: In the "Normal" or "Default" Thread Group I noticed that I can do this to get the initial duration:
String groupDuration = ctx.getThreadGroup().getDuration();
log.info(groupDuration)
But for the Concurrency Thread Group it does not work the same.
I would appreciate any information to help me achieve this goal.
If your Concurrency Thread Group is configured with a Throughput Shaping Timer and Schedule Feedback Function the scheduled test duration is available through a property exposed by the Throughput Shaping Timer.
props.get('elementName_totalDuration')
The element will export the following propertyy that you can access through __P function or using in JSR223 Test Elements props.get("property name")
elementName_totalDuration - Total duration as sum of the
"Duration,sec" column
elementName will be the name of your Throughput Shaping Timer
NOTE
You should set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule. Hence set this value to a very high value to avoid test completing before scheduled duration in Throughput Shaping Timer. e.g Set Target Hold rate t0 1440 minutes.
Using concurrency Thread Group with Throughput Shaping Timer and the Feedback Function
When this thread group is used with Throughput Shaping Timer, you may replace Target Concurrency value with a call to the tstFeedback function to dynamically maintain thread count required to achieve target RPS. When using this approach, leave Concurrency Thread Group Ramp Up Time and Ramp-Up Steps Count fields blank, but be sure to set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule.
For dynamic thread groups and derivatives you can use the following function:
ctx.getThreadGroup().getHold()
If you need to determine whether it is in minutes or seconds you can use
ctx.getThreadGroup().getUnitStr()
Example:
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
You can filter results after test with Filter Results Tool
If you want to remove the ramp-up phase, you could use offset filters
Using --end-offset 120 parameter (seconds)

I am not able to get Precise Throughput Timer working

I don't know if I have placed the timer at the correct location. I am not able to get Precise Throughput Timer working.
Any JMeter component needs to be placed according to JMeter Scoping Rules
How do you expect the timer to "work" given you have only one thread and one iteration in the Thread Group especially given your test finishes in 500 milliseconds and you configured the test duration as 500 seconds
If you want to limit your test throughput to 1 request per second for 1 thread and 1 iteration only - I can only think of introducing pacing as none of the existing timers won't be able to do this given that short test duration

Jmeter - How can we calculate think time from response time?

Suppose, I am adding some think time(Timers) in each HTTP request, but when I execute the test, in the report it shows response time as Sum of ThinkTime + actual response time.
How can I get actual response time from the result?
by default, JMeter does not include Timer's time in the response time of any HTTP sampler.
In case if you are using Transaction Controller to group the requests, then you can deselect the checkbox Include duration of timer and pre-post processors in generated sample in the transaction controller.
By default JMeter does not include the duration of:
Timers
PreProcessors
PostProcessors
into Sampler's response time unless you use Transaction Controller with Include duration of timer and pre-post processors in generated sample option selected. If this is the case and you use dynamic values in the Timer - you can consider using Sample Variables functionality to record think time into .jtl results file.
Think Time is the time taken by the user to read,
understand and take next action on the webpage.
So the time between a response and the net request
is the Think Time. This can be simulated by adding
a timer.

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 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