Using user defined variables in the path of a results file in JMeter - jmeter

I want to write a results CSV file in JMeter which contains a variable in path of the file I write.
E.g.
C:\\Users\\User1\\test-results\\${output}.csv
But I only seem to be able to use predefined variables like ${__time(ddMMyyHHmmss)}
Is there a way to use user defined variables in the path? I have successfully done this to find input files by defining the variable in the test plan node as a User Defined Variable.

I managed to use user defined variable in the path of result file using JMeter 2.9. REPORT is a user defined variable with value REPORT. It gives me file named REPORT.csv

In JMeter 3.1(?) (or Windows?) a double slash is required in the path.
I have used the following successfully:
c:\\jmeter\\results\\${testId}\MyReport.csv
c:\\jmeter\\results\\${testId}\MyReport.csv
c:\\jmeter\\results\\${__time(yyyyMMddHHmm)}\MyReport.csv
c:\\jmeter\\results\\${__time(yyyyMMddHHmm)}.csv
${testId} is a User Defined Variable configured in the Test Plan and set to ${__time(yyyyMMddHHmm)}

Related

Variable in library path with JMeter is not working

My JMeter plan config looks like this:
as you can see from the picture the mypath variable has a default value /somehwere which may change based on the machine that hosts JMeter.
So I added it as variable in the ${mypath}/bin below for Library.
However if I run a command like:
jmeter -n ... -Jmypath=/newpath/elsewhere
it is not working. Is there any way to put that path as variable?
You need to amend the variable using __P() function like:
${__P(mypath,/somepath)}
This way you will be able to override the value using -J command-line argument and if you don't provide the override value it will default to /somepath
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Overriding Properties Via The Command Line
I answer myself as the solution required is using the parameter -Juser.classpath=some_path which avoid the need to create an external parameter for that case.

Parametrize source folder directory or file path in JMeter

Is there any way to parameterize the CSV data file path or source directory path in JMeter?
There are at least 2 possibilities:
Via User Defined Variables like:
and then referring the variable in the CSV Data Set Config
Or via __P() function like:
the property value can be passed via -J command line argument or put into the user.properties file. See Overriding Properties Via The Command Line for more information.

JMeter SMTP Sampler - is it possible to use parameterization with in "attach files" option?

am using JMeter 4.0 and I have been trying to parameterize the filename in "Attach files" option with no success. I am required to use attachments of varying sizes and with each loop a random pdf file (from the set of files saved locally in d drive) to be attached with the email.
I am using a CSV data set config for parameterization and see no issues in using the parameters in Subject line of within the Message.
However, when used with the attach files option, the JMeter test fails to execute with FileNotFoundException as the variable name is substituted as such instead of the pdf filename. Is there a solution?
Error Message: java.io.FileNotFoundException: D:\Data_Jmeter\${AttachFile}.pdf (The system cannot find the file specified)
I cannot reproduce your problem using the following settings:
Where ${path} is set via User Defined Variables on Test Plan level and resolves into "bin" folder of my JMeter installation
The same situation for ${path} variable originating from the CSV Data Set Config
So I would recommend to double check if your ${AttachFile} variable is defined, you can do this using Debug Sampler and View Results Tree listener combination

Writing to a file named with variables in distributed JMeter testing

Okay I've been having an issue with writing results to folders in JMeter.
I have set 2 variables, one for the name of the test and one for the submit date. I want the reports to be written to the folder named with these two variables.
Here's the variables:
TestRun = "Name of test"
DateRun = $__{time(dd-MMM-yyyy HH.mm.ss)}
The path of the folder to be written to looks like this:
C:\Tests\TestEnvironment\Results\\${TestRun}${DateRun}\file.csv
When I run it on the master machine, it's fine. It saves to the correct file and folder path, and ends up looking something like this:
C:\Tests\TestEnvironment\Results\Test Run 1 - 08-May-2014 08.55.47\file.csv
However, when I run it on remote machines, it saves it literally as below:
C:\Tests\TestEnvironment\Results\${TestRun}${DateRun}\file.csv
So I end up with a folder named "${TestRun}${DateRun}"
Am I missing something blindingly obvious, or is this an actual JMeter issue?
Thanks!
As per JMeter help:
-G, --globalproperty <argument>=<value>
Define Global properties (sent to servers)
e.g. -Gport=123
or -Gglobal.properties
You need to use -G key so your variables could be distributed across remote clients.
so something like:
jmeter -r -n GTestRun=SomeName -GDateRun=SomeTime -t /path/to/your/plan
should help.
Alternatively you can create a .properties file and pass it to remote JMeter Engines via the same "-G" option.
I expect that if you want to use JMeter __time() function you'll need to wrap it with __eval, elsewise it will be treated as a string. Alternatively you can use operating system commands to retrieve current date and time.
See Apache JMeter Properties Customization Guide for more information on dealing with JMeter Properties.

Informatica Parameter File

Whenever I use the -lpf parameter with the pmcmd command, the workflow runs perfectly fine but when I add the same path in the Parameter FileName under Workflow 'Properties' and try to execute the workflow from the Workflow Manager, I get an error saying that parameter file is not found.
Now, the path which I am giving for '-lpf' is :
/apps/config/informatica/param.txt.
I don't understand why it works when I am overriding the parameter file name, whereas it doesn't work when I add it in the workflow properties (the file is not found).
By default, is any Informatica Environment variable set which needs to be changed and what's the default path of the parameter file on server and can this be changed?
Could you provide the log file?
Assuming I did understand this:
when you run the workflow with the parameter file -lpf that has this path:
/apps/config/informatica/param.txt
it does work, instead when you run it manually does not.
it could be so simply that manually you have to put instead of the extended path the string $PMSourceFileDir\ in the Source file Directory or to put it better: Source file Directory = $PMSourceFileDir\.
That because $PMSourceFileDir refer to the Informatica server initialization, as it is a server variable.
Instead with a parameter file usually is used to override that "deafult" path.

Resources