0
votes

I have a file where I specify the number of threads for each Thread Group.
My goal is to run concurrently all Thread Groups with the number of threads read from the file.

My current algorithm: I have the first Thread Group in the Test Plan called Setup.
I read the data file to the local variables.
With the BeanShell Sampler, I convert those variables into the properties variables.
In each Thread Group, the number of threads is defined via the properties variable.

If I run the Thread Groups consecutively, there are no problems.
But I need to run them in parallel. I imagine that the Thread Group can try to run before the Setup group finishes reading the number of threads for that group. Then that group will never run.

I appreciate any thoughts and suggestions.

2

2 Answers

2
votes

My current algorithm: I have the first Thread Group in the Test Plan called Setup. I read the data file to the local variables. With the BeanShell Sampler, I convert those variables into the properties variables. In each Thread Group, the number of threads is defined via the properties variable.

You could use Property File Reader. This will get loaded before any thread group starts. So you would not face any issue.

If you do not like Property File Reader, whatever you do - reading the data file and converting them into properties - do that in setUp Thread Group.

enter image description here

It will get executed before any thread group starts

4
votes

You can define the number of threads via JMeter properties in at least 2 more ways:

  1. In user.properties file (the file is located in JMeter's "bin" folder, JMeter restart will be required to pick the properties up)

    threads=100
    
  2. Or you can do the same via -J command-line argument, i.e. start JMeter as:

    jmeter -Jthreads=100 -n -t ....
    

In your Thread Groups you can refer the property via __P() function like:

 ${__P(threads)}

It is also possible to have "default" value which will be used in case of "threads" property will not be defined:

${__P(threads,50)}

References: