Search code examples
jmeterrobotframeworkjmeter-3.2

Any limitation of variable length in jmeter


i am using robotframework with jemetr to automate my API.I am trying to pass the below json data from robotframework script to jmeter but it is getting failed and if i reduce the json data size it is working fine.Please let me know whether there is any limitation and if yes what is the workaround.

JSON data:

{"fordate(dd-mm-yyyy)":"21-04-2021","user_id":"1","outlet_id":"10","warehouse_id":"1","skunit_id":"1","Quantity(case)":"","Quantity(units)":"2","Auto Scheme Apply":"","unitprice":"23","po_number":"","po_deliveryTime(dd-mm-yyyy)":"2021-04-22","id":"jqg1"}

Robot keyword:

Run Jmeter      ${jmeter}    ${jmxPath}  ${logPath}   -Jmdmpath=${mdmpath} -Jtestname=${TEST_NAME} -Jmdmid=75 -Jjsondata=${json}

Json data is passed via variable ${json}

Error:

10:37:27.702    FAIL    JMeterLibException: 'Value returned by JMeter: 1'   
10:37:27.702    DEBUG   Traceback (most recent call last):
  File "/home/sadha/.local/lib/python3.8/site-packages/JMeterClasses.py", line 41, in runJmeter
    JMeterRunner(jmeterPath, testPlanPath, logFilePath, otherParams)
  File "/home/sadha/.local/lib/python3.8/site-packages/JMeterClasses.py", line 200, in __init__
    jmeterOutput = self.runAndPrintResult()
  File "/home/sadha/.local/lib/python3.8/site-packages/JMeterClasses.py", line 234, in runAndPrintResult
    raise JMeterLibException("%s %s" % (msg, retValue))

Solution

  • Put your ${json} in quotation marks like:

    -Jjsondata='${json}'
    

    or make sure to escape all the special characters with a backslash \ in your JSON


    A better idea would be passing the path to the JSON file and reading the file in JMeter script using __FileToString() function. If you have multiple files in a folder it makes sense to use Directory Listing Config

    More information: Bash: Special Characters and Quoting