Jmeter - How to capture curl manpage parameters for http request - jmeter

I am trying to create a report in Jmeter where I am fetching a file from URL and in report I need to capture following information -
DNS resolution (time_namelookup)
Connect (time_connect)
TLS handshake (time_appconnect)
HTTP request start (time_pretransfer)
HTTP response start (time_starttransfer)
HTTP response completed (time_total)
I am able to capture these using following command from my Mac's terminal.
curl -w "#curl-format.txt" -o /dev/null -s "https:///large5-1663346153.bmp"
here's the content of curl-format.txt file
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n

As per JMeter Glossary JMeter can report the following metrics:
Connect time
Latency (time to first byte)
Elapsed time (time to last byte)
The only way to get the metrics you're looking for in JMeter is executing the curl command via OS Process Sampler or JSR223 Sampler and get the values from the response using suitable Post-Processors

Related

JMeter Non-GUI mode (Command line) execution - Tidying up

I'm executing Jmeter from command line using following command
!JMeter -Jjmeter.save.saveservice.samplerData=true -Jjmeter.save.saveservice.response_data=true -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.responseHeaders=true -Jjmeter.save.saveservice.requestHeaders=true -Jsummariser.out=false -n -t .jmx -l JmeterReports\TestReport.xml -j JmeterReports\jmeter.log
At the end of the run, I get a tidying up message and it takes 50 mins. Any hint on how to avoid this. it impacts my testing time.
00:08:42.083 login ticket value is :: LT-1418054-HsUfB5qYlXKKhrnJGGcoGeCeQtTf5
00:59:51.971 Tidying up ... # Tue Mar 22 12:30:26 CET 2022 (1647948626380)
00:59:51.971 ... end of run
First of all consider disabling all these Results File Configuration overrides as storing all requests and responses data into the .jtl file for one hour test causes massive disk IO, moreover writing XML is more resource intensive process than default CSV output
If the problem is still there take a thread dump and inspect what the threads are doing and which are stuck or waiting
Monitor the JVM metrics using JVisualVM or equivalent, it might be the case JVM does excessive garbage collection due to low heap space or something like this
More information:
Reducing resource requirements
9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure

Why jmeter generate other requests and put a number for them

I have a script, one of the requests in the script is: redireccion.html, but when I generate the HTML Dashboard report I see:
redireccion.html-0, redireccion.html-1, redireccion.html-2
Why those requests are generated by Jmeter?
HTML Dashboard Report Graph
This happens when your first request i.e. redireccion.html encounters a HTTP Redirect, i.e. gets a Redirection Message
JMeter stores all these redirects as sub-results
If you don't want these sub-results to be present in the HTML Reporting Dashboard - you can run your test providing jmeter.save.saveservice.subresults property with the value of false like:
jmeter -Jjmeter.save.saveservice.subresults=false -n -t test.jmx -l result.jtl -e -o dashboard
In order to make the change permanent - just add the next line to user.properties file:
jmeter.save.saveservice.subresults=false
More information: Apache JMeter Properties Customization Guide

parametrize to csv file url in JMeter

I configured this in following steps: in this moment I prepare following csv file:
protocol $url
${dev} http://10.200.XXX.XX/{$url}
${trial} trial.mycompany.io{$url}
${product} product.mycompany.io{$url}
then I add to my Test Plan -> Config element - CSV Data Set Config, and then I add Switch Controller,
and I have WebSocket Samplers by Peter Doornbosch and I dont have HTTP Samplers and WebSocket Samplers;
In Switch Controller I add HTTP Request and WebSocket request-response Sampler. In HTTP request I set
protocol:http,
server name or IP: localhost,
port number 8080.
HTTP request method POST,
path: ${URL}, and
parameters Add: Name: Value ${protocol} ws://{$URL} ${protocol} http://{$URL}
and in WebSocket request-response Sampler I set: use existing connection
do I correctly set the parameterization of the url variable, do I do something wrong, how to correct it, what to change?
Your understanding of parameterization in JMeter seems to be vague, as far as I get your idea your CSV file should look like:
protocol, url
http, some-http-host/some-http-path
ws, some-websocket-host/some-websocket-path
http, some-http-host/some-other-http-path
etc.
Then you should be able to use it in the CSV Data Set Config as
Switch Controller will allow you to choose either HTTP Request or WebSocket samplers depending on ${protocol} variable value so when ${protocol} is equal to http - only children of the http Simple Controller will be executed and ws will not be run and vice versa, when ${protocol} is ws - only ws samplers are being kicked off and http are not executed.
And in Samplers you can refer the values from the CSV file as ${protocol} and ${url} correspondingly
Open cmd prompt, change the path to the jmeter bin folder.
Now write jmeter command to run:
jmeter -n -t testing.jmx
If you want to log the results then use -l with a file name for output, So the command will be changed to
jmeter -n -t testing.jmx -l results.jtl

Curl taking too long to send https request using command line

I have implemented one shall script which send an https request to proxy with authorization header using GET request.
Here is my command :
curl -s -o /dev/null -w "%{http_code}" -X GET -H "Authorization: 123456:admin05" "https://www.mywebpage/api/request/india/?ID=123456&Number=9456123789&Code=01"
It takes around 12 second to wait and then sending request to proxy and revert back with some code like 200,400,500 etc..
Is it possible to reduce time and make it faster using CURL ?
Please advice me for such a case.
Thanks.
Use option -v or --verbose along with --trace-time
It gives details of actions begin taken along with timings.
Includes DNS resolution, SSL handshake, etc. Line starting with '>' means header/body being sent, '<' means being received.
Based on difference between operation sequence - you can decipher whether server is taking time to respond (time between request and response) or network latency or bandwidth(response taking) time.

How do I get a server's response time?

How can I get a server response time with ruby?
Im using Net::HTTP.get_response(URI.parse(url)) to the response code and response time of the URL. Actually my code is:
start_time = Time.now
#req = Net::HTTP.get_response(URI.parse(url))
end_time = (Time.now - start_time) * 1000
puts ("%.2f" % end_time + "ms")
Is working perfectly, but I'm getting too high response times, e.g.: Twitter.com (630.52ms). If I try to ping twitter.com, I'm getting 70/120ms of response.
Is this the best way to calculate the response time of this server?
What you implemented does not show the server response time, it shows:
the time spent in ruby to send the request
the network time of the request
the server's response time
the network time of the response
the time spent in ruby to process the response
If you need to see only the time that the server took to process the request you need to do it with another way. You can use the HTTP response headers. The date header in particular can help you with that.
Ruby timings are included in your version of code as #xlembouras said.
I would suggest to use curl for what you are looking for:
response_time_total = `curl -w \"%{time_total}\" google.com -o /dev/null -s`
You can try it out in terminal:
curl -w \"%{time_total}\n\" google.com -o /dev/null -s
There are different metrics you can get like time_namelookup, time_connect, time_starttransfer, time_redirect, etc. Example:
response_times = `curl -w \"%{time_connect}:%{time_starttransfer}:%{time_total}\" google.com -o /dev/null -s`
time_connect, time_starttransfer, time_total = response_times.split(':')
All available metrics and detailed information can be found at the cURL manpage
Refs
How do I measure request and response times at once using cURL?

Resources