0

I am running a load test using JMeter and I want take the ConstantThroughputTimer value as user input and set in the JMX XML. The JMeter shell script is being called from a bash script.

Bash Script:

THROUGHPUT_VALUE=121
THROUGHPUT_VALUE=$(echo "$THROUGHPUT_VALUE" | awk '{printf "%.1f", $1}')

$JMETER_INSTALL_DIR/jmeter.sh -n -t $JMETER_LOAD_PROFILE_CONFIG/$PROFILE_FILE_NAME -JThroughput=$THROUGHPUT_VALUE


    

JMeter JMX XML (This is not complete XML. Just a snippet of the full XML where user defined variable and Throughput time is declared)

   <UserParameters guiclass="UserParametersGui" testclass="UserParameters" testname="User Parameters" enabled="true">
    <collectionProp name="UserParameters.names">
      <stringProp name="904465283">CurrentDay</stringProp>
      <stringProp name="-2026347353">CurrentDate</stringProp>
      <stringProp name="-2025863226">CurrentTime</stringProp>
      <stringProp name="690807817">FinalDate_Header1</stringProp>       
      <stringProp name="-323914198">throughput</stringProp>
   </collectionProp>
   <collectionProp name="UserParameters.thread_values">
      <collectionProp name="-548354585">
        <stringProp name="603506847">${__time(E,)}</stringProp>
        <stringProp name="-1521574952">${__time(YYYY-MM-dd)}</stringProp>
        <stringProp name="1821498968">${__time(HH:mm:ss)}</stringProp>
        <stringProp name="52928079">${__time(E\, dd MMM yyyy\, h:mm:ss,)} +0000</stringProp>
        <stringProp name="1446819321">${__P(Throughput)}</stringProp>
      </collectionProp></collectionProp> </UserParameters>


   <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
      <intProp name="calcMode">0</intProp>
      <doubleProp>
        <name>throughput</name>
        <value>${__P(Throughput)}</value>
        <savedValue>0.0</savedValue>
      </doubleProp>
    </ConstantThroughputTimer>

But JMeter is throwing error

Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'/mnt/Test.jmx'. 
Cause:
NumberFormatException: For input string: "${__P(Throughput)}"
 Detail:com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : 
first-jmeter-class  : org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:109)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/ConstantThroughputTimer/doubleProp/value
line number         : 461
version             : 5.5
-------------------------------
Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'/mnt/Test.jmx'. 
Cause:
NumberFormatException: For input string: "${__P(Throughput)}"
 Detail:com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : 
first-jmeter-class  : org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:109)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/ConstantThroughputTimer/doubleProp/value
line number         : 282
version             : 5.5

I even changed the property of the XML from

<stringProp name="-323914198">${__P(Throughput)}</stringProp> to <doubleProp name="-323914198">${__P(Throughput)}</doubleProp>

thinking that it's a float or double value. But still getting same error. Is there any way I can resolve this?

3
  • Please don't tag your titles. See How to Ask. Commented Mar 6 at 22:02
  • Btw.: Your shown XML file is no valid XML file. Commented Mar 6 at 22:38
  • I haven't shared the complete XML. It's just snippet of the user parameters and constant throughput timer. Why do you think it's not valid? If I remove <value>${__P(Throughput)}</value> and put a double number then it's working fine. So XML is valid. Commented Mar 7 at 5:03

1 Answer 1

1

It's better to use JMeter GUI for creating and editing test plans:

enter image description here

This results in the following XML configuration:

<ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer">
  <intProp name="calcMode">0</intProp>
  <stringProp name="throughput">${__P(Throughput,)}</stringProp>
</ConstantThroughputTimer>

Once done you can set the property value via -J command-line argument like:

jmeter -JThroughput=12345 -n -t test.jmx -l result.jtl

More information:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.