Jmeter - Run multi-threaded users simultaneously without affecting the flow - jmeter

I have a user flow (create base64 header auth > register request > Register > login > sending data) which I want to run simultaneously (100 users).
If I use the Thread Properties as it is, it will run in asynced way.
Examples:
User 3 will try to login with token of user 1, user 40 will register with registration header created for user 24 and so on..
Token for login extracted from base64 process,
another token is extracted from 'register-request' and used as variable in 'registration' header.
I want first user to register with token created in first register-request and login with token created in base64 process, and so on for next users.
Is there a way to do so?

Normally JMeter virtual users store variables in the thread-local storage so given your test plan design is good each thread (virtual user) should use its own header.
Not knowing the details of how your header is generated it's hard to say what's wrong, I would recommend using Debug Sampler and View Results Tree listener combination and double check the header value (and any interim variables) - hopefully you will be able to determine the cause. If not - you will need to share the test plan somewhere somehow.
Other things to consider:
If your application requires Auhtorization header in form of username:password encoded into Base64 you actually don't need to generate the header manually, you can use HTTP Authorization Manager which automatically generates and adds the relevant header to the requests. Check out How to Use HTTP Basic Authentication in JMeter article for more details if needed.
There is __base64Encode() function which you can use for encoding a custom string into Base64, the function can be installed as a part of Custom JMeter Functions bundle using JMeter Plugins Manager

Related

OAuth token generation using Jmeter for multiple User-Credentials

I am testing an application hosted in gcloud, to execute the test using jmeter I require OAuth token for respective User credentials. I am able to generate the token for one credentials, however I have not been able to find a way to generate them for more than one users.
If anyone has faced such problem or has any glimpse please let me know.
Note:
I need a fresh token with every iteration since token expires in every 60 mins
I am able to generate token manually to run the test
I have tried auth/header manager for the process
I have tried console auth code generation code as well
Above all generate auth code for a specific credential, wherein I have to keep the application active.
So you want to apply load to app backend using authenticated users.
If so, why don't you use
CSV File to store your test credentials
Use JMeter's CSV Config to read those credentials
once only controller for authentication, extract access_token and refresh_token
Use tokens to make calls to your backend
If you need to run loadtest / soak test for longer than one hour you can use if controller to verify the token validity and renew the token if necessary.
Hope this helps.
If you need to refresh the token each 60 minutes it makes sense to create a separate Thread Group which will be executing a token refresh request each 60 minutes.
The token can be passed to the main Thread Group using __setProperty() function, you can make the token value thread-specific by combining it with __threadNum() function like:
In "token" thread group:
${__setProperty(token_${__threadNum},${token},)}
In "main" thread group you can read the value using __P() function:
${__P(token_${__threadNum},)}
Demo:
More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups

Recorded user authentication then run same script with another user id and password but Jmeter displaying previous user's dashboard

Recorded user authentication for one user then run script in Jmeter and successfully logged-in. Now change user id and password for another user but displaying previous user information not changed user information
Check out if there are any headers being sent via HTTP Header Manager. It might be the case your application under test identifies user via header
Check if recorded URLs contain dynamic postfix which can act as user session identifier
If there is a HTTP Authorization Manager in your Test Plan - update username and password there
Consider adding HTTP Cookie Manager to our Test Plan - it should be sufficient to automatically handle user sessions
Generic troubleshooting step: capture the requests sent by JMeter and the real browser using a sniffer tool like Wireshark or Fiddler and compare them. Amend JMeter configuration to eliminate differences.

How to maintain session in Jmeter for testing web application?

How to maintain session in Jmeter so that each user should login, search tickets and then logout ? and this process kept going until loop completes for all users.
As I am trying to test our web application with multiple users.
Each JMeter Thread (representing a virtual user) executes samplers upside down so if you have 3 samplers for login, search and logout each thread will execute them in that order.
Keep in mind that:
You need to provide different credentials to each thread so they could impersonate different users. The most common way of parametrization is using CSV Data Set Config
It's better to add HTTP Cookie Manager to represent browser cookies.
It may also be required to perform correlation: in majority of cases application expects dynamic parameters which need to be extracted from previous page response and added to the next request. If you fail to do it you may not even be logged in. The most commonly used test element for correlation is Regular Expression Extractor however depending on the nature of the response it may worth be using CSS/JQuery Extractor, XPath Extractor or JSON Path Extractor
Add Cookie manager. Afterwards it depends on the application you will need dynamic values like viewState or eventValidation or similar ones. But first add the manager and get to the next problem :)

How to Configure Jmeter for after Login process in an Application?

How to Configure Jmeter for after Login process in an Application?
I am able to configure the login request for 100 users from the CSV file with the help of Jmeter's "CSV Data set Config", but after the successful login of all I want to know how to configure the jmeter to go to the "Offers" page of there(100 user) accounts.Means 1 User can login & View his/her "Offer" page.Please Help.
There are two ways to achieve this scenario:
add another HTTP sampler & fill the details like Server IP, Path of Offers URL (you will have already done the same for Login), HTTP Header data etc. and pass correlation parameters from the response of Login if required to view the offers specific to 1 user.
make sure you use right method (GET/POST) in HTTP Sampler.
record the whole scenario (ref: http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf).
You will still have to do the correlation of parameters (using regular expression extractor or Xpath extractor) wherever required. This entirely depends on the parameters required for the offer page HTTP request.
hope this will help.
You'll need a cookie manager to store the session and cookie for all logged in users.
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager

How to login to an email Address using jmeter?

I am testing some api for our product using jmeter. To test the api to verify the user's email address I need to login to the mail account. I have the email and password of a test user. How can I login using an api or any other way in jmeter?
Is it possible at all?
Yes that is possible. You'll have to create a test plan with multiple steps but these depend on the concrete implementation of the login.
First you must identify the following two locations:
The GET request that gets the initial login form (if this is required).
The POST request that posts the login credentials.
If your service has a stateless login form you can even skip the first step.
Otherwise the response of the GET request will contain stuff which needs to be extracted (e.g. the JSESSIONID if you are using JSF) and sent as a parameters in the POST request. You can use the Regular Expression Extractor of JMeter to extract these values and provide them as variables for use in the subsequent requests.
Here is an example screenshot of a HTTP Request element configured to POST login data to the url /common/j_security_check
You might also need to intercept an authentication token from the server response and then pass that into following requests.
Here is a blog entry with a couple of video tutorials on logins with JMeter:
http://community.blazemeter.com/knowledgebase/articles/80479-how-to-use-jmeter-for-login-authentication
You can use jmeter to login,
two ways:
parameterization using csv file(for more users)/user defined variables(UDV)
Login config elements(for single user)
Now that I understand you want to automatically click on a confirmation link from an email using JMeter, here is a blog entry that explains exactly how to do that:
http://blazemeter.com/blog/how-create-jmeter-script-check-email-during-registration-and-grab-confirmation-url
Ophir

Resources