How to use one access token generated for multiple users request in jmeter - jmeter

I am working on jmeter for the First time. I am extracting the accesstoken and passing it on to other requests. but i am facing the issue that once I run it for 50 users the access token request is also running and becase of which other request is failing as new access token is generated and the request is failing to use that. I want to generate one access token for all the 50 request. I have tried keeping the request parted in two different thread groups.
enter image description here

#oshin, I am also new here but I will try what I did that might help yours too. I used JSR223 PreProcessor to get that access token and passed that in my other thread with another JSR223 preprocessor which reads that accesstoken. And passed that token in my header manager. See if this helps you.
Get token
Read access token in the following thread
Assign token to Header manager

Don't use Beanshell, since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting
Don't use scripting when something can be achieved using built-in JMeter Test Elements (or JMeter Plugins)
I would recommend:
Moving your "login" sampler under setUp Thread Group so it would be executed before the main thread group and only by 1 user
Storing the token into a JMeter Property via __setProperty() function
JMeter Properties are global and can be accessed by all threads in all thread groups so you will be able to use one token
Read the token using __P() function where required.

Related

how can we pass bearer token created in xml into 2 nd api which is placed in another thread group in jmeter

how can we pass bearer token created in xml into 2 nd api which is placed in another thread group in jmeter I have tried with set property but it is not working as the body of token is in xml.
If your token comes in the XML response just extract it using XPath Extractor or better XPath2 Extractor.
Once you have the token stored as JMeter Variable there will be 2 options:
Convert it into a JMeter Property using __setProperty() function
Or use Inter-Thread Communication Plugin (see SynchronizationExample.jmx test plan for reference usage)

Jmeter generating reports for each thread(user) in case of multiple users logged

I have created a thread group with user credentials passed from csv file . Using CSV Data Set Config, i have passed 10 different credentials to the test plan and executed it.
I have used different listeners, but not able to generate the report for each user. The report is generated for the requests and responses for the entire threads and not any individual threads.
If anyone got to know about generating the report for the requests and responses for individual threads, please let me know. Thanks in advance.
You can add __threadNum() function as prefix/postfix for the Sampler label, this way you will be able to distinguish the results for different virtual users, to wit instead of HTTP Request use HTTP Request - User: ${__threadNum}
Similarly you can add a JMeter Variable to add credential from the CSV file to the sampler label, this way you will get a human-readable names instead of virtual user IDs

Need to handle duplicate session in jmeter scipt

Below is my Jmeter script flow:
-Thread group
- Test Plan
- Login scripts
- Http header manager
- CSRF authorization using css/Jquery extractor
- Dashboard
- Graph Listener.
Problem is: When i run this test plan with 1 user hit, it passes but when i try it with 50 users(more than 1 user) it fails As in our website Multi sessions are not allowed.
Any help would be appreciated !!
Try adding HTTP Cookie Manager to your Test Plan, if your application manages session basing on cookies - it should fix the issue
It might be the case your application uses URL parameter for session management - in that case go for HTTP URL Re-writing Modifier
Inspect your script more carefully as it might be not only one dynamic parameter (CSRF token), there could be more parameters requiring correlation. Record the same scenario 2 times using HTTP(S) Test Script Recorder and compare 2 results scripts. All parameters which are different need to be correlated.

How to make working login into Laravel 5.+ with JMeter?

I'm trying to test a few functions on my Laravel based website. However, I'm having difficulties logging in the website. I've used BlazeMeters Chrome plugin to record my events and save it in jmx file. Was able to do that and imported the file in JMeter. Now at login we are not just examine the email and password, but also a _token variable. This is individual for all visitors. Do I need and if yes, then how can I fetch the token for one user and use that at login time and any other time, when the _token was requested?
Bert
Your test flow should look like:
Open Login Page (usually HTTP Get Request)
Extract the token from the response using one of JMeter's Post-Processors (normally people use Regular Expression Extractor or CSS/JQuery Extractor)
Perform Login (usually HTTP Post Request) providing credentials and the token from the step 1
The process is known as correlation and there is a plenty of information on it over the Internet.
If you want to get things done faster you could consider an alternative way of recording a JMeter test scenario which automatically detects dynamic parameters, generates the relevant post-processors to extract them and store into JMeter Variables and substitutes parameters with the variables so you won't have to do it manually. Check out How to Cut Your JMeter Scripting Time by 80% article for more details.

Why is only my first HTTP request running?

I'm still pretty new to jmeter. I'm using jmeter 2.9.
I have created a thread group with two threads in it. I have set up an HTTP Request Defaults for the thread group. I have created User Parameters to define person IDs that I'm going to be working with in each thread.
I then set up two HTTP requests. One for login, one for retrieve person. For the login one, I created a regular expression extractor to extract the session key that comes back. I then supply the session key as the parameter for the retrieve person request.
I then sniffed the net traffic and started jmeter test. I wanted to make sure the session key was getting passed into the second parameter OK, but it appears to be running on the login twice and then ending. I am getting a 200 return on the HTTP packet and my jmeter test was set to continue regardless.
I believe I followed chapter 5 of the jmeter user manual to set up this test with the addition of parameters, user parameters, and the regex extractor.
Can anyone give me an idea what i might have done so that the second request never runs?
Add "View Results Tree" listener to see what jMeter is actually doing? You should also check jmeter.log to see if there are any exceptions while generating the 2nd request.

Resources