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

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.

Related

Jmeter command line option issue

I am running a load test using jmeter command line and saving the result into csv file using -l command line option. After the test is completed, i see the data in the csv and while i upload it to a view result tree and try to check the failure response data in the response section, i dont see any response data noted in there. Is there something am missing here?
i have the following command
<path to jmeter bat> -n -t <jmx loc> -l <loc of result.csv> -j <path to jmeterlog> -Gparam1 -Gparam2 -Gparam3 -Gjmeter.save.saveservice.output_format=csv -Gjmeter.save.saveservice.output_format=csv -Gjmeter.save.saveservice.assertion_results_failure_message=true -Gjmeter.save.saveservice.data_type=true -Gjmeter.save.saveservice.label=true -Gjmeter.save.saveservice.response_message=true -Gjmeter.save.saveservice.successful=true -Gjmeter.save.saveservice.thread_name=true -Gjmeter.save.saveservice.time=true -Gjmeter.save.saveservice.response_message=true -Gjmeter.save.saveservice.successful=true -Gjmeter.save.saveservice.thread_name=true -Gjmeter.save.saveservice.time=true -Gjmeter.save.saveservice.connect_time=true -Gjmeter.save.saveservice.assertions=true -Gjmeter.save.saveservice.latency=true -Gjmeter.save.saveservice.connect_time=true -Gjmeter.save.saveservice.thread_counts=true -Gjmeter.save.saveservice.response_data=true -Gjmeter.save.saveservice.response_data.on_error=true -Gjmeter.save.saveservice.response_message=true -Gjmeter.save.saveservice.samplerData=true -Gjmeter.save.saveservice.requestHeaders=true -e -o <Reportpath>
By default JMeter uses CSV format for saving test metrics
CSV format is not suitable for storing response data due to eventual delimiters and line breaks. Moreover as per Reducing resource requirements chapter it's not recommended to store response data.
If you really need to save response data you need to switch JMeter's .jtl file format to XML and instruct JMeter to store it, it's controllable via the following properties:
jmeter.save.saveservice.output_format - defaulting to csv
jmeter.save.saveservice.response_data - defaulting to false
So you need to amend your command line to override these properties like:
<path to jmeter bat> -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.response_data=true ......
in order to make the changes permanent add the corresponding lines to user.properties file
More information:
Results file configuration
Configuring JMeter
Apache JMeter Properties Customization Guide
Another option is adding a separate Listener like Simple Data Writer and configure it to save response data into a separate file:

how can I use different CSVs for my JMeter script on different instance

We have 20 worker on AWS and I want to parameterized CSV file name for each instance Please help
I have divided my CSV in to number of Load generator hosts
$ wc -l "youroriginalcsv.csv" /* this will return number of total rows in csv*/
$ split -l "count of above query"/"number of hosts" "youroriginalcsv.csv" /* this will split CSV with file name as xaa, xab ... */
Transfer each unique CSV to all available hosts
$ scp xaa host1_user#host1_ip:/csvpath/csvfile.csv
$ scp xab host2_user#host2_ip:/csvpath/csvfile.csv
$ scp xaz hostN_user#hostN_ip:/csvpath/csvfile.csv
Now I want to use specific file name for specific host
What do you mean by "specific file name for specific host"? Your CSV files are all named csvfile.csv so it's sufficient to specify /csvpath/csvfile.csv in the CSV Data Set Config and each JMeter slave will pick up its own file containing partial data from the "big" CSV file.
If you want to use different names for CSV files depending on the machine IP address or DNS hostname - go for combination of If Controller with __machineName() or __machineIP() function
Also if you don't want the same data to be re-used by different JMeter slaves you can consider using Redis Data Set Config or HTTP Simple Table Server, this way you won't have to "split" and "copy" CSV files and will be able to centrally manage your test data from a single location

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

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

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

Resources