Need to handle duplicate session in jmeter scipt - jmeter

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.

Related

Using JMeter to test an OpenXava application

I'm facing a problem when writing a JMeter test plan.
The goal is to test an OpenXava based application.
I perform the request with firefox then I try to copy the headers, parameters and cookies in my HTTP request sampler (thus in JMeter).
There are a lot of parameters (36) sent when trying to login. I copied all of them.
However, I can't make it work.
The HTTP response seems useless. It's nearly the same I get when sending a wwrong password with Firefox :
throw 'allowScriptTagRemoting is false.';
//#DWR-INSERT
//#DWR-REPLY
var s0={};
dwr.engine._remoteHandleCallback('1','0',{application:"bdsa",changedParts:null,currentRow:-1,dialogLevel:0,dialogTitle:null,error:null,focusPropertyId:null,forwardInNewWindow:false,forwardURL:null,forwardURLs:null,hideDialog:false,module:"SignIn",nextModule:null,propertiesUsedInCalculations:null,reload:true,resizeDialog:false,selectedRows:null,showDialog:false,strokeActions:s0,urlParam:null,viewMember:"",viewSimple:false});
Do you have a clue about what is happening ? Should I try to test the login page with another method ?
Why don't you just record your flow using JMeter's HTTP(S) Test Script Recorder and your browser.
Set up JMeter Proxy Server
Set up your browser to use JMeter as the proxy
Perform the test scenario in the browser - JMeter should capture the requests under the Recording Controller
Perform correlation if required. If your application is deployed in the Internet you might get benefit of cloud-based proxy service which can perform automated detection of dynamic parameters and generating the relevant code to extract the values and substitute recorded hard-coded parameters with the variables
Don't forget to add HTTP Cookie Manager to your Test Plan - it deals with cookies and cookie-based authentication

CSS/JQuery extractor is extracting default value in case of load test, for the random threads

Performing a login and update user test with multiple users.
I have created a CSV file with 200 username and passwords. Running 200 threads
Performing login and update user, with 200 users.
I am extracting the value of csrf token in a variable after the login request. Then, I am passing that csrf variable in the user update, post request.
Running the same request with 100 users, I am able to log in and update the user's details.
Running the same request with 200 users.
getting the connection timeout exception.
Some of the update user post requests are getting failed because csrf variable is extracting the default values of CSS/JQuery extractor. CSRF token actual value is not getting extracted to the variable.
I have also added Authorization, Cookie, Cache and Header Manager in my test plan.
The constant timer is also being used after login request.
I have set the value of timeouts to 120000 in the HTTP request defaults. Even if I am increasing the timeouts, getting the same exception.
Most probably your application under test simply gets overloaded therefore it cannot respond in a timely fashion.
With regards to CSS/JQuery extractor which is failing to get CSRF token - my expectation is that the token is not present in the response for failing samplers.
So I would recommend taking the following troubleshooting steps:
Completely remove Connect and Response timeouts in the HTTP Request Defaults so JMeter will wait for response forever.
Configure JMeter to save responses for failed samplers by adding the next 2 lines to user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data.on_error=true
this way you will be able to see how does response look like for failing requests. See Results File Configuration User Manual chapter to learn what other metrics could be useful for your analysis.
Check your application and middleware (web/application/database server/load balancer logs)
Make sure to set up monitoring of baseline OS health metrics on the application under test side. You can do this using JMeter PerfMon Plugin
Just in case double check you're following JMeter Best Practices

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

browser session issue in jmeter

Iam testing an application which has the following behaviour
User1 loged into machine A using IE Then User2 cannot login into
Machine A using IE. So User2 should login from Machine B.
I have recorded the script using IE and when trying to test with 10 user load say U1 to U10, only U1 is able to login and rest all are failing....how do i simulatd the load in this case.
I checked with developers and they are not using IP address for this but using browser session for making single user logs in from a single browser.
Could you please help how do i overcome the issue and simulate the load
Try adding HTTP Cookie Manager, it can automatically handle cookies and define and maintain separate session for each thread.
If it doesn't help - inspect requests more closely with a sniffer tool like Wireshark to compare which request bits are different for different users. The possible options are:
Cookies - can be handled by aforementioned HTTP Cookie Manager
Headers - can be handled by HTTP Header Manager
Request parameters - it may be the case when server sends some parameter in the response and expects it to be present in the next request. In that case you need to extract it from the first response with i.e. Regular Expression Extractor, store it into a JMeter Variable and send with the next request.

Session Expired Response in JMeter

I am testing particular application using JMeter 2.9.There My test plan is Thread group--> Transaction Controller.Inside that various recorded requests are there.I am using HTTP request defaults,HTTP Cookie manager and HTTP header manager,and a view result tree for validation.I found one token i.e. CSRF token to be correlated and I did correlation.But for a particular request I am finding "Session expired..Login again" response much before the logout request.My transaction flow is to Login--> Search a content-->Logout.
Please help me finding a solution.
Try put the element: HTTP Cookie Manager in Thread Group, first item.
the problem can be in the following areas:
-you were redirected automatically instead of following redirects
-login hasn't succeeded
-the session id has not been successfully passed on to the request after login
The JMeter documentation states this:
I've set up JMeter to sample the same URLs as my browser, why is JMeter not seeing the same responses?
There are various different reasons for this:
Cookies - make sure you added a Cookie Manager. Browsers process cookies unless you set them up otherwise, but JMeter does not process cookies unless you add a Cookie Manager.
User-Agent - the User-Agent is a header that is sent by browsers; it identifies the browser type. Some servers are sensitive to this setting and generate different results for what they think are different browsers. The Header Manager is used to add headers such as User-Agent.
Hidden fields - if you did not use the JMeter Proxy (or other application) to record the test plan, then it is easy to miss hidden fields from forms.
Dynamic field names/content - some servers use varying names for fields. So although the test plan may be correct at the time of creation, it does not work when replayed.
URL rewriting - TBA
from http://wiki.apache.org/jakarta-jmeter/DifferentBehaviour

Resources