Perf2017
Perf2017

Reputation: 29

Load Distribution for multiple thread group in Jmeter

In my Jmeter 3.0 test plan, I have multiple thread groups. Now I want to distribute users among them on the basis of percentage.

I have declared Variables in user defined variable and then used the following statement in thread group

${__BeanShell(${__evalVar(threads)}*${__evalVar(WeightOfGroup1)}/100)}

But I am getting the following exception while doing so

2017/09/20 19:25:39 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of: ``**ERROR - see log file*****ERROR - see log file**/100;'' Encountered "*" at line 1, column 1.

2017/09/20 19:25:39 WARN  - jmeter.functions.BeanShell: Error running BSH script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``**ERROR - see log file*****ERROR - see log file**/100;'' Encountered "*" at line 1, column 1.

Upvotes: 0

Views: 1026

Answers (1)

timbre timbre
timbre timbre

Reputation: 13960

You cannot use variables in thread group definitions, since variables are local to a thread, and thus are initialized after thread group starts its threads.

You have 2 options:

  1. Use properties, as described in this solution. Calculation you are trying to do will need to be modified too, for example like this:

    ${__javaScript(Math.max(1\,Math.round(props.get('threads')*props.get('WeightOfGroup1')/100)))}

    Assuming here that you have both threads and WeightOfGroup1 properties defined. Also notice that you need to round the number to integer. To avoid ending up with 0 threads, I also take the maximum between 1 and formula calculation (so it will run at least one thread) - this is optional of course.

  2. From your use case it actually looks like you don't need thread groups. Instead, you could use one thread group, have Throughput Controller for each fragment which previously was your thread group, and express your distribution goal in Throughput Controller parameter. In that case you don't need to calculate percentage, just specify what you need the percentage to be, e.g.:

    enter image description here

    I think this solution is more elegant, so unless there are any other reasons to use multiple thread groups, I'd go with that.

Upvotes: 1

Related Questions