Set delay between different threads in the same group - jmeter

I want to simulate the following use case. Multiple users login to a server, then after all of them are logged in (and all of them have the required cookies), they do a certain action on the server at different intervals of time.
E.g.
- User1 -> Login
- User2 -> Login
- User3 -> Login
- User1 -> POST foo
- Wait 2 sec
- User2 -> POST bar
- Wait 2 sec
- User3 -> POST foobar
- End
Question: How do I add a delay between the POST actions without having to add the same delay for the login actions?
My Jmeter config looks like this:
-- Test Plan
|- HTTP Cookie Manager
|- Thread Group
|- login (HTTP request)
|- Synchronizing Timer (to wait for all threads to login)
|- post (HTTP request)

Add a timer right to your "post" sampler.
So it's going to look like that:
-- Test Plan
|- HTTP Cookie Manager
|- Thread Group
|- login (HTTP request)
|- Synchronizing Timer (to wait for all threads to login)
|- post (HTTP request)
|- your 2 sec constant timer
If you need something conditional, you may use BeanShell/JSR223 timer instead.

You would have to add constant timer inside the post request so that everytime before post request delay of those many second will occur.
Two implement your scenario we can set jmeter elements as below :

Related

Group multiple HTTp samplers as one transaction, and have constant throughput

In my application, I would like to combine a group of HTTP samplers as one transaction, and have a constant throughput on the group.. ie. when I created a thread group with multiple HTTP samplers and defined a constant throughput timer in the group, I am seeing that it is considering each HTTP sampler separately...
Test Plan
ThreadGroup
----> request 1
-----> request 2
-----> request 3
------> constant Throughoput timer ( 1.0 req per min)
It executes as :
-----> request1
wait 60 secs
------> request 2
wait 60 secs...
----> request 3
...
what I would like
-----request 1
----- request 2
------ request 3
wait 60 secs
----- request 1
---- request 2
----- request 3
wait 60 secs
Depending on what exactly you're trying to achieve:
You can put the requests under the Transaction Controller and tick Generate parent sampler box:
Another option is adding Flow Control Action sampler as the 4th sampler and put the "wait for 60 sec" there
And finally you can put a Constant Timer as a child of the 1st Sampler:
use flow control action at the end of the requests
for better understanding difference between timers & flow control action, please go through this video
https://www.youtube.com/watch?v=miZGLaAq4UQ&t=301s

Execution behavior of Jmeter sending HTTP request to server

I have a Login transaction where in this there are 10 requests. I have added a Uniform random timer for Login transaction for 2 to 3 seconds. i.e all these 10 request will wait for 3 seconds before sending the request as below.
wait for 3 seconds sends Request1
wait for 3 seconds sends Request2
wait for 3 seconds sends Request3
and so on.
So my question is does Jmeter waits for the response before sending the next request. i.e will Request2 waits for the response or will Request3 is sent after 3 seconds irrespective previous requests response. in this case Request2's response.
Please help in this.
Thanks in Advance,
JMeter will wait for response from previous request prior to sending next request in any case. In normal conditions it would look like:
Request 1
Request 2
Request 3
...
See A Comprehensive Guide to Using JMeter Timers article for more information on how Timers work.
By adding a Timer you create a "sleep" before each request, it will look like:
Sleep 2 - 3 seconds
Request 1
Sleep 2 - 3 seconds
Request 2
Sleep 2 - 3 seconds
Request 3
...
However as per documentation:
Each thread will execute the test plan in its entirety and completely independently of other test threads. Multiple threads are used to simulate concurrent connections to your server application.
So if you have > 1 thread you may run into the situation when different threads are executing requests at the same time (which is the main point of load testing).

Jmeter user session wise different data set

My test plan is as following
- Test Plan
- Thread Group (No of Threads: 4)
- HTTP Request Defaults
- HTTP Cookie Manager
- CSV Data Set Config(Login Information) [4 user login]
- Simple Controller
- HTTP Request(GET: Open Login Page)
- HTTP Request(POST: Login auth)
- Loop Controller
- CSV Data Set Config(Operation Information) [8 operation data]
- HTTP Request(GET: Open Operation page)
- HTTP Request(POST: Commit Operation)
- HTTP Request(POST: Logout)
In this plan suppose I provide 4 users and 8 operation data.
What it doing is running 8 operation for 4 users each in total of 8x4=32 operations.
How could I make this as following
1st user will do 2 operations
2nd user will do 2 operations
3rd user will do 2 operations
4th user will do 2 operations
I want to provide user session wise different operations that 4 users will do number of transactions but the transactions will not be same.
How can I achieve this?
If I'm getting your test scenario correctly you can just set the "Sharing Mode" of your CSV Data Set Config (Operation Information) to Current Thread Group.
Current thread group - each file is opened once for each thread group in which the element appears
If you want more precise control I believe Switch Controller is what you're looking for, using it you can select which user will go for which execution branch.
See Running JMeter Samplers with Defined Percentage Probability article for more information.
As requested, I am posting my solution. Below is the test plan story.
Test Plan
Thread Group
I used only 1 thread in my thread group and 4 in the loop count as shown below.
Loop Controller
CSV Config for the both the files
Output

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 - Access TransactionController in Beanshell Listener

I've created a BeanShell Listener element in my test plan which I use to collect SampleResult data for each HttpRequest and send to third party software. Presently there are four HttpRequests in my plan:
Get - Hit Login Page
Post - Submit data to Login Page
Get - Hit page to setup session
Get - Hit 'Home Page'
Steps 2 and 3 are related and ran sequentially so from a reporting perspective are essentially '1 step'. I've created a TransactionController around these two elements but my Listener script only appears to be able to retrieve the result data from the second of these two elements. Essentially I want my script to get the total time taken for these two steps for reporting.
Any thoughts?
I can't reproduce your scenario (using JMeter 2.8). Here is how my test plan looks like:
Thread Group
HTTP Request 1
Transaction Controller
HTTP Request 2
HTTP Request 3
HTTP Request 4
Beanshell Listener
My Beanshell Listener has row
log.info(sampleResult.toString() + " - " + sampleResult.getLatency());.
It logs (with omitted log info):
HTTP Request 1 - 143
HTTP Request 2 - 84
HTTP Request 3 - 83
Transaction Controller - 167
HTTP Request 4 - 93
Looks like it works

Resources