justb4 / docker-jmeter

Docker image for Apache JMeter
MIT License
278 stars 310 forks source link

Jmeter jmx file doesn't exist or can't be opened #40

Closed sudhir22sharma closed 2 years ago

sudhir22sharma commented 3 years ago

I have tried to execute jmeter test plan using below command,

sudo docker run --mount type=bind,source="/home/ubuntu/",target="/opt/apache-jmeter-5.4/bin" justb4/jmeter -n -t /home/ubuntu/SampleAPITest.jmx -l /home/ubuntu/testrun.jtl

and got the below error message that the file doesn't exist/can't be opened,

START Running Jmeter on Tue Jun 1 10:05:31 CEST 2021 JVM_ARGS=-Xmn28m -Xms112m -Xmx112m jmeter args=-n -t /home/ubuntu/SampleAPITest.jmx -l /home/ubuntu/testrun.jtl Jun 01, 2021 10:05:33 AM java.util.prefs.FileSystemPreferences$1 run INFO: Created user preferences directory. An error occurred: The file /home/ubuntu/SampleAPITest.jmx doesn't exist or can't be opened

Please note : The file SampleAPITest.jmx exists in the given path and it can be opened using cat or vi command. SampleAPITest.zip

image

TannerGabriel commented 3 years ago

It seems that you are referencing the path of your local computer /home/ubuntu/SampleAPITest.jmx when trying to access the file inside of the container by providing it using the -t flag. However, your bind mount moves the files from /home/ubuntu to /opt/apache-jmeter-5.4/bin therefore you should use the following command:

sudo docker run --mount type=bind,source="/home/ubuntu/",target="/opt/apache-jmeter-5.4/bin" justb4/jmeter -n -t /opt/apache-jmeter-5.4/bin/SampleAPITest.jmx -l /opt/apache-jmeter-5.4/bin/testrun.jtl
sudhir22sharma commented 3 years ago

Thanks @TannerGabriel , it worked for me. :)

However, how can I provide path to my csv files(input data files) in Jmeter script?

e.g.; I have placed my Jmeter script and input data file in the following folder ,

/home/ubuntu/SampleAPITest.jmx /home/ubuntu/inputData.csv

justb4 commented 2 years ago

Think this has been answered by @TannerGabriel . Please note that you are mounting your local /home/ubuntu/ to the Docker Container path: /opt/apache-jmeter-5.4/bin. This is not a good idea. Please look at the run.sh and test.sh scripts. E.g. you can mount --mount type=bind,source="/home/ubuntu/",target="/home/ubuntu/" and refer as local.