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

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

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

Running Jmeter for Https app with single user for multiple times through Loop controller

Attached is the snapI am trying to run jmeter for single user with value of 10 in loop controller , I first login into the app and then subsequently uses the CSRF token accordingly for future request .The login is always successful and generates CSRF token, But when i try to use CSRF token for future request , I get unauthorized HTTP 401 reponse code , when running with value 10 in loop controller for single user , the same works when i try to run single user with value 1 in loop controller , Any idea how to fix this? (Note :- All this is present in same thread Group)
Well-behaved JMeter test should be able to loop single user without any problem, most likely you have a problem with your test design or mismatch with the application under test behaviour. General recommendation would look like:
First of all switch to iterations on Thread Group level, JMeter configuration elements don't respect iterations originated from elsewhere as "iterations"
Add Debug Sampler and View Results Tree listener to your Test Plan
Run your test with 1 user and 2 loops
Inspect request and response details, identify missing/extra/different parameters and fix them. See How to Debug your Apache JMeter Script for more details on JMeter test troubleshooting techniques.
Blind shot: your test includes login request and the virtual user is already logged in therefore it doesn't require login on 2nd loop. In this case you have 2 options:
Put the logic which needs to be executed only 1 time under Once Only Controller
If you use HTTP Cookie Manager be aware that Clear cookies each iteration works only on Thread Group-level iterations

Need to send the web service request contentiously till get response using JMeter

My requirement is as follows:
I will be copying one test data file to one location. [My application will pick file, process it and will respond using web service]
So when I login to my application and go to that page, every 5 seconds web service request would be sent.
Above two, i can handle using JMeter. Now next is
Need to send the web service request contentiously [maybe each request in 5 seconds] till get response using JMeter
So how can I do this?
Please help. Thanks!
Something like:
While Controller with condition depending on the response
HTTP Request Sampler
Constant Timer to sleep for 5 seconds
Maybe a Post-Processor to set the While Controller's condition
See Using the While Controller in JMeter article for more details on implementing while loops in JMeter tests.

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