jmeter command line option doesnt pick my params - jmeter

Why my command below doesn't pick the values I give at runtime rather it takes from my JMeter test plan itself where I defined with option ${__P(param1,value)}
<path to jmeter bat> -n -t <jmx loc> -l <loc of result.csv> -j <path to jmeterlog> -Gparam1=paramval1 -Gparam2=paramval2 -Gparam3=paramval3 -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
I am running this from jenkins. Why it is not picking up my parameters?

-G is used for distributed testing/Remote JMeter servers
defines a JMeter property to be sent to all remote servers.
Use -J instead to define JMeter property
-J[prop_name]=[value]
defines a local JMeter property.

You need to use -J command-line argument, -G is for sending the properties to JMeter Slaves in case of Distributed testing.
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Full list of command-line options
Apache JMeter Properties Customization Guide

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:

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

JMeter distributed testing and command line parameters

I have been using JMeter parameters to specify test attributes like testduration, rampup period etc for load test. I specify these parameters in shell script and it looks like this -
JMETER_PATH="/home/<user>/apache-jmeter-2.13/bin/jmeter.sh"
${JMETER_PATH} \
-Jjmeter.save.saveservice.output_format=csv \
-Jjmeter.save.saveservice.response_data.on_error=true \
-Jjmeter.save.saveservice.print_field_names=true \
-JCUSTOMERS_THREADS=1 \
-JGTI_THREADS=1 \
// Some more properties
Everything goes good here.
Now I added distributed testing and modified above script with JMeter Server related info. Hence new script looks as -
JMETER_PATH="/home/<user>/apache-jmeter-2.13/bin/jmeter.sh"
${JMETER_PATH} \
-Jjmeter.save.saveservice.output_format=csv \
-Jjmeter.save.saveservice.response_data.on_error=true \
-Jjmeter.save.saveservice.print_field_names=true \
-Jsample_variables=counter,accessToken \
-JCUSTOMERS_THREADS=1 \
-JGTI_THREADS=1 \
// Some more properties
-n \
-R 127.0.0.1:24001,127.0.0.1:24002,127.0.0.1:24003,127.0.0.1:24004,127.0.0.1:24005,127.0.0.1:24006,127.0.0.1:24007,127.0.0.1:24008,127.0.0.1:24009,12$
-Djava.rmi.server.hostname=127.0.0.1 \
Distributed test runs well but test does not take parameters specified in script above into consideration rather it takes the default value from JMeter test plan -
Did I mess up any configuration?
Use -G instead of -J for properties to be sent to remote machines as well. -J is local only.
-D[prop_name]=[value] - defines a java system property value.
-J[prop name]=[value] - defines a local JMeter property.
-G[prop name]=[value] - defines a JMeter property to be sent to all remote servers.
-G[propertyfile] - defines a file containing JMeter properties to be sent to all remote servers.
From here
Replace -J with -G, for more details go to link below or can see the image atached.
If you want to run your load test in distributed mode refer to URL click here
And search for Server Mode (1.4.5)

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]

create summany report in jmeter from command line

I am using Jmeter version : 2.10. I test has couple of Http samplers. When i run the test from command line
jmeter.bat -n -t "C:\Jmeter Projects\TestSuite.jmx" -l "C:\Jmeter Projects\testResult.xml"
the result of the test creates "testResult.xml" but when i open it the data is in cvs format
1384844043490,1527,HTTP Request-1,200,OK,Thread Group 1-1,text,true,2776,1527
1384844045046,350,HTTP Request-2,200,OK,Thread Group 1-1,text,true,395,350
1384844045411,4890,HTTP Request-3,200,OK,Thread Group 1-1,text,true,977530,4888
1384844050304,286,HTTP Request-5 ,200,OK,Thread Group 1-1,text,true,4091,28
There is no header. I do not mind csv format if i can get the table header or the .jtl format.
I think it was since JMeter 2.8 that the default JTL format is CSV as opposed to XML. I didn't try this myself, but this should work for you:
-Jjmeter.save.saveservice.output_format=xml
Just make the changes as suggested by Alon and execute your test plan. Saving report as .jtl file.
jmeter.bat -n -t "C:\Jmeter Projects\TestSuite.jmx" -l "C:\Jmeter Projects\testResult.jtl"
Then using JMeter plugins generate the kind of report you wish for.

Resources