parametrize to csv file url in JMeter - 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

Related

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

Jmeter - Testing with 100 User while reading Links from CSV file

I just started using Jmeter recently.
What I want:
I want to run a test of 100 users by getting links from CSV file.
How I am doing:
I created a Test-Plan, Added Thread Group, CSV Data Config (Child to Thread group), HTTP Request.
Given Values:
HTTP Request Default: Url Address (Tried with both HTTP & without HTTP in protocol section)
Thread Group: User: 100
Loop: Forever
CSV Data Set Config: File Name (Full Path, the file is not in bin folder)
Variable Name: Path
Recycle on EOF: False
Stop Thread on EOF: True
HTTP Request: IP Address:
Path: ${Path}
CSV File:
Path
Link1
Link2
Link3
What I am getting: Well the test is executing but it executing all link only once (one User), it not going for 100 User
Note: I am running the TestPlan from Command Mode
Thanks for your Time
If you want each user to go through all links in the CSV file you need to amend Sharing Mode setting of the CSV Data Set Config to Current Thread
You can verify the behavior by adding __threadNum() function as request prefix/postfix

How do I make jmeter use the different hostname/port for different threads of same test plan

In my test scenario I have to test 2 urls with different host and port under same test plan. Is it possible to do so
You can make variable as property and send to jmeter script
Add to Test Plan In User define variables 2 rows:
baseUrl with Value ${__P(baseUrl,localhost)}
port with Value ${__P(port,8080)}
localhost and 8080 are default values you can change it
and when you execute add the values you want e.g.:
jmeterw.cmd ... -JbaseUrl=192.168.0.33 -Jport=80
Define your host and port combinations in a CSV endpoints.csv file like:
somehost,someport
someotherhost, someotherport
and put the CSV file to the "bin" folder of your JMeter installation
Add CSV Data Set Config to your test plan and configure it like:
Set HTTP Request sampler to use ${host} and ${port} variables defined via the CSV Data Set Config
That's it, on each iteration (or virtual user hit) the next line will be picked up from the endpoints.csv file.
See Using CSV DATA SET CONFIG article for more information on parameterising JMeter tests using CSV files.

Details about which user from csv failed response assertion in Jmeter

I am using JMeter to webUI performance testing. I have a list of users in csv with passwords. I am using response assertion to check failed password scenario.
How to record which user from csv is failed?
I would recommend going for Sample Variables property. For example, if you defined a ${username} which holds the user name from the CSV you can get it added to JMeter .jtl results file by adding the next line to user.properties file:
sample_variables=username
If you need to store more variables - provide them separated by commas:
sample_variables=username,password
Remember that:
JMeter restart is required to pick the property up
You can pass it via -J command line argument as well like:
jmeter -Jsample_variables=username,password -n -t test.jmx -l results.jtl
See Apache JMeter Properties Customization Guide for more information on different JMeter properties types and ways of working with them

How to add "Send Parameters With the Request" using java in jmeter

I am new to jmeter and i want to execute jmeter in non-gui fashion using java code.
When testing on the endpoints i would like to pass the "Send Parameters with the Request" via java code. So i have tried sending the data as follows
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setProtocol("http");
httpSampler.setDomain(hostip);
httpSampler.setPort(8080);
httpSampler.setPath(endpointpath);
httpSampler.setMethod("POST");
HTTPArgument httpArgument = new HTTPArgument();
httpArgument.setValue("[{ \"firstname\": "", \"name\": \"Venkat\"}]");
No Error came. The request was not added to the DB
Can some one suggest and provide a sample code to add the post request body using java?
httpSampler has no arguments associated. Basically you are just sending a http request without any argument.
You might have to use addTestElement / setArgument method to associate the parameters to the httpsampler.
httpSampler.setMethod("POST");
HTTPArgument httpArgument = new HTTPArgument();
httpArgument.setValue("[{ \"firstname\": \"venkatachalam\", \"name\": \"Venkata\"}]");
httpSampler.addTestElement(httpArgument);
Just curious - why are you creating your JMeter test using java by the way?
To run your JMeter test in non gui mode, use below command & options. (assuming you have %JMETER_HOME%/bin is added to your PATH variable)
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
-n [This specifies JMeter is to run in non-gui mode]
-t [name of JMX file that contains the Test Plan]
-l [name of JTL file to log sample results to]
-j [name of JMeter run log file].
Besides these options, JMeter has several other parameters that can be used for running in non-GUI mode.
-R [list of remote servers] Run the test in the specified remote servers
-H [proxy server hostname or ip address]
-P [proxy server port]

Resources