I have a problem with jmeter regular expressions extractor.
I'm using magento jmeter stress test. https://github.com/magento/magento-performance-toolkit/tree/master/1.14
Problem is in next part. When i put category url and key in settings, jmeter gives me next errors:
Assertion error: false
Assertion failure: true
Assertion failure message: Response was null
This is regular expression extractor:
<a href="http://${host}${base_path}(index.php/)?([a-z0-9-]+)${url_suffix}" class="level
This if from responce assertion:
^[a-z0-9-]+$
Example of url:
http://web.stresstest.com/index.php/my-class.html
The error you're getting is due to a Null response , meaning you didn't get a checkable response.
Could you show the Sampler details and in View Results Tree the request and response ?
Related
This code doesn't work
sam.attemptsTo(
Get.resource("/byName/{search_text}").with(request -> request.headers(header))
.with(request -> request.pathParam("search_text",search_item))
);
But below code works fine
sam.attemptsTo(
Get.resource("/byName/Apple").with(request -> request.headers(header))
);
The response status code is 400 in case of using both the 'request.header' and 'request.pathParam' but response in case of sending only then header I get 200 Ok status response code.
The server was returning a 500 error whenever there was a non matching /unavailable data in the back-end. So there was nothing wrong with code syntax or semantic. The parameter was the issue.
I am using an RSS feed generated by our test application to verify if there are any broken links on our website.
When I use these URLs in the HTTP sampler after some pre-processing (to split the URL to extract protocol, host, domain), most of the URL's are working just fine but I am facing issues in some random cases as explained below.
for example: below mentioned URLs throw URI exception. The separator between the highlighted text in these URLs mentioned below does not seem to a normal hyphen. It's some special character which I guess needs special handling.
Failed URL from the feed
https://abc.xyz.com/article/worksheet-development-planning—manager-preparation-10200/download/
https://abc.xyz.com/article/worksheet-development-planning—worker-preparation-10201/download/
JMeter Result from Assertion Listener
See link below for JMeter Result from Assertion Listener
URL gets encoded with some unexpected characters
You're right, this — symbol needs to be URL-encoded, to wit your URL path should look like
article%252Fworksheet-development-planning%25E2%2580%2594manager-preparation-10200%252Fdownload%252F
JMeter provides __urlencode() function which can perform URL-encoding of the passed parameter on the fly so you can use it directly in the "Path" field of the HTTP Request sampler like:
${__urlencode(/article/worksheet-development-planning—manager-preparation-10200/download/)}
Check out Apache JMeter Functions - An Introduction article to learn more about JMeter Functions concept.
I am working on REST project using jersey. On success I am returning 200 code along with the json response for particular request. I know there are may different classifications of error codes, like server error which start with 500, client error which start with 400 etc. My question is suppose we are subtracting some value in database for example count, for example count in database is 5 and request comes to subtract 3, it is valid and i will send request but my business rule states that count cannot be less than zero, so if request comes 6, i cannot subtract that , so in that case should i actually send status code as 200 and send error information is json respose {"errorCode" : "1","errorMessage":""} so i should send different HTTP status code like 5## that there is server problem or 4## saying bad request.
Can anyone please suggest me good (in the sense which is restful and follow all standars) REST project on github which I can refer.
If any error occurs during request processing you should never send a 2XX status code. Why? Because 2XX indicates successful processing which in this particular situation did not happen.
When you send a value to be subtracted from another value in DB and the assumption is that the result can't be lower than 0 you should reply with 409 Conflict HTTP status code and clarification in a response body stating e.g.:
The request can't be completed since the result value will be lower than 0.
It would be 400 Bad Request if null e.g. is sent instead of a number.
In the particular use case, you mentioned, you should return 400 as status code (bad request). errorCode in the json is your business domain, so you can use what you want ( Also, take a look at JSend standard for sending the http "error status" in the response https://labs.omniti.com/labs/jsend )
You're exactly right: you should send an HTTP "400" for a client error, a "500" for a server error, etc; along with a specific error message.
You may or may not want more granular HTTP status codes (for example, "403" for client authentication failed, otherwise "400" for other client-related errors).
Are are two good lists you can use for guidance:
Common MS-Azure REST Error Codes
HTTP Status Codes
NOTE:
There is no "standard" per se. The two links I gave above are useful "examples". The "official" IETF RFC for HTTP 1.1 Error codes is RFC 2616:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
In order to send http request to dynamic urls based on message headers...
I am trying to set the url value from Message header as follows:
<int-http:outbound-gateway id="httpOutboundGateway" request-channel="fromMyQueue"
url="{outboundGatewayUrl}" reply-channel="nullChannel"
http-method="POST" expected-response-type="java.lang.String" charset="UTF-8">
<int-http:uri-variable name="outboundGatewayUrl" expression="headers['X-CUSTOM-HTTP-REQUEST-URL']" />
But this is not working.
Apparently {outboundGatewayUrl} value is not being replaced at all.
This works if i replace the {outboundGatewayUrl} with actual URL.
Error Message:
Caused by:
org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [{outboundGatewayUrl}]...
Caused by:<br> java.lang.IllegalArgumentException: URI is not absolute
at java.net.URI.toURL(URI.java:1080)
at org.springframework.http.client.SimpleClientHttpRequestFactory.createRequest(SimpleClientHttpRequestFactory.java:109)
What am i missing here?
It looks like header X-CUSTOM-HTTP-REQUEST-URL doesn't exist in the message.
You will get that error (URI is not absolute) if the expression returns null (i.e. if the header doesn't exist).
I just ran a test and it worked fine for me with a proper header; if you believe the header is correct, you should break down the problem; for example by using a literal expression first...
<int-http:uri-variable name="outboundGatewayUrl" expression="'http://foo/bar'" />
The error message is, perhaps somewhat misleading:
Caused by:
org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [{outboundGatewayUrl}]...
because it implies the url wasn't expanded. The problem is the expansion is done inside the RestTemplate and the adapter doesn't have access to it.
I think you are missing a $ sign before your {outboundGatewayUrl} and consequently it is not being expanded by SEL. This is also suggested in the error message.
How can I see an error in JMeter?
In other words, if a test fails, How is it possible to see the page returned with the error ?
In our application we have a custom error page displaying a certain message. In JMeter we added a Response Assertion to the TestPlan (Add > Assertions > Response Assertion). We configured this assertion to have a pattern checking for this message (e.g. check for "error occurred" or whatever your error page shows).
Then we added a View Results Tree to the Thread Group (Add > Listener > View Results Tree) and configured it to display the errors only (check Log/Display only Errors). This result tree now captures all error pages along with their requests.
Depending on how you set up your test, you will most likely get a 404, 401 or 500 error code from your server.
You can then use the access logs of the server (not jMeter) to see which page it was that returned the error.