2 issue while running JMeter in GitHub Actions

Issues while running Jmeter in GitHub Actions

These two issues were related but were addressed sequentially. First, the ForbiddenClassException was resolved by adjusting JMeter’s security settings, and second, the missing jmeter command was fixed by installing the correct JMeter version.

Issue 1: ForbiddenClassException Error

Run jmeter -n -t Jmeter/API_Stress_Testing.jmx -l results.jtl
  jmeter -n -t Jmeter/API_Stress_Testing.jmx -l results.jtl
  shell: /usr/bin/bash -e {0}
Error in NonGUIDriver com.thoughtworks.xstream.security.ForbiddenClassException: org.apache.jmeter.save.ScriptWrapper

Description:
This error occurs when trying to run JMeter tests in a GitHub Actions workflow, specifically due to JMeter’s security settings. By default, JMeter has restricted access to certain classes when running in non-GUI (headless) mode. In this case, the org.apache.jmeter.save.ScriptWrapper class is considered forbidden, causing the test execution to fail.

Cause:
This issue is related to JMeter’s security configuration, where certain classes, including ScriptWrapper, are not allowed by default due to potential security risks.

Solution:
To resolve this issue, the security settings need to be adjusted. Specifically, you can allow the ScriptWrapper class by adding the following configuration to the JMeter properties file:

echo "xstream.security.allowAll=org.apache.jmeter.save.ScriptWrapper" >> $HOME/.jmeter.properties

This line allows the class to be used, resolving the ForbiddenClassException error.

Issue 2: command not found Error After Fix

After fixing the issue above, I encountered this issue:

Run jmeter -n -t Jmeter/API_Stress_Testing.jmx -l results.jtl
  jmeter -n -t Jmeter/API_Stress_Testing.jmx -l results.jtl
  shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/77c2a8d3-d096-40ce-96ed-1ad18e767f54.sh: line 1: jmeter: command not found
Error: Process completed with exit code 127.

Description:
After resolving the ForbiddenClassException error, I encountered this new issue where the jmeter command could not be found. The error message indicates that JMeter is not recognized as a valid command in the system path, causing the GitHub Action to fail.

Cause:
The root cause of this issue was the installation method used for JMeter. In the workflow, I initially installed JMeter using Ubuntu’s default package manager (apt-get), which installs an outdated version of JMeter (version 2.13). As a result, the jmeter command wasn’t available, causing the error.

Solution:
The solution was to manually install JMeter version 5.5, which is required to run the test plan successfully. The steps for installation included:

  1. Downloading JMeter 5.5 from Apache’s archives.
  2. Extracting and setting up the correct JMeter version.
  3. Ensuring the jmeter command was available in the system’s PATH to allow test execution.

By performing these steps, the command not found error was resolved, allowing JMeter tests to run successfully.

The final version of the YML code

name: Postman Functional/Integration + Jmeter Stress Performance test

on:
  workflow_dispatch:

jobs:
  api-tests:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v3

    - name: Set Up Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '16.x'

    - name: Install Dependencies
      run: npm ci

    - name: Run Postman Test
      run: newman run "Postman/Retrieve all items in the database.postman_collection.json"

    - name: Install OpenJDK 8
      run: sudo apt-get install openjdk-8-jdk

    - name: Download and Install JMeter 5.5
      run: |
        wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.5.tgz
        tar xf apache-jmeter-5.5.tgz
        echo "$PWD/apache-jmeter-5.5/bin" >> $GITHUB_PATH

    - name: Configure JMeter XStream Security
      run: |
        echo "xstream.security.allowAll=org.apache.jmeter.save.ScriptWrapper" >> $PWD/apache-jmeter-5.5/bin/jmeter.properties

    - name: List JMeter Directory
      run: ls -R apache-jmeter-5.5

    - name: Run JMeter Tests
      run: jmeter -n -t Jmeter/API_Stress_Testing.jmx -l results.jtl

This YML code proved to successfully do the job for me while running a Postman functional/integrational + JMeter Stress Performance test that you may check by taking a look at the following repository:
https://github.com/NoToolsNoCraft/Postman-Integration-Jmeter-Stress-test

Scroll to Top