Skip to content

load-test-image

load-test-image #109

name: JMeter Load Test (repository_dispatch)
on:
repository_dispatch:
types: [load-test-image]
jobs:
load-test-with-jmeter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install postman to jmeter converter
# run: |
# npm install -s postman-jmeter
run: npm install
- name: install jmeter
run: |
java -version
wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.zip
unzip apache-jmeter-5.6.3.zip
cd apache-jmeter-5.6.3/bin
./jmeter -v
pwd
- name: Print env
env:
MESSAGE: ${{ github.event.client_payload.envFile }}
run: |
echo $MESSAGE
- name: Convert postman collection with environment
if: github.event.client_payload.envFile != ''
run: |
mkdir ./assets/${{ github.run_id}}
node ./bin/convert-postman-jmeter -p ${{ github.event.client_payload.collectionPath }} -j ./assets/${{ github.run_id }}/${{ github.run_id }}.jmx -o -v=${{ github.event.client_payload.variableStrategy }} -e ${{ github.event.client_payload.envFile }}
- name: Convert postman collection without environment
if: github.event.client_payload.envFile == ''
run: |
echo $MESSAGE
mkdir ./assets/${{ github.run_id}}
node ./bin/convert-postman-jmeter -p ${{ github.event.client_payload.collectionPath }} -j ./assets/${{ github.run_id }}/${{ github.run_id }}.jmx -o -v=${{ github.event.client_payload.variableStrategy }}
- name: Run Stress Tests
run: |
cd ./apache-jmeter-5.6.3/bin
./jmeter -n -t ${{ github.workspace }}/assets/${{ github.run_id }}/${{ github.run_id }}.jmx -l ${{ github.workspace }}/results.csv -e -o ${{ github.workspace }}/output
- name: Generate screenshot of JMeter results
run: |
npm install --global capture-website-cli
capture-website output/index.html --output=./assets/${{ github.run_id }}/screenshot_${{ github.run_id }}.png --width 1280 --height 800
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: jmeter-load-test-image
path: ./assets/${{ github.run_id }}/
- name: Add image to repo
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git status
# mkdir -p assets/images/
# mv screenshot_${{ github.run_id }}.png assets/images/
git add assets/${{ github.run_id }}/*
git commit -m "added JMeter jmx file and results screenshot to assets"
git push
git status
echo "https://github.com/${{github.repository}}/blob/main/assets/images/screenshot_${{ env.GITHUB_RUN_ID }}.png?raw=true"
- name: Send results to postman
run: |
echo "Path: ${{ github.client_payload.collectionPath }} "
node ./bin/respond -w ${{ github.event.client_payload.workspaceID }} -u https://github.com/postman-solutions-eng/postman-jmeter/blob/main/assets/${{ github.run_id }}/screenshot_${{ github.run_id }}.png -r $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID -k ${{ secrets.POSTMAN_API_KEY }} -n $GITHUB_RUN_ID -c ${{ github.event.client_payload.collectionPath }} -b $GITHUB_WORKFLOW