Interface IJMeterSession


public interface IJMeterSession
Interface for creation, management, deletion of JMeter sessions
  • Method Details

    • applyProperties

      void applyProperties(InputStream propStream) throws JMeterManagerException
      Apply properties to the JMeter session from a properties file stream. This method should be called before starting the JMeter test.
      Parameters:
      propStream - An InputStream containing the properties file content
      Throws:
      JMeterManagerException - if properties cannot be applied
    • applyProperties

      void applyProperties(InputStream propStream, Map<String,Object> properties) throws JMeterManagerException
      Apply properties to the JMeter session from both a properties file stream and additional dynamic properties. This method should be called before starting the JMeter test. The dynamic properties map will be merged with properties from the stream, with dynamic properties taking precedence.
      Parameters:
      propStream - An InputStream containing the properties file content
      properties - A Map of additional dynamic properties to apply
      Throws:
      JMeterManagerException - if properties cannot be applied
    • startJmeter

      void startJmeter() throws JMeterManagerException
      Start the JMeter test execution with the default timeout of 60 seconds. All results are automatically stored in the Result Archive Store (RAS).
      Throws:
      JMeterManagerException - if the test fails to start or execute
    • startJmeter

      void startJmeter(int timeout) throws JMeterManagerException
      Start the JMeter test execution with a specified timeout. All results are automatically stored in the Result Archive Store (RAS).
      Parameters:
      timeout - The maximum time in milliseconds to wait for test completion
      Throws:
      JMeterManagerException - if the test fails to start, execute, or times out
    • setDefaultGeneratedJmxFile

      void setDefaultGeneratedJmxFile(InputStream jmxStream) throws JMeterManagerException
      Set the JMX test plan file for this session using a static (non-parameterized) JMX file. Use this method when your JMX file does not require dynamic parameter substitution.
      Parameters:
      jmxStream - An InputStream containing the JMX test plan content
      Throws:
      JMeterManagerException - if the JMX file cannot be stored or is invalid
    • setChangedParametersJmxFile

      void setChangedParametersJmxFile(InputStream jmxStream, Map<String,Object> parameters) throws JMeterManagerException
      Set the JMX test plan file for this session using a parameterized JMX template. This method processes the JMX template using Velocity, replacing variables with provided values.

      To prepare your JMX file for parameterization:

      1. Replace JMeter's ${__P(VARIABLE)} notation with Velocity's $VARIABLE notation
      2. Provide parameter values in a Map

      Example:

       Map<String,Object> params = new HashMap<>();
       params.put("HOST", "galasa.dev");
       params.put("PORT", 8080);
       session.setChangedParametersJmxFile(jmxStream, params);
       
      Parameters:
      jmxStream - An InputStream containing the JMX template content
      parameters - A Map of parameter names to values for template substitution
      Throws:
      JMeterManagerException - if the JMX template cannot be processed or stored
    • getJmxFile

      String getJmxFile() throws JMeterManagerException
      Retrieve the JMX test plan file content as a UTF-8 encoded string.
      Returns:
      The JMX file content
      Throws:
      JMeterManagerException - if the file cannot be retrieved
    • getLogFile

      String getLogFile() throws JMeterManagerException
      Retrieve the JMeter log file content as a UTF-8 encoded string. The log file contains JMeter's execution logs and diagnostic information.
      Returns:
      The log file content
      Throws:
      JMeterManagerException - if the file cannot be retrieved
    • getConsoleOutput

      String getConsoleOutput() throws JMeterManagerException
      Retrieve the console output from the JMeter execution.
      Returns:
      The console output as a string
      Throws:
      JMeterManagerException - if the console output cannot be retrieved
    • getListenerFile

      String getListenerFile(String fileName) throws JMeterManagerException
      Retrieve a specific listener output file from the JMeter execution. Listener files contain test results in various formats (e.g., .jtl files).
      Parameters:
      fileName - The name of the listener file to retrieve
      Returns:
      The listener file content as a string
      Throws:
      JMeterManagerException - if the file cannot be retrieved or fileName is invalid
    • statusTest

      @Deprecated boolean statusTest() throws JMeterManagerException
      Deprecated.
      Use isTestSuccessful() instead. This method will be removed in a future release.
      Check whether the JMeter test executed successfully.
      Returns:
      true if the test completed successfully, false otherwise
      Throws:
      JMeterManagerException - if the test status cannot be determined or the test failed
    • isTestSuccessful

      boolean isTestSuccessful() throws JMeterManagerException
      Check whether the JMeter test executed successfully.

      For LOCAL mode: Returns true if exit code is 0

      For DOCKER mode: Returns true if log contains expected completion markers

      Returns:
      true if the test completed successfully, false otherwise
      Throws:
      JMeterManagerException - if the test status cannot be determined or the test failed
    • stopTest

      void stopTest() throws JMeterManagerException
      Stop the JMeter test execution and clean up resources.

      For LOCAL mode: This is a no-op as binary execution completes automatically

      For DOCKER mode: Stops the container and removes it from active sessions

      Throws:
      JMeterManagerException - if the test cannot be stopped or cleanup fails
    • getExitCode

      long getExitCode() throws JMeterManagerException
      Get the exit code from the JMeter process execution.
      Returns:
      The exit code (0 indicates success, non-zero indicates failure)
      Throws:
      JMeterManagerException - if the exit code cannot be retrieved
    • getSessionID

      int getSessionID()
      Get the unique session identifier for this JMeter session.
      Returns:
      The session ID