JMeter - execute requests according to given millisecond offset - jmeter

For a JMeter load test, I'd like to replay what we call a 'playbook', which has a form similar to this:
offset ms | request
--------------------------
0 | http://localhost/request1
7 | http://localhost/request2
12 | http://localhost/request3
25 | http://localhost/request4
... | ...
Where '0' is the start time of the test, and each request should be fired exactly x milliseconds after that, as given in the first column, irrespective of how long the single requests take.
What I want to avoid is the regular way JMeter works, where each thread basically fires one request after the other.
Background: We already have a tool which creates this sort of playbook, and it is a very realistic way of simulating user behavior. We are now evaluating if we can use JMeter to execute them.

In JMeter this is similar to Think time,
You can add after each request similar to Think time a Test Action after each request and under it a Timer as a Uniform Random Timer with Random = 0 and in your case:
After first request 7000 Constant Delay Offset
After second request 5000 Constant Delay Offset
After third request 13000 Constant Delay Offset

Related

Dynamic Request per minute in Jmeter

When we have a constant request per minute we can use timer to control throughput, but let's assume we have a CSV containing a number of requests every minute (dynamic throughput per minute) like:
| timestamp | Num. Of. Request|
| ..01:01:00| 9 |
| ..01:02:00| 3 |
| ..01:03:00| 23|
| ..01:04:00| 5 |
I tried to use constant throughput timer with beanshell but with handy input value not from csv.
Is there any good way to simulate this in Jmeter?
First of all are you aware of Throughput Shaping Timer in general and load_profile special property in particular?
If you want to continue with your "CSV" approach here is how it could be implemented: you can read the file in Groovy in separate Thread Group and overwrite the property value
"Handy" shorthands:
new File('path-to-your-file.csv').readLines().get('x') - read line number x from the test.csv file
vars.get('TESTSTART.MS') as long - get Unix timestamp of the time when the test was started
props.put('throughput', some-value-from-CSV-here) - write the value from CSV into throughput JMeter property
Then you can use ${__P(throghput,)} function in the Constant Throughput Timer
More information:
__P() function
Pre-Defined Properties
Top 8 JMeter Java Classes You Should Be Using with Groovy

How to keep certain thread delay between requests and store correlation id for all the request during load test

May i know how to achieve this scenario in JMeter.
Requirement 1 : Request 1 should execute for 15 mins, once 15 mins crossed request 2 should execute and request 1 to be stopped.
Requirement 2 : In request 1, we need to capture all dynamic value and store it some place and same dynamic value we should use it as request body for request 2. We like to run large numbers of users. Not sure, how to store all the response in some files or other alternatives.
Ex : Request 1 - > Trigger -> Store response somewhere(15 min run & 100 iteration) - stopped
Request 2 - > Trigger after 15 min - Execute request with above 100 iteration response)
Either take a look at Runtime Controller, using this guy you can choose how long its child(ren) will be run or just put your requests 1 and 2 into separate Thread Groups
If you want to store full responses into a file take a look at:
Post-Processors to capture the required part of the response into a JMeter Variable
Sample Variables property to tell JMeter to save this variable into .jtl results file
Flexible File Writer if you want to write the values into a separate file

Execute httpSample conditionally JMeter

I need to test a REST method for saving an object. In order to have the ability to save it I need to request an authToken that is updating each 100 seconds.
Right now I have a thread containing both requests , and the login request is executed each time the saving does. How can I make the login execute once at the start of the thread and then each 100 seconds ?
P.S. I've tried separating it in 3 threads , one for the initial login , the other with a loop and a 100 seconds timer and finally the one with the actual test. It does work ,but it seems like a bad solution.
How about:
|-Login
|-Loop n times
|-Save
n being number of times that will be just about less than 100ms?
or
|-If login valid?
| |-NO: Login
|
|-Save
option 3:
ThreadGoup1
|- Login
|- Beanshell update shared token
|- Constant throughput timer
ThreadGroup2
|- Beanshell fetch shared token
|- Save
A constant throughput timer allows you to run at a set throughput. Once every 100 seconds is 0.6 samples per minute, I'm not certain you can do fractions, but even 1 sample a minute should work for you.

Jmeter - I have run 2 test cases but result seems odd

I have run load testing for website but when I have increased no. of users , I can see throughput time seems increasing instead of decrease.
Test Case 1 :
No. of Threads : 15
Ramp up time : 450 [As I want to put delay of 30 seconds between 2 users]
Loop count : Forever
Scheduler : 1800 Seconds [As I want to run test for 30 minutes]
In Http requests I have added 10 pages and each request has constant timer with 30000 miliseconds as I need to put delay of 30 seconds between 2 requests.
Now When I see result of Aggregate Report , it shows me Throughput 3/min for each request.
Test Case 2 :
No. of Threads : 30
Ramp up time : 900 [As I want to put delay of 30 seconds between 2 users]
Loop count : Forever
Scheduler : 1800 Seconds [As I want to run test for 30 minutes]
In Http requests I have added 10 requests/pages and each request has constant timer with 30000 miliseconds as I need to put delay of 30 seconds between 2 requests.
Now When I see result of Aggregate Report , it shows me Throughput 6/min for each request.
I am confuse that how it is possible? If my users are increased from 15 to 30 then it should have more load on server and throughtput should decrease like 1/min or 2/min.
Please let me know what I am doing wrong here.
Throughput is no. of completions per unit time. (A completion can be a http request/db request in short anything that needs to be executed and needs >0 execution time.)
Ex. req per sec or req per min etc.
By definition of throughput in JMeter, it is calculated as total no. of requests/total time.
In your first case, no. of requests generated in 1800 seconds with 3 second delay in every request by 15 users are x. Thus throughput is x/30 i.e. 3 it means ~90 requests were generated (verify this from aggregate report or other reporter.)
In your second case, everything else is same but no. of users are doubled which creates ~double no. of requests in given time which is (1800 seconds)
Thus according to formula, no. of requests generated/total time.
Throughput in 2nd case = 2x/30 = 2*throughput in 1st case
Which is 6/min. (Correctly shown by JMeter.)
Key here is to check no. of requests generated in both cases.
I hope this clears your confusion. Let me know if you need further clarification. BTW "when I have increased no. of users , I can see throughput time seems increasing instead of decrease." is not always true.
Throughput increased by factor of 2.
Test Case 1: - 3 requests per minute - 1 request each 20 seconds
Test Case 2: - 6 requests per minute - 1 request each 10 seconds
As per JMeter Glossary:
Throughput is calculated as requests/unit of time. The time is calculated from the start of the first sample to the end of the last sample. This includes any intervals between samples, as it is supposed to represent the load on the server.
The formula is: Throughput = (number of requests) / (total time).
You may also be interested in the following plugins:
Server Hits Per Second
Transactions Per Second
or alternatively Loadosophia.org service which can convert your JMeter .jtl results files into easy-understandable professional load report

JMeter - Firing different requests in every iteration

I am currently using JMeter to simulate 5 users firing requests every 40 seconds. I have created 100 different requests but after every 40 seconds, each user is firing all 100 requests. I want to make it in such a way that after every 40 seconds, each user only fires 1 request and that request has to be different from the previous request. I would like to know what kind of controller to use (or anything else) to achieve this scenario.
Thanks
Try to use Random Controller.
The simplest way to implement your scenario:
Thread Group
Number of Threads = 5
Loop Count = N
. . .
Random Controller
HTTP Request 001
HTTP Request 002
HTTP Request 003
. . .
. . .
HTTP Request 100
Test Action
Target = Current Thread
Action = Pause
Duration = 40000
. . .
This will iterate 5 threads N times.
Random Controller will RANDOMLY pick up on each step http request from "requests pool" - all the samplers added as children to Random Controller.
Test Action will pause thread for 40 secs.
Updated:
working illustration for above scheme:
Thread Group
Number of Threads = 5
Ramp-Up Period = 0
Loop Count = 10
Constant Timer
Thread Delay (in ms) = 40000
You can download working example for described scheme from here: rc-plan.jmx.
This one works how you want (at least for me, Jmeter 2.5.1): it picks randomly ONE request from requests pool (in example - 10 requests) for EACH user (here - 5 users) on EACH step (here - 10 loops) and pauses each thread for 40 secs (Constant Timer).
You can also look into this mailing archive: Is their a way to randomize URL selection?.
Situation similar to your one seems to be described here.
...As per official documentation "Interactions between multiple controllers can yield complex behavior. This is particularly true of the Random Controller."
Another option for you may be to create a CSV file with parameters for your requests ahead of time and use CSV Data Set Config to parameterize a single http request.
That obviously depends on how different your http requests are, but if it fits your requirements there are some potential bonuses with maintaining 1 http request in your test plan vs. 100.
The other details would be the same as #Alies Belik laid out -- one thread group configured for your required number of threads and loops, with a constant timer at the end for your 40 second pause.

Resources