I am trying to parameterize the JMeter test so that I can run Load Test, Stress Test as well as Soak Load Test using the same test plan.
In order to do this, I defined the following as User Defined variables (Test Plan -> Add -> Config Element -> User Defined Variables)
numberOfThreads=${__P(numberOfThreads,1)}
rampUp=${__P(rampUp,1)}
loopCount=${__P(loopCount,1)}
schedulerEnabled=${__P(schedulerEnabled,false)}
schedulerDuration=${__P(schedulerDuration,120)}
Now, in the ThreadGroup definition, I am using these variables as
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test123" enabled="true">
<stringProp name="TestPlan.comments">Test for the endpoint GET /test123</stringProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">${loopCount}</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">${numberOfThreads}</stringProp>
<stringProp name="ThreadGroup.ramp_time">${rampUp}</stringProp>
<boolProp name="ThreadGroup.scheduler">{schedulerEnabled}</boolProp>
<stringProp name="ThreadGroup.duration">${schedulerDuration}</stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
But when I run the same and pass in values
numberOfThreads=50
rampUp=10
loopCount=-1
schedulerEnabled=true
schedulerDuration=30
(using jmeter-maven-plugin) the first ThreadGroup keeps creating infinite number of threads instead of shutting down the thread groups after 30 seconds.
PS: 30 is an example. When executing Soak Load Test, I will be setting a higher value to the same.
PS: I noticed that LoopController.continue_forever is set to 'false' immaterial whether for Loop Count I check "Infinite" or provide the value 1. When in UI, I check "Infinite", the value of LoopController.loops is set to -1.
- jmeter-maven-plugin: 2.7.0
- JMeter Version: 5.1.1