Scheduling Login, post request and logout in Jmeter - performance

I have Test Plan in Jmeter having following three sections:
Login (HTTP Sampler)
Runtime Controller (Containing HTTP POST Requests)
Logout (HTTP Sampler)
I want to schedule the test in following way:
300 users LOGIN
Once all the users are logged in, the Runtime Controller runs for 1 hour posting HTTP Post request
All the 300 users logout.
I have set the Thread group to 300 users, and Runtime controller duration to 3600 seconds. But I have observed that the Login, POST requests and Logout are not synchronized the way I want it to be.
I am new to Jmeter, please help!

You need Synchronizing Timer to achieve 300 users doing same activity concurrently.
Synchronizing timer blocks or holds the threads at a point till x no. of threads are blocked. It then releases all blocked threads at once so that peak concurrent load (300 users doing post activity at a time) is achieved.
you should follow below sequence,
Please change Number of Simulated Users to group by to 300 i.e your needed users.

Related

How to synchronize 2 requests (samplers) in JMeter

I have test in jmeter that call get oauth token (Token request) and than call rest web service. Problem is that it call Token request to early and when It call web service, it fails becouse token is no longer valid. Can someone help me to fix it in the way, that Token request will be executed few seconds before web service call?
My test config in jmeter
Throughput Controller
Constant Throughput Timer
Normally you shouldn't do anything because each JMeter thread (virtual user) executes Samplers upside down and looking into your test plan I can see that the token request is before the authenticated request so it shouldn't be a problem (unless token life time is below 1 minute)
Whatever.
If you want to introduce a delay between 2 requests there are following options:
Add Flow Control Action Sampler before the 2nd request
Add a relevant JMeter Timer (i.e. Constant Timer) as a child of the 2nd request

JMeter - different HTTP request for different number of threads in the same thread group

I am load-testing a web application. I have recorded 5 different test scenarios using HTTP test script recorder under the same thread group.
I want to run the script with 5 threads, different thread for each request.
For Ex:
5 HTTP Requests in the same Thread Group.
5 Users. Different user for each HTTP request
1st user 1st HTTP request, 2nd user 2nd HTTP request... 5th user 5th HTTP request.
How to implement this. Any help would be much appreciated.
You can use Switch Controller for this and put __intSum() and __threadNum() functions combinatino as the "Switch Value"
This way each user will pick up the relevant Switch Controller's child:
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

While running ultimate thread group with multiple users in parallel, I'm getting 'Session Expired' message for the application

Please find below details,
Ultimate Thread Group: User:10, Initial Delay:0, Startup time:300, Hold time: 900,Shutdown time: 120
Once Only Controller: Login
Run Time Controller: Actions (Given Seconds: 1420)
Once Only Controller: Logout
If I run the group with single user it's executing the Login and Action sampler without any error But logout sampler is not executed.
If I run the group with multiple user, some of the samplers are passed and some of the samplers are getting fail with error message as 'Session Expired'. Here also Logout sampler not executed.
How to over come this issue in Jmeter?
The Logout sampler is not executed because the thread is shut down before it reaches it. Your overall thread group duration is 1320 and your Runtime Controller is set to 1420
With regards to the "Session Expired" I can think of 2 options:
missing or improperly implemented correlation, i.e. the maximum duration of the user session is shorter than your test duration. Have you added HTTP Cookie Manager to your Test Plan?
your application gets overloaded and cannot properly maintain the user session, check its logs for any suspicious entries.

How to send some api call sequentially and some api calls parallely for the same user action

How to send some api call sequentially and some api calls parallely for the same user action .
You can make use of Parallel controller
I tried to simulate your scenario in this screenshot below
I added 2 Debug Samplers before Parallel controller and 2 after the controller. On the right hand side if you see Debug Sampler 3 and Debug Sampler 4 started at same time whereas others have a different start time indicating a sequential run.
For sending requests sequentially just add HTTP Request samplers, one per request and each JMeter thread (virtual user) will execute them upside down
For sending requests in parallel put the relevant HTTP Request samplers under the Parallel Controller

Logout not working in Jmeter script

I have been using JMeter for a while and I am facing a problem in particular related to logout. I am using the below script -
TestPlan
HTTP Cookie Manager
HTTP Request Defaults
ThreadGroup - (scheduled for half and hour)
Once Only Controller
HTTP Request - login
Loop Controller - (forever)
HTTP Request 1
HTTP Request 2
....
HTTP Request 13
tearDown Thread Group
HTTP Request - logout
But the problem here is that even the logout response looks good , the user used for JMeter script login is still actually not logged out. (that i can monitor as as Admin)
Most likely your "Logout" link just clears user's cookies via JavaScript. As per Apache JMeter project main page:
JMeter is not a browser. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).
So Logout event can be simulated in JMeter by clearing cookies - see "Clear cookies each iteration" box in the HTTP Cookie Manager
NB: Iteration in the HTTP Cookie Manager (as well as in HTTP Cache Manager, etc) is something which is being defined and incremented at Thread Group level, loops triggered by Loop Controller, While Controller, etc. are not considered as "iterations"
It it also possible to clear cookies programatically i.e. from Beanshell Sampler

Resources