Parameterized file/folder path in Jmeter - jmeter

Is there any way to parameterized the folder/file path in Jmeter?
When the user uploading it to jenkins or sending to another user it will be very handy if that can be possible

If your test relies on external files (i.e. uses CSV Data Set Config or uploads files using HTTP Request sampler) the good practices is using relative paths, to wit not hard-coding the full path to the folder/file but rather using a relative path to the .jmx file, this way you will be able to transfer the script across machines, use it for distributed testing or in continuous integration servers without having to change anything
Any path can be set via JMeter Property using __P() function, this way you will be able to override the property value using -J command-line argument
If your test data represents a folder with multiple files you might be interested in Directory Listing Config plugin

Related

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

Jmeter Cross-Platform Path config issue

I am working on master-slave Jmeter configuration, my data set exist on each machine on a different path for (macOS, Windows).
I use a global data set to fetch data for multiple thread groups.
However, the variable/property can be different across platforms.
I also tried the JSR223 to check the, but still no luck. check out the below snapshot.
I am trying to make sure that once I ran my test from Master (Mac), it also run on Windows.
Any thoughts how to do that on multiple platform setup.
The best solution is placing your test data under the same path which will be relative to JMeter working directory, this way you will not have to change anything in your script.
If for some reason you cannot afford this you can add a JSR223 Sampler to your Test Plan and use the code like:
if (org.apache.commons.lang3.StringUtils.containsIgnoreCase(System.getProperty('os.name'), 'Windows')) {
vars.put('data-path', 'c:/windows/specific/path')
} else {
vars.put('data-path', '/macos/specific/path')
}
It will detect the operating system name in the runtime and you will be able to define an OS-specific paths using the above approach.
vars is a shorthand for JMeterVariables class instance, the above code defines ${data-path} JMeter Variable which you can use later on for specifying data files locations. See Top 8 JMeter Java Classes You Should Be Using with Groovy to learn more about JMeter API shortcuts exposed to JSR223 Test Elements

Relative path to jmeter target folder in Jmeter GUI

I want to save Jmeter aggregate report to project's target folder with timestamp,so that everytime I run the tests I get the new unique report, irrespective of OS.
I tried by providing this path /target/jmeter/results/aggReport.csv but it saved it in C:/target/jmeter/results/aggReport.csv Also there was no time stamp.
E.g. 100320182130aggReport.csv which is mmddyyyyhhmmaggReport.csv
This question is in continuation of soemthing I wanted to achieve here and suggested by Dmitri Jmeter: Test plan has two thread groups but it generated only 1 jtl report
I am using Maven, Java 8, Windows 7
Update:
I tried:
In case of JMeter test execution via Maven JMeter's working directory (or Java user.dir property) points to target/jmeter/bin folder so you need to construct the desired path relative to it
Your path starts with / which means it is absolute and points to root folder of the file system
You need to include __time() function into the resulting filename if you want the result to be prepended by the timestamp
Assuming all above your listener "Filename" field should look like:
../results/${__time(MMddyyyyhhmm,)}aggReport.csv
Check out Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on various ways of kicking off a JMeter test including using Maven plugin.

JMeter - Multiple users reading requests from a directory

I have a directory of XML files, and I wanted to configure Jmeter such a way that multiple users(threads) should be able to read the XML files(SOAP requests) concurrently (in a round-robin way or some other way) and submit them to Web Service Endpoint, which means I wanted them to share the input files.. for example if my directory contains 100 XML files then all of my configured users(threads) should share the load and jointly have to process the XML files. (Each user should not process all the 100 files independently).
Is there any way to test the above scenario?
Thanks,
Siva
I believe Directory Listing Config plugin would be the easiest option to use
Just provide path to the directory where your XML files live, configure the plugin according to your test scenario and that's it, you will be able to use just one HTTP Request sampler and refer the file name (or path) as ${filename} where required.
You can install Directory Listing Config plugin and keep it up-to-date via JMeter Plugins Manager.

In JMeter, can you specify variables to fill in for an HTTP Request Default?

I'd like to be able to read a value out of a CSV file, or more ideally a .properties file with JMeter, and then use it in multiple Test Plans in the HTTP Request Defaults as the Server Name or IP, and the Port Number/
I wanted to set it up that way so that for a folder of different Test Plans that can be run, and there can be a single point of modification for any of the tests that can be run. But the ${} variables don't seem to populate in the HTTP Request Defaults.
You can do this with user-defined properties. The values for those user-defined properties can be controlled from a file. In the following example, I am controlling the environment the script needs to run against by a user defined property called env.
And then, I am using it in the http request defaults. You can do this for any property that you want to

Resources