Integrating JMeter scripts with JSystem

Apache JMeter is a great open source tool designed for load testing and performance measurement of web applications and web services. For those of you wishing to bring together the strengths of JMeter and JSystem, here is a short tutorial describing the methods that me and my team members have devised for integrating JMeter scripts with JSystem:

  1. Begin by designing the logic of a JMeter script as usual, using the JMeter GUI. When the script is ready, validate its functionality by running it from the JMeter GUI.
  2. Once you’re satisfied with the functionality of your script, replace all parameters that you want to be configurable from JSystem (such as the number of threads and the ramp-up period) by variable placeholders such as: ${numberOfThreads} and ${rampUpPeriod}.
  3. Add a “User Defined Variables” element to the top of the test plan (right-click on the “Test Plan” element -> Add -> Config Element -> User Defined Variables).
  4. Inside the “User Defined Variables” element, add new variables for each of the parameters you expect to be passed from JSystem. The variable names should match the names you used in the variable placeholders defined in step 2. The variable values should contain placeholders for JMeter command line parameters, matching this pattern: ${__P(variableName)}.
    For example, for the ${numberOfThreads} placeholder from step 2, you need to define a variable named numberOfThreads with the value: ${__P(numberOfThreads)}.
  5. If you need to add additional processing or business logic on top of JMeter’s output (some functionality which is not supported as one of JMeter’s built-in features), add a “Listener” element of your choice at the end of your test plan and configure it to write the results to file. When the script will finish running this will create a text file with the relevant data regarding the last run. Later this data can be analyzed and further be processed from your Java code.
  6. When finished working on the JMeter script, including all steps above, save the script to a JMX file, for example: jsystemLoadTest.jmx. We shall use this file in the next steps to invoke JMeter from JSystem.
  7. In your JSystem project, implement an object which supports running CLI commands from within the Java code (creating a new process that executes the command).
  8. To invoke the JMeter script from a JSystem test, run the following command from your Java code, using the object implemented in step 7:
    <JMETER_HOME>\jmeter –n –t <path_to_jmx_script_file> -J<paramName1>=<X> -J<paramName2>=<Y>
    for example:
    C:\apache-jmeter-2.9\bin\jmeter -n -t C:\JMeterScripts\jsystemLoadTest.jmx -JnumberOfThreads=100 -JrampUpPeriod=60
  9. When the process running the JMeter script ends you can pick up the results file created by JMeter as configured in step 5, parse it and implement your logic on the results such as: sorting, grouping, calculating complex statistics, etc.


View Rony Byalsky's LinkedIn profileView Rony Byalsky’s profile

Fork me on GitHub