Skip to content

Hub Load Test

Hub Load Test #21

Workflow file for this run

name: Hub Load Test
on:
push:
# branches:
# - add-workflow
workflow_dispatch:
inputs:
requst-methold:
description: 'Select request method'
required: true
default: 'GET'
type: choice
options:
- GET
- POST
- POST_WITH_FILES
host:
description: 'Target host'
required: true
default: 'https://api.simplehash.com'
type: choice
options:
- https://api.simplehash.com
- https://edge.stg.storyprotocol.net
number-of-users:
description: 'Number of users(peak concurrency)'
required: true
default: '100'
ramp-up:
description: 'Ramp up (users started/second)'
required: true
default: '2'
run_time:
description: 'Run time (e.g. 20, 20s, 3m, 2h, etc.)'
required: true
default: '10m'
jobs:
load-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set Timestamp
id: set_timestamp
run: |
TIMESTAMP=$(date +'%Y%m%d_%H%M%S')
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
- name: Run Locust
if: ${{ github.event.inputs.requst-methold == 'GET' }}
run: |
rm -rf ./test_report/*
locust -f src/test_scripts/test_get_api.py --headless -u ${{ github.event.inputs.number-of-users }} -r ${{ github.event.inputs.ramp-up }} --run-time ${{ github.event.inputs.run_time }} --host ${{ github.event.inputs.host }} --html ./test_report/load-test-report_${{ steps.set_timestamp.outputs.timestamp }}.html
continue-on-error: true
- name: Run Locust
if: ${{ github.event.inputs.requst-methold == 'POST' }}
run: |
rm -rf ./test_report/*
locust -f src/test_scripts/test_post_api.py --headless -u ${{ github.event.inputs.number-of-users }} -r ${{ github.event.inputs.ramp-up }} --run-time ${{ github.event.inputs.run_time }} --host ${{ github.event.inputs.host }} --html ./test_report/load-test-report_${{ steps.set_timestamp.outputs.timestamp }}.html
continue-on-error: true
- name: Run Locust
if: ${{ github.event.inputs.requst-methold == 'POST_WITH_FILES' }}
run: |
rm -rf ./test_report/*
locust -f src/test_scripts/test_upload_image.py --headless -u ${{ github.event.inputs.number-of-users }} -r ${{ github.event.inputs.ramp-up }} --run-time ${{ github.event.inputs.run_time }} --host ${{ github.event.inputs.host }} --html ./test_report/load-test-report_${{ steps.set_timestamp.outputs.timestamp }}.html
continue-on-error: true
- name: Deploy report to GitHub Pages
if: always()
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./test_report
publish_branch: gh-pages
keep_files: true
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v4
with:
name: hub-load-test-report
path: |
./test_report