'How to parameterise the boolProp tag in jmeter jmx file for providing the input in jenkins

Context:

  • Using JMeter 5.4.3
  • Using JenkinsFile for setup
  • Jmeter Thread group in .jmx has the below snippet:
        <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test" enabled="true">
        <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">${__P(Linf1,1)}</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">${__P(Tinf1,1)}</stringProp>
        <stringProp name="ThreadGroup.ramp_time">${__P(Rinf1,1)}</stringProp>
        <boolProp name="ThreadGroup.scheduler">${__(TSch,false)}</boolProp>
        <stringProp name="ThreadGroup.duration">${__P(Dinf1,60)}</stringProp>
        <stringProp name="ThreadGroup.delay">1</stringProp>
        <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
        </ThreadGroup>

From the above TheadGroup section - I am facing issue with ThreadGroup.scheduler

I am trying to parameterise this using ${__(TSch,false)} where the JenkinsFile -

  • Accepts user input from Jenkins with theseparameters
  • And execution happens with the below usage :
jmeter_path/${params.testPlan} -GTinf1=${params.jmeterThread} -GRinf1=${params.jmeterRamp} -GTSch=${params.testScheduled} -GLinf1=${params.jmeterLoop} -GDinf1=${params.jMeterDuration} -Gconstant_throughput=${params.jmeterCT}

Issue am facing is from -GTSch=${params.testScheduled}

When I provide input as either true/false. It is not working as intended.

Example : I am giving the below details from Jenkins.

Inputs from Jenkins

The script is running indefinitely as the loop given is -1 which led me to believe that schedule param is not working as intended.

Please note - When I hardcode the scheduler value in jmx with true/false or change the tag to intProp and update it as 0/1. The script works as intended.



Solution 1:[1]

Unfortunately this is not something you can control using JMeter properties as of JMeter 5.4.3, the options are in:

  1. Consider migrating to custom thread group i.e. Ultimate Thread Group when the workload can be configured using threads_schedule special property
  2. Using a non-interactive editor like sed to replace the default value in the .jmx file directly
  3. Use Taurus tool as a wrapper for your JMeter test, it has possibility to modify JMeter scripts.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T