JMETER Performance Testing - Dynamic Payload - performance

While doing performance testing via JMETER, I encountered one usecase where the POST request call is taking the dynamic data from the website. So in that case when we run our script it fails as that data is no more available on the website.
Payload looks like given below. It is a POST CALL and the payload is changing everytime.
{"marketId":"U-16662943","price":{"up":98,"down":100,"dec":"1.98"},"side":"HOME","line":0,"selectionids":["W2-1"]}
Could anyone suggest how we can make this payload dynamic when we create a script in JMETER?

I can think of 3 possible options:
Duplicate data is not allowed. If this is the case you can use JMeter Functions like __Random(), __RandomString(), __counter() and so on
The data you're sending needs to be aligned with the data in the application somehow, in this case you can use JDBC PreProcessor in order to build a proper request body basing on the data from the application under test database
The data is present in previous response. In that case it's a matter of simple correlation, the dynamic values should be extracted from the previous response using suitable Post-Processors and variables needs to be sent instead of hard-coded parameters

Related

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')
}

How do i view all transactions in JMeter Report

I am running performance test using JMeter 5.0 and then at the end of the test a HTML report is generated. I would like to know if there is anyway to view actual request with the endpoint it served what was the response and ability to view all requests in HTML report. I know JMeter has something called view result tree and it provides most of the information i need but i am not sure how to display result tree or something similar in HTML report.
View results is tree is rather resource intensive listener so you want to use it with caution. Typically you want to filter and display only errors so you can analyse them.
If you would like HTML reports then you can use a modular extension for JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.
You can generate the HTML report using menu item Tools → Generate HTML report:
This page explains different configs and options to tweak and tune the report generation.
Hope this helps.
As of current JMeter version 5.2
JMeter can only generate the HTML Reporting Dashboard from the CSV files
The dashboard generator is a modular extension of JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.
There is no possibility to store response data in CSV mode:
response_data is currently not supported for CSV output
So there is no easy way to implement your issue unless you use i.e. Flexible File Writer to store request/response data into a separate file and modify report-template (you will need to learn FreeMarker) to display the information you need.
use this command, -g .jtl file -o reportlocationpath, you will get nicely generated html report along lots of graphs as shown below:
I would like to know if there is anyway to view actual request with
the endpoint it served
My guess is that you already have all the metrics required for each request but would like to see individual request payload and the response. Just in case this guess is wrong, since you already have the report and are still not able to see the individual requests, I am assuming that you have checked on "Generate Parent Sample" across each Transaction Controller. Uncheck that and you should be able to see individual request level response time, 90th percentile etc. Of course you will have to re-run the test to get these individual request level values
However, if you want to literally see the request payload and response in HTML report, there is no way we can do that. Only View Results Tree can do that for you within the scope of JMeter's GUI and not outside of this.
what was the response
As mentioned above, as of today, there is no possibility to see the response of individual requests along with their payload in the HTML report and this is for a good reason. We do not require the requests/responses while we run a load test in our HTML report. It is necessary for debugging and until the script is ready for execution. But post that, we wouldn't require the responses. If you still want to ensure that the correct responses are received, you can always add assertions (although best practice is not to add too many assertions in a load test)
Just an example of why HTML report across any load testing tool will not show responses of a request -
Assume there is a load test of 10K users for 10 iterations and the Thread Group has around 10 transactions each having an average of 7 requests, there is going to be 7 million responses to go through. Having this in a HTML report is not just tedious but literally doesn't make sense.
I know JMeter has something called view result tree and it provides
most of the information i need
The View Results Tree is the holy grail for debugging and for ensuring if requests and response are appropriate during script creation stage.
I think your primary concern is to ensure the correctness of the responses rather than get the whole response of each request. In that case, as I had mentioned above, you can always use assertions. Several other custom alternatives include capturing specific parts of response and writing them to a file or something like that by leveraging JSR223 sampler or using the if controller to validate. Of course this is going to add some overhead on JMeter depending on the type of test and script that you are going to execute
but i am not sure how to display result tree or something similar in
HTML report
But if you still insist on having something in HTML and if I have failed to convince as to why this is something that one must not pursue, you can capture the entire response of each request in a variable through Regex Extractor and write them to a file with HTML tags in it. However, you will have to implement logic to collate responses and organize them for your need.
One more way would be to have the JTL save all data and modify this up in some text editor and beautify it with HTML
FYI on JTL and its configuration
Hope this helps!

JMeter encoding issue on "application/soap+msbin1"

Working on JMeter and trying to send the soap request to server and shows the below error msg.
Error Msg:- Cannot process the message because the content type 'application/soap+msbin1' was not the expected type 'application/xml; charset=utf-8'.
We need help to encode XML to 'application/soap+msbin1' format.
Bit late to the party, but I encountered a similar issue - I had a template for SOAP request which uses embedded-binary XML (xop:Include cid="...") and had to scratch my head to figure out how to do that with the stock HTTP Request.
The answer: you can't - not in a simple way. To solve the issue, I ended up customizing JMeter (I also looked at HTTPRawRequest as well but it doesn't seem to support https and I would have to rewrite a lot of the test script to use that). Since HTTP request does 99% of the job, the quickest way to support binary data is to change the source code to handle binary data.
The main issues are two: the Function interface in JMeter is designed around returning String, not byte[]. So already __FileToString() (which I used to read an external binary file to use) encodes the content of the file . Secondly, the HTTP Request Sampler and HTTPHC4Impl itself (excluding the "upload file" bit) encodes the parts of the HTTP request before sending it over to the wire.
Changing that implied changes in Function, AbstractFunction, CompoundVariable and create a new function class FileToStringBinary which encode the binary data in a way that it can be decoded after (by changes made to HTTPHC4Impl).
If I have the time I'll find someplace where to post the idea and the source (can't submit to JMeter because my update to HTTPHC4Impl is limited to handle the specific requests I need to test, where the embedded binary is in a multipart/related part, and I have no time or inclination to handle the general cases), but if you still need help to make it work, drop a line.

How to implement a recursive call inside jmeter?

I need to simulate a test scenario where my application sends a request with 100s of queries. On the back-end, this request is broken down into requests containing a single query each. So a request from Jmeter with 100 queries will become 100 requests on the back-end. Now - the response from the back-end could either contain the requested data for each of those queries OR contain a unique queryID. Sending back a queryID is server's way of telling that this query is still running. For example, if Jmeter sends a request with 100 queries, it might get back data for 80 and 20 unique queryIDs. So my application under test makes a callback request with those 20 queryIDs every 15 seconds until it gets back the requested data or timeout.
Here is what I have implemented so far.
-main_request_with_100_queries
--XPath_extractor_to_extract_any_queryIDs_found
-if_controller_to_check_if_queryID_MatchNr_is_greater_than_0
--15_second_pause
--beanshell_preprocessor_to_create_the_request_body_with_all_queryIDs
--callback_request_with_queryIDs
What I want to implement is to have another XPath extractor for my callback_request and if any queryIDs are found, then go back to the if_controller
I'm trying to make this work by using a module_controller but so far no luck. Has anyone ever implemented something like this? Can anyone suggest some ideas?
You can use While Controller to keep making the request until there is a queryID in the response.
While Controller [ "${querid.present}"=="true" ]
HTTP Request
Pre Processor [to_create_the_request_body_with_all_queryIDs]
Post Processor [to check for query ID. if no query id - change querid.present to false ]
If possible, try to use Regular Expression Extractor. xpath is very slow and might affect your performance of the script. Check here for more details.
Creating modular test script in JMeter.

Correlation in general for LoadRunner

In general could anything coming from the server be correlated? All unique values being recorded could be correlated as long as it is created server side and passed in the server response?
Spesific for correlating values in the http headers returned from the server one would use "scope=headers" right?
What kind of other values could "scope" have? I know of body, but are there others?
It is not possible to correlate values generated client side by i.e. a JavaScript?
Correlated values are returned from the server inside of the HTTP response stream. If you need a value from Javascript then you have a couple of paths
Convert your javascript function to the language of your virtual user (C, VB, Java, etc...)
Run truClient, which executes JavaScript as a full blown browser.

Resources