Jmeter resolution variable with remote

22 Views Asked by At

I have a Jmeter script with a variable define in test Plan

SCRIPT_DIR  ${__groovy(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__groovy(File.separator,)}
INPUT_DIR   ${SCRIPT_DIR}./../data
RESULT_DIR  ${SCRIPT_DIR}./../resultat
RUN_ID  ${__P(runID, ${__time(yyyy'-'MM'-'dd_HH'h'mm'm'ss's',)})}

RESULT_DIR is used to define the location of my Simple Data Write and my Summary Report

${RESULT_DIR}${SLASH}${RUN_ID}${SLASH}errors.xml
${RESULT_DIR}${SLASH}${RUN_ID}${SLASH}rapport_summary.csv

I want to execute my script in distributed mode with two instances, VM1 and VM2

On each VM, I have start my jmeter-server and they are OK

[user@vm1]$ ./script/lance_jmeter_with_config_mode_server.sh
Created remote object: UnicastServerRef2 [liveRef: [endpoint:[xxx.xxx.xxx.xxx:45595](local),objID:[2ff2de01:18e896a8f94:-7fff, 7070060110512970506]]]

Then I start my script in remote mode (-r) and it's ok

$JMETER_HOME/bin/jmeter.sh -r -n -t /home/user/script/myscript.jmx -G$/home/user/config/myconf.properties -j /home/user/resultat/jmeter.log

Starting the test on host xxx.xxx.xxx.xxx @ March 29, 2024 9:54:44 AM CET (1711702484330)

But on my directory, when Jmeter create the "resultat" folder, the variables are not translated. Folder is name "${SCRIPT_DIR}./../"

Is there any specific configuration for resolve this problem ?

1

There are 1 best solutions below

0
Ivan G On BEST ANSWER

As per User Defined Variables documentation:

Also, the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.

So if you want to proceed with your current approach you need to:

  1. Declare SCRIPT in 1st User Defined Variables
  2. Declare INPUT_DIR and RESULT_DIR using 2nd instance of the User Defined Variables

More information: Using User Defined Variables