I've set BUNDLE_DIRECTORY user defined variable as:
Nevertheless, when I'm using it on Directory Listing Data Source it's not able to resolve it:
Any ideas?
The User Defined Variable which is set on the Test Plan level will be available in the runtime, i.e. when you start your JMeter test.
In order to see the variable value you can add Debug Sampler and View Results Tree listener combination:
If you want to use "Test Directory Listing" it has to be a JMeter Property
Related
I have a variable CCODE.
In my Cookie Manager, I set:
Name = AAA
Value = ${CCODE}
Results Tree shows AAA=${CCODE}.
I'm very sure the variable CCODE exists because I can use it elsewhere.
The following in user.properties:
CookieManager.save.cookies=true
CookieManager.check.cookies=false
CookieManager.allow_variable_cookies=true
How to solve this ? Thanks.
Take a look at:
JMeter's test elements execution order
JMeter Scoping Rules
Given the ${CCODE} variable exists and has its respective value (you can check it using Debug Sampler and View Results Tree listener combination) JMeter will send the relevant cookie along with the request.
I have one http request whose response comes in nested json and using groovy i am saving that data in different csv file on the basis of conditions.
the name of csv file is generated dynamically and saved in a variable
using vars.put() function
vars.put("_cFileName",cFileName.toString());
when try to use this variable in csv data set config
enter image description here
getting error message
2022-01-19 16:58:39,370 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: File ${_cFileName} must exist and be readable
it is not converting the name to actual file name
But in case if file name is not dynaamic and the variable is defined under user defined variable in test plan it will able to convert to actual file name?
is there any way we can use the dynamic name created in an previos request post processor?
You cannot, as per JMeter Test Elements Execution Order Configuration Elements are executed before everything else, CSV Data Set Config is a Configuration Element hence it's being initialized before any JMeter Variables are being set.
The solution would be moving to __CSVRead() function, JMeter Functions are evaluated at the time they're being called so it's possible to provide dynamic file name there, see How to Pick Different CSV Files at JMeter Runtime guide for more details if needed.
I'm trying to create JNDI Properties values as variables from a config file but when I use the command:
${__groovy(vars.getObject("myTrustedCerts"))}
as the value, the error is:
2021-06-25 14:49:08,682 ERROR o.a.j.p.j.s.JMSSampler: Not permitted: empty file name
javax.naming.AuthenticationException: Not permitted: empty file name"
But the variable myTrustedCerts is correctly filled:
2021-06-25 14:49:08,732 INFO o.a.j.p.j.s.J.JSR223 Sampler: JSR223 The value of myTrustedCerts = C:/GEMS5.0/Gems/figeastrustchain.cer.pem
The variable is filled from an xml file:
vars.putObject("myTrustedCerts",xml.ssl_trusted_certs).toString()
It works when I fill the value with the full path, but I want it to be generic from a config file.
Try adding a Debug Sampler before your JMS Point-to-Point sampler and look into View Results Tree listener to ensure that the variable is there and it has ancitipated value
I think you have an error/typo in this line:
vars.putObject("myTrustedCerts",xml.ssl_trusted_certs).toString()
I believe it should look like:
vars.putObject("myTrustedCerts", xml.ssl_trusted_certs.toString())
If you look at jmeter.log file you should see some Groovy-syntax-related errors, once you fix them you should get expected behaviour.
I found a alternative way to resolve my issue: I use properties instead of variables. To be sure it's done in the right order, I use multiple threads: in the first one, I initialize the properties and in the next one I use them
I have an http request that uses an extractor to set a JMeter variable (lets call it test) from the body. When I look at the debug controller I can see this works fine. Next I want to append something to the beginning of the variable so I add a user defined variable node and add a variable with the name new and I set the value to ${test}. However when I look in the debug response I see ${test} instead of the value.
I tried the same thing setting the value manually in 2 different UDV nodes and it works fine, so how do I append to a JMeter variable declared in an extractor?
As per JMeter Documentation:
The User Defined Variables element lets you define an initial set of variables, just as in the Test Plan.
Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.
So the User Defined Variables element will be read only once and only when the Test Plan is started.
If you need to overwrite the current variable with a new value you can go for i.e. __groovy() function, the relevant syntax would be something like:
${__groovy(vars.put('foo'\, 'some_prefix_' + vars.get('foo')),)}
Demo:
vars is a shorthand for JMeterVariables class instance, it provides read-write access to all JMeter Variables in the current thread scope. Check out The Groovy Templates Cheat Sheet for JMeter to learn what else you can do with Groovy scripting in JMeter tests
UDVs can't be used in dynamic way because they are process once at the start of the test.
Don't use UDV, use JSR223 Sampler (or PostProcessor) with vars;
vars.put("new", "prefix"+ vars.get("test"))
Another option is to use Set Variables Action plugin
I am trying to run a single recording in various different ways without copying the recorded pages.
I have created two Property File Readers that look for:
C:\performance\jmeter\users_${__P(ttype)}.properties
and
C:\performance\jmeter\${__P(env)}_${__P(region)}.properties
where the ${__P(xxx)} variables are passed on the command line as so:
-Jregion=UK -Jenv=dev -Jttype=isolated
These property files load the following variables (for example):
- usercount=25
- duration=1800
- host.name=server1
- host.port=8546
These are used in the HTTP Request Defaults:
${__P(host.name)}
${__P(host.port)}
and Thread Group:
${__P(duration)}
${__P(usercount)}
This works fine. However, if I want to run the same test in the Gui for a single thread (to check it works), these variables are not populated and the test fails.
I can create a User Defined Variable element but these have the format
${xxx}
so cannot be used interchangeably.
Is there any way to do what I'm trying to do here, please?
Option 1: you can pass the same parameters via '-J` arguments as JMeter in the GUI mode respects them as well
Option 2: you can specify your properties values in user.properties file (located in JMeter's "bin" folder) like
usercount=25
duration=1800
etc.
The properties values passed over the command-line will override those, which are specified in the user.properties
See Apache JMeter Properties Customization Guide for more information on using JMeter properties
By the way, you ain't gonna need this Property File Readers, there is a possibility to add extra properties files in JMeter via -q command line argument.
-q, --addprop
additional JMeter property file(s)
Discovered another way to resolve this issue.
The __P() function can take a second argument that acts as the default if the first value isn't resolved.
So
${__P(host.name)}
${__P(host.port)}
become
${__P(host.name,server1)}
${__P(host.port,1234)}
This works as well.