I am having some trouble trying to change User Defined Variables based on an already existing variable.
BeanShell:
String databaseSize;
if (${__P(DBsize,${DB_size})} == '0') {
vars.put("databaseSize","SmallDB"); }
else if (${__P(DBsize,${DB_size})} == '1')
{vars.put("databaseSize","LargeDB");}
User Defined Variables
Name: path
Value: ${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}\ ${databaseSize}
I would like to change the path based on what I store in databaseSize. I have two folders in the given path: SmallDB and LargeDB. As far as I know, UDV are getting assigned before JMeter manages to run my BeanShell.
Is there an alternative way of changing the path based on another variable (received from Jenkins or default value received from a file)?
Thank you
Value
stanza of the User Defined Variables - it will be evaluated when the configuration element will be processed You can go for ternary operator in order to convert your code into one smaller line, something like:
${__groovy((props.getProperty("DBsize").equals("0")) ? "SmallDB" : "LargeDB",)}
So your configuration would be: