简体   繁体   中英

Trying to run a JMeter test using a docker container for JMeter (non GUI mode) throws error “Could not open xxxx.jmx file”

I am trying to distribute loading tests using Docker containers.

At local in JMeter, my tests run correctly in GUI or non GUI mode, but when I try to run any of them in non GUI mode using a docker image for JMeter:

docker run egaillardon/jmeter -n -t ~/Developer/testing/login_test.jmx -l ~/Desktop/resultado.jtl

I get the error:

Could not open ~/Developer/testing/login_test.jmx

I tried with different docker images for JMeter (egaillardon/jmeter, justb4/jmeter, vmarrazzo/jmeter) and I got the same error in any of them. Anyone knows what I have to change in my jmx file to do it readable?

I already tried with this solution in Stack Exchange but none worked for me.

You can also mount the host directory to the default working directory ( /jmeter ) in the container.

Example :

docker run --detach --rm --volume `pwd`:/jmeter egaillardon/jmeter-plugins --nongui --testfile test.jmx --logfile result.jtl


By doing so, the jmeter run log file ( jmeter.log ) will also be created in the host directory.

In addition, to address issue regarding file permissions, you can also assign the user id and the group id of the user on the host to the jmeter user inside the container.

Example :

docker run --env JMETER_GROUP_ID=`/usr/bin/id -g` --env JMETER_USER_ID=`/usr/bin/id -u` --rm egaillardon/jmeter --server -Jserver.rmi.ssl.disable=true

~/Developer/testing/login_test.jmx would be loaded from the container filesystem perpective, chances are that this path does not exist within your container filesystem.

To overcome this, you could mount this file from your host filesystem into your container filesystem with a docker volume :

docker run -v ~/Developer/testing/:/workspace egaillardon/jmeter -n -t /workspace/login_test.jmx -l /workspace/resultado.jtl

Explanations

  • -v ~/Developer/testing/:/workspace : mount the ~/Developer/testing/ directory from your host to the path /workspace/ in the container filesystem
  • -n -t /workspace/login_test.jmx -l /workspace/resultado.jtl : options passed to the container processus (jmeter) at runtime, and thus in the context of the container. We need to adjust paths so that they match the location we chose when configuring the volume.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM