Run JMeter API Performance Test #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run JMeter API Performance Test | |
on: | |
workflow_dispatch: | |
inputs: | |
Environment: | |
description: 'Host name' | |
required: true | |
default: 'inkind-staging.com' | |
Threads: | |
description: 'Number of threads (users)' | |
required: true | |
default: '2' | |
RampupPeriod: | |
description: 'Ramp-up time in seconds' | |
required: true | |
default: '1' | |
LoopCount: | |
description: 'Loop count' | |
required: true | |
default: '1' | |
jobs: | |
performance_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout performance_test repository | |
uses: actions/checkout@v3 | |
with: | |
repository: inKindCards/performance_test | |
ref: main | |
- name: Install JMeter | |
run: | | |
if ! command -v jmeter &> /dev/null | |
then | |
echo "JMeter not found, installing..." | |
wget https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.3.tgz | |
tar -xvzf apache-jmeter-5.6.3.tgz | |
export JMETER_HOME=$(pwd)/apache-jmeter-5.6.3 | |
export PATH=$JMETER_HOME/bin:$PATH | |
echo "JMeter installation complete." | |
else | |
echo "JMeter is available. Skipping installation..." | |
fi | |
- name: Environment and parameters | |
run: | | |
echo "Running performance test with parameters:" | |
echo "Environment: ${{ github.event.inputs.Environment }}" | |
echo "Threads: ${{ github.event.inputs.Threads }}" | |
echo "Ramp-up Time: ${{ github.event.inputs.RampupPeriod }}" | |
echo "Loop Count: ${{ github.event.inputs.LoopCount }}" | |
echo "jmeter -n -t ./inKind_API.jmx -JEnvironment=${{ github.event.inputs.Environment }} -JThreads=${{ github.event.inputs.Threads }} -JRampupPeriod=${{ github.event.inputs.RampupPeriod }} -JLoopCount=${{ github.event.inputs.LoopCount }} -l result.csv -e -o result-html" | |
- name: Run JMeter API Performance Test | |
run: | | |
export JMETER_HOME=$(pwd)/apache-jmeter-5.6.3 | |
export PATH=$JMETER_HOME/bin:$PATH | |
jmeter -n \ | |
-t ./inKind_API.jmx \ | |
-JEnvironment=${{ github.event.inputs.Environment }} \ | |
-JThreads=${{ github.event.inputs.Threads }} \ | |
-JRampupPeriod=${{ github.event.inputs.RampupPeriod }} \ | |
-JLoopCount=${{ github.event.inputs.LoopCount }} \ | |
-l result.csv \ | |
-e -o result-html | |
- name: Upload JMeter CSV Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jmeter-csv-report | |
path: result.csv | |
- name: Upload JMeter HTML Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jmeter-html-report | |
path: result-html |