Jmeter setup specific parameters on different host - jmeter

My test plan use a parameter as startIndex.
In local case:
"thread pool 1" -> "Java Request" -> "Send Parameters With the Request" -> Add a parameter named startIndex,
and Create a config element - "User Defined variables", and give a parameter startIndex.
But how to give different startIndex parameters to each server,
for example:
serverA:"startIndex"=100, serverB:"startIndex"=200.

On each JMeter slave machine locate user.properties file under /bin folder of your JMeter installation
Add the following lines to this file:
on server 1: startIndex=100
on server 2: startIndex=200
Refer startIndex property value via __P() function as ${__P(startIndex,)} where required
Make sure you restart JMeter after user.properties file modification.
See Apache JMeter Properties Customization Guide for extended information on JMeter properties and ways of working with them

It is not a best practice to have create two variables having same names. If this situation is unavoidable then do not use 'user defined variables. Instead you can create the second variable under specific sampler, by using beanshell (vars.put) to create second variable. Not a tested technique but you can try.

Related

overwriting parameters in Azure Load Testing

When the parameters are passed via the 'CSV Data Set Config' in the jmeter script, do we have a way of over-writing the values in Azure Load Testing tool,
I have away of externalising the parameters in Jmeter as well, in azure load testing, but when I combine both the values are not over-written
I don't think you can overwrite the JMeter Variable. You can overwrite the value of a JMeter Property so if you use __P() function to define some value in the test you can use user.properties file to give the property its respective value.
At the same time it would be possible to override the default property value via -J command-line argument.
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide
If you have parameterization implemented via CSV files the only way of amending the values is changing the CSV file itself, in that case you can take a look at awk language and/or sed editor.

Dynamic value to JMS PTP fields in Jmeter

I have been trying for weeks now to find a way to handle jmeter script using only single thread group & pass connection variables dynamically by CSV file in which I'm failing terribly. I have multiple value in place of QueueConnection few test cases have message properties as well. I would like to find a way to eternalize is & use single thread group to achieve it.
Check the screenshot an example of variable which should take value dynamically from a file is what I'm expecting.
enter image description here
I don't think you will be able to use CSV file, you will have to go for JMeter Properties instead.
And in the JMS P2P Sampler you need to use __P() function to read the properties values
Something like:
The properties along with their respective values can be:
put into user.properties file like:
queueConnectionFactory=ConnectionFactory
passed via -J command-line arguments like
jmeter -JqueueConnectionFactory=ConnectionFactory
put into a separate .properties file, in this case you will need to "feed" this file to JMeter via -q command-line argument like:
jmeter -q /path/to/your/custom/JMS.properties -t test.jmx ...
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Full list of command-line options

How to pass properties files to Jmeter server in distributed setup

I have Jmeter distributed setup (One client and one server).
In single jmeter instance I'm using the below command to execute jmeter with a properties file that will pass the user defined variables to my test script
/apache-jmeter-5.3/bin/jmeter -p reco.properties -n -t Performance.jmx -l test2server.csv
When I tried to use the same command including the server configurations I noticed that the values defined in my "reco.properties" are not picked at the test execution.
Instead I need to pass all the variables with "-G" argument. Ex:
/apache-jmeter-5.3/bin/jmeter -GENV=test -n -t Performance.jmx -l test2server.csv
is it possible that I can pass all variables in a properties file for Jmeter Server as I do in the normal execution with "-p"?
Thank you
As per JMeter Documentation:
If the test uses any data files, note that these are not sent across by the client so make sure that these are available in the appropriate directory on each server. If necessary you can define different values for properties by editing the user.properties or system.properties files on each server.
So currently as per JMeter 5.4 this is not supported, you either need to pass the properties one-by-one like -Gprop1=value1 -Gprop2=value2 or to copy the .properties file to all the slave machines
The limitation can be also worked around via getting the properties from a dataabse using JDBC Request sampler or with plugins like HTTP Simple Table Server or Redis Data Set
If you do believe that the feature is essential you can try raising an enhancement request in JMeter Bugzilla

Is there any way to define testdata specific to the environments

Besides using the CSV config file and beanshell programming, is there any way to define the testdata specific to the environments?
Each environment varies different testdata(values) using same jmx script.
For example :Firstname,LastName,ProjectName so on..
You can have different properties in different environment.
You can have different or additional properties file
-p, --propfile
the jmeter property file to use
-q, --addprop
additional JMeter property file(s)
or override each property per environment using command line
-J[prop_name]=[value]
defines a local JMeter property.
The fastest and the easiest way is using JMeter Properties like:
In .jmx script define Firstname using __P() function like
${__P(Firstname)}
When you start JMeter pass this Firstname property value via -J command-line argument like:
jmeter -JFirstname=John
See Configuring JMeter User Manual chapter for more details.

Overriding jmeter.properties

Is it possible to re-read jmeter.properties without closing and restarting JMeter?
Maybe any additional class that will trigger this process?
Sometimes I need to play with a property's values, and it is not convenient to restart JMeter every time, so I'd like to automate this process.
There is no need to re-read jmeter properties from file - jmeter has enough built-in functionality to read/set values of properties.
At least the following below:
jmeter functions:
_setProperty(),
_property(),
__P;
props - JMeterProperties (class java.util.Properties) - to access from beanshell code;
Property Display.
Look also into the following for more info and examples:
Using JMeter properties
How to set a javascript value as a JMeter property
Jmeter Wiki

Resources