I would like to control throughput in real-time while running the test. How do I do that using BeanShell server?
Basically I want to update a user property 'throughput' (used in Constant Throughput Timer) from command line while the test is running.
Solution:
Based on Dmitri's answer I did the following:
1. I added to user.properties
:
beanshell.server.port=9000
beanshell.server.file=beanshell.server.file=/home/sam/JMeter/apache-jmeter-4.0/extras/startup.bsh
~/JMeter/apache-jmeter-4.0$ java -jar lib/bshclient.jar localhost 9000 /home/sam/JMeter/beanshell/setthroughput.bsh 100
throughput
property is now 100. Fantastic!Add the next 2 lines to user.properties file:
beanshell.server.port=9000
beanshell.server.file=../extras/startup.bsh
Set throughput
property in the Constant Throughput Timer using __P() function like:
${__P(throughput,60)}
this will set default throughput to 60 requests per minute (1 request per second), if throughput
property will be defined somewhere somehow - the value will get overriden.
Create setthroughput.bsh
in "lib" folder of your JMeter installation with the following contents:
setprop("throughput", args[0]);
In the runtime you will be able to modify the throughput like:
java -jar bshclient.jar localhost 9000 setthroughput.bsh 100
More information: Beanshell Server
I believe it would be easier if you switch to Throughput Shaping Timer which has load_profile
property so you will be able to control throughput in more flexible and efficient manner. You can install Throughput Shaping Timer using JMeter Plugins Manager