jmeter replace subsequent requests with response from initial request - jmeter

I am thinking of using Jmeter Access Log Sampler to replay tomcat access log or even normal http sampler with a CSV.
What we have in the log is
url1?CallId=1&otherParam=value
url1?CallId=1&otherParam=value&CONTEXT_ID=123435
url1?CallId=1&otherParam=value&CONTEXT_ID=123435&somemoreParam=etc..
url1?CallId=2&otherParam=value
url1?CallId=2&otherParam=value&CONTEXT_ID=67859
When the first request sent to the server without the CONTEXT_ID the server will do a lot of stuff and create a context id for that CallId and return it in the response. Subsequent calls to the server for the same CallId need to have the this same CONTEXT_ID on the URL. Context_IDs from access logs server will not exist in the target server so I can't just use it as is.
Is there a way to capture the response from the initial request for a given CallId and replace CONTEXT_ID for subsequent requests that contains the same callId?
Thanks & regards
voki

Extract it with:
&CONTEXT_ID=([^"]+)
Re-use it:
${YourParamName}
See also http://jmeter.apache.org/usermanual/regular_expressions.html

Related

How to handle callback return response in Jmeter

In my REST POST/PUT request I will send callback url with additional data
Once backend server responded with success or failure, i will get response to my callback url.
How can see what response in callback url in Jmeter. Based on response I process further
If this is a 3rd-party URL there is no possibility to intercept the request from your backend to this callback URL with JMeter
If you can change the callback URL to an arbitrary value you can use i.e. HTTP Mirror Server as the callback URL, this way your backend will send the request to JMeter instead of the 3rd-party URL so you will be able to get the status and eventually re-send the request to the callback URL so it won't be lost.
If this is not possible you can investigate where the information about the job status is stored, if it can be found in a log file you can use OS Process Sampler or SSH Command sampler to get it, if it's in the database - you can retrieve it using JDBC Test Elements, etc.

Apache Jmeter is not giving any error even we gave wrong credentials

I am new to JMeter. I am using it for load testing for Microstrategy web dossiers. I am loading the users from CSV Config file. I have generated steps using Badboy software and exported as Jmeter file. I have added variables for userID and password. I have enabled "Retrieve all Embedded Resources". When I ran the testing. I observed that its giving same response even if password is wrong. taskProcs are giving connection closed error. I have searched with dossier ID in both the cases , I am able to see the request and response same even if password is wrong. Can you help me how to identify whether the credentials matched or not ? I would like to throw error when password didn't match ? I thought of adding Response Assertions but responses are same.
JMeter automatically treats HTTP Response Status codes below 400 as successful. So if HTTP Request sampler returns status 200 (or any other between 100 and 399) it's treated as success.
JMeter doesn't perform any checks for content, if you need to add explicit pass/fail criteria basing on the response body, presence or absence of certain text, sampler execution time, etc. you need to add a relevant Assertion and put the anticipated success criteria into the assertion.
First JMeter doesn't generate any error codes or error messages itself, what it actually do is working as client and giving back what application sends to JMeter.
I think first you have to make sure application works correctly, then check whether Jmeter scripts work correctly. For that add debug sampler before the API request and check whether variables username, password has evaluated correctly from the csv.

Maintain State Between HTTP Requests to Keycloak in JMeter

So I am trying to automate a JMeter script that creates Keycloak users and then signs them in.
First It GETs the login page and stores the code, here is an example request:
GET http://Keycloak.com:8001//auth/realms/REALM/protocol/openid-connect/auth?response_type=code&client_id=CLIENT&scope=openid%20profile%20email&nonce=N5b3a2da23c04a&response_mode=form_post&resource=RESOURCE&state=2SJwtlVZrswlGkw&redirect_uri=REDIRECTURI
However, when I then GET the registration page, the code changes and the tab_id also changes. How can I keep keycloak from generating a new code token with every HTTP request in a thread?
In addition, why is each HTTP request with JMeter acting like a new session instead of the next request in a series?
EDIT:
I am using Regular Expression Extractors in order to track the code and execution variables, in addition to using a HTTP Cookie Manager and HTTP Cache Manager for the thread.
Looking at my POST request, both variables are the same as those from the previous HTTP request, and all of my cookies are being maintained, yet every time I try this automated login, I get a 400 error and the keycloak event log displays an invalid_code error.
Edit:
As requested here is a screenshot of all my sign in requests
Most probably your Regular Expression Extractor is not nested in the HTTP Request you are trying to extract data from.
If its scope is too wide, it applies to all HTTP Requests, so first time it succeeds extracting, but then for the next request that does not contain the token, the extractor runs and overwrites the old value by an empty one.
See scoping rules in JMeter:
https://jmeter.apache.org/usermanual/test_plan.html#scoping_rules
You need to maintain the corelation between hits. Please go through below blog
https://www.blazemeter.com/blog/how-to-handle-correlation-in-jmeter
According to keycloak you must use https if you are using keycloak.com
Keycloak can run out of the box without SSL so long as you stick to private IP addresses like localhost, 127.0.0.1, 10.0.x.x, 192.168.x.x, and 172..16.x.x. If you don’t have SSL/HTTPS configured on the server or you try to access Keycloak over HTTP from a non-private IP adress you will get an error.
So you have 3 options: use private IP address, use a reverse proxy or load balancer to handle HTTPS or enable HTTPS for the Keycloak server.

Facing issues in Jmeter script for asmx calls

We recorded a business flow with Jmeter. In our script we have some asmx calls. All calls are sending requests in http format.
The recorded asmx requests are not sending any parameters (not possible to do correlation).
But after replay, all asmx calls are failing where we are sending some session values in cookies in our requests in view result tree. But not
Getting those sessions in any of the previous response.
Please help me out to fix it.
Thanks in advance
I believe that the problem is in cookies.
Try adding a HTTP Cookie Manager to your test plan. JMeter should be smart enough to handle cookies for you. If you have any cookies being sent via "Browser-derived Headers" - remove them.
If point 1 doesn't help you should be able to manually extract cookie data from Set-Cookie header via Regular Expression Extractor. Inspect View Results Tree Listener output for any Set-Cookie headers being sent in responses.
Don't forget to "tell" your Regular Expression Extractor to look at Headers response field (it defaults to Body)

how to use jmeter with ajax request

How to use JMeter with ajax request?
I have a button with is clicked and by using fiddler I can find the session id which is being sent to the server.
What should I do next using the JMeter in order to handle this.
EDIT:
Let's say I have in my hand the header which call the request. The JSESSIONID AJAXREQUEST
and so on where should I put it ?...
I putted it in http header manager name and value.
Jmeter will not execute Javascript embedded in your web page. However AJAX request is also a HTTP request that Jmeter will be able to run as a separate HTTP request and upon getting the response you can have post processors (using XPATH or REGEX) to extract the session id in a Jmeter variable.
Alternatively you can record the Jmeter scripts using Jmeter proxy and then all the HTTP requests will be recorded for you and you will just need to attach a post processor manually.

Resources