benevolent
benevolent

Reputation: 101

Running jmeter using docker

I am facing issue while running jmeter using docker container. The script works fine when I run it through GUI or CLI on my local machine. But when I execute same script using container it getting failed.
Below is the issue.
So I am using beanshell postprocessor for capturing response cookies. Below is the code for same.
props.put("MyCookie1","${COOKIE_one}"); props.put("MyCookie2","${COOKIE_two}"); props.put("MyCookie3","${COOKIE_three}");
And this parameterized value works fine in my local machine(windows 10). But when I run the same in container these parameterized value doesn't gets resolved.
I am using "alpine:3.12" base image in container.

NOTE : Jmeter version in my local machine is "5.4.1" and java version is "java 11". In docker container Jmeter version is "5.3" and java version is "java 8". The API which I am hitting is hosted in AWS Lambda.

Upvotes: 3

Views: 818

Answers (1)

Dmitri T
Dmitri T

Reputation: 168197

You forgot the most important detail: your Dockerfile

Blind shot: in order to be able to access cookies as COOKIE_one, etc. - you need to add an extra property to wit CookieManager.save.cookies=true either to user.properties file or to pass it to JMeter startup script via -J command-line argument like:

./jmeter -JCookieManager.save.cookies=true -n -t test.jmx -l result.jtl

Also according to JMeter Best Practices:

  1. Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting
  2. You should always be using the latest version of JMeter

So maybe it worth consider migrating to Groovy, you will only need to amend your code from:

props.put("MyCookie1","${COOKIE_one}")

to

props.put("MyCookie1",vars.get("COOKIE_one"))

where vars stands for JMeterVariables class instance, see Top 8 JMeter Java Classes You Should Be Using with Groovy for more information if needed.

And update your Dockerfile to use the latest stable version of JMeter

Upvotes: 1

Related Questions