JMETER Assertion for response not working - jmeter

I have my Response assertion updated as shown in screenshot. it work when condition match but when it doesn't match i still get error because response is null. as the request posted is successful

If you expect particular that request to have HTTP 404 status and you want to mark it as successful - just tick Ignore Status box and that would be it.
Also make sure that the assertion is applied only to this sampler(s) it should be applied to, in order words it acts according to the JMeter Scoping Rules and you need to be aware of these rules.

Related

View Result tree is not showing a correct request as in script

In the script we are using a PUT request as shown in below image
But when we run this, it is showing it as a GET request as shown in the below image
Due to this request is failing with a 400 bad request response code.
I am using Jmeter 5.5
If you expand this Sample Result to see its sub results you will see your initial PUT request followed by at least one redirect so View Results Tree listener is "showing the correct result", the fact that your PUT request fails is rather connected with a problem in your script, most probably you're simply not authorized due to missing or improperly implemented correlation or something like this.
So visit previous results and inspect their response data to ensure that your script is doing what is supposed to be doing, the fact that the request is "green" indicates only that HTTP Status Code is below 400, it doesn't necessarily mean that it's successful.

JMeter ignore specific types of responses in all Receive samplers (Websocket)

Is there a way for all Receive samplers to ignore specific responses in JMeter and wait for the one that we are interested?
To be more precise, we have created a jmx file that contains a large flow like a user would create on the browser. Each request sent is followed by a response, so we use a request handler followed by the corresponding receive handler for each call. And everything seems to work fine.
But there are cases that another kind of response may arrive, which is not the one we expect in our flow, but it is triggered by another independent mechanism. You can think of it like notifications sent to the user that is doing the flow and are independent of the flow itself, but theu are received in the channel (for us inside the websocket connection).
So we are trying to find a way to ignore a specific set of responses that may come while we are running the tests.
We firstly tried to add a While Controller in each receive sampler that checks if the content is of the desired type and if not loops again. But this solution has 3 disadvantages :
we have to add the sampler for the specific receive twice - one before the while element and one inside the element because we have to first extract the received data and while does not execute its contents before doing the while condition check
we have so many pairs of send-receive in our jmeter test script , that we have to add so many while controllers inside the script
since the received message may not be of the type we expect but another one that we want to ignore, then we cannot add a Response Assertion because it will fail if the notification arrives, so we have to verify the content indirect -> in the condition of the while loop
We use apache-jmeter-5.3.
So we are wondering if we could do another kind of configuration in order to avoid all these while loops.
It may be irrelevant to the solution, but we use websocket through "WebSocket Samplers by Peter Doornbosch".
Thanks
You don't have to, just amend your While Controller's condition to accept undefined variable as well
Sounds like a potential use case for using Module Controller to avoid code duplication
If you're getting the response you don't expect you can change the response body using JSR223 PostProcessor to the one you expect, example code
if (!prev.getResponseDataAsString().contains('foo')) {
prev.setResponseData('foo', 'UTF-8')
}

JMeter View results tree listener displaying duplicate https requests

View result listener displaying duplicate https requests, 1 request is without response and 1 request is with having response. I need only 1 request, How can i fix it?
enter image description here
enter image description here
Sample with response message as "Number of samples in transaction : 1, number of failing samples : 0" is for the "Transaction Controller" while the other is the actual request with response.
Select the "Generate parent sample" checkbox in the Transaction controller and you will be able to see the desired results.
Transaction Controller will always club the response times for the underlying Http requests. If you don't want to see this in results use "Simple Controller" instead.
Look into "Sampler Result" tab of the View Results Tree listener:
If you see one of HTTP status codes 3xx it means that you're being redirected so it's absolutely normal to see blank response if this is the case of redirection
You can control the behaviour of the JMeter when it comes to handling redirect responses by playing with Redirect automatically and Follow Redirects checkboxes in the HTTP Request sampler:
However you need to remember that you don't "need only 1 request", you need exactly the same number of requests like real browser sends so inspect how many requests are being sent by the real browser using your favourite browser developer tools and ensure that JMeter sends the same amount of requests and they have the same nature

Correct HTTP status code for PUT/POST method that does not update the document

I have a HTTP PUT/POST method to update a document in the database. However, in certain conditions (for example, the input transaction timestamp is less than the timestamp on the document), the PUT/POST method does not apply the update. What is the appropriate HTTP status code to return in such cases, to notify the caller that the update did not happen?
Look at the answer here
Ideally, you should return a 400 status code (bad request) with a message indicating why the request failed. This allows anyone using your API to understand why the request was not successful.

HTTP GET vs POST for Idempotent Reporting

I'm building a web-based reporting tool that queries but does not change large amounts of data.
In order to verify the reporting query, I am using a form for input validation.
I know the following about HTTP GET:
It should be used for idempotent requests
Repeated requests may be cached by the browser
What about the following situations?
The data being reported changes every minute and must not be cached?
The query string is very large and greater than the 2000 character URL limit?
I know I can easily just use POST and "break the rules", but are there definitive situations in which POST is recommended for idempotent requests?
Also, I'm submitting the form via AJAX and the framework is Python/Django, but I don't think that should change anything.
I think that using POST for this sort situation is acceptable. Citing the HTTP 1.1 RFC
The action performed by the POST method might not result in a
resource that can be identified by a URI. In this case, either 200
(OK) or 204 (No Content) is the appropriate response status,
depending on whether or not the response includes an entity that
describes the result.
In your case a "search result" resource is created on the server which adheres to the HTTP POST request specification. You can either opt to return the result resource as the response or as a separate URI to the just created resource and may be deleted as the result resource is no longer necessary after one minute's time(i.e as you said data changes every one minute).
The data being reported changes every minute
Every time you make a request, it is going to create a new resource based on your above statement.
Additionally you can return 201 status and a URL to retrieve the search result resource but I m not sure if you want this sort of behavior but I just provided as a side note.
Second part of your first question says results must not be cached. Well this is something you configure on the server to return necessary HTTP headers to force intermediary proxies and clients to not cache the result, for example, with If-Modified-Since, Cache-control etc.
Your second question is already answered as you have to use POST request instead of GET request due to the URL character limit.

Resources