|
| 1 | +name: One-time performance testing - 8th November 2023 |
| 2 | + |
| 3 | +# Run "At every 30th minute on day-of-month 8 in November" |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: '*/30 * 8 11 *' |
| 7 | + |
| 8 | +# Add some extra perms to comment on a PR |
| 9 | +permissions: |
| 10 | + pull-requests: write |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + run-perftests: |
| 15 | + # Run this on Delphi's self-hosted runner |
| 16 | + runs-on: self-hosted |
| 17 | + outputs: |
| 18 | + request_count: ${{ steps.output.outputs.request_count }} |
| 19 | + failure_count: ${{ steps.output.outputs.failure_count }} |
| 20 | + med_time: ${{ steps.output.outputs.med_time }} |
| 21 | + avg_time: ${{ steps.output.outputs.avg_time }} |
| 22 | + min_time: ${{ steps.output.outputs.min_time }} |
| 23 | + max_time: ${{ steps.output.outputs.max_time }} |
| 24 | + requests_per_sec: ${{ steps.output.outputs.requests_per_sec }} |
| 25 | + steps: |
| 26 | + - name: Set up WireGuard |
| 27 | + uses: egor-tensin/[email protected] |
| 28 | + with: |
| 29 | + endpoint: '${{ secrets.WG_PERF_ENDPOINT }}' |
| 30 | + endpoint_public_key: '${{ secrets.WG_PERF_ENDPOINT_PUBLIC_KEY }}' |
| 31 | + ips: '${{ secrets.WG_PERF_IPS }}' |
| 32 | + allowed_ips: '${{ secrets.WG_PERF_ALLOWED_IPS }}' |
| 33 | + private_key: '${{ secrets.WG_PERF_PRIVATE_KEY }}' |
| 34 | + - name: Clean files from previous runs |
| 35 | + uses: AutoModality/action-clean@v1 |
| 36 | + - name: Check out repository |
| 37 | + uses: actions/checkout@v3 |
| 38 | + - name: Set up repository # mimics install.sh in the README except that delphi is cloned from the PR rather than main |
| 39 | + run: | |
| 40 | + cd .. |
| 41 | + rm -rf driver |
| 42 | + mkdir -p driver/repos/delphi |
| 43 | + cd driver/repos/delphi |
| 44 | + git clone https://github.com/cmu-delphi/operations |
| 45 | + git clone https://github.com/cmu-delphi/utils |
| 46 | + git clone https://github.com/cmu-delphi/flu-contest |
| 47 | + git clone https://github.com/cmu-delphi/nowcast |
| 48 | + cd ../../ |
| 49 | +
|
| 50 | + cd .. |
| 51 | + cp -R delphi-epidata driver/repos/delphi/delphi-epidata |
| 52 | + cd - |
| 53 | +
|
| 54 | + ln -s repos/delphi/delphi-epidata/dev/local/Makefile |
| 55 | + - name: Build & run epidata |
| 56 | + run: | |
| 57 | + cd ../driver |
| 58 | + sudo make web sql="${{ secrets.DB_CONN_STRING }}" rate_limit="999999/second" |
| 59 | + sudo make redis |
| 60 | + - name: Check out delphi-admin |
| 61 | + uses: actions/checkout@v3 |
| 62 | + with: |
| 63 | + repository: cmu-delphi/delphi-admin |
| 64 | + token: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }} |
| 65 | + path: delphi-admin |
| 66 | + - name: Build & run Locust |
| 67 | + continue-on-error: true # sometimes ~2-5 queries fail, we shouldn't end the run if that's the case |
| 68 | + env: |
| 69 | + PERFTEST_API_KEY: ${{secrets.PERFTEST_API_KEY}} |
| 70 | + run: | |
| 71 | + cd delphi-admin/load-testing/locust |
| 72 | + docker build -t locust . |
| 73 | + export CSV=v4-requests-small.csv |
| 74 | + touch output_stats.csv && chmod 666 output_stats.csv |
| 75 | + touch output_stats_history.csv && chmod 666 output_stats_history.csv |
| 76 | + touch output_failures.csv && chmod 666 output_failures.csv |
| 77 | + touch output_exceptions.csv && chmod 666 output_exceptions.csv |
| 78 | + docker run --net=host -v $PWD:/mnt/locust -e CSV="/mnt/locust/${CSV}" locust -f /mnt/locust/v4.py --host http://127.0.0.1:10080/ --users 10 --spawn-rate 1 --headless -i "$(cat ${CSV} | wc -l)" --csv=/mnt/locust/output |
| 79 | + - name: Produce output for summary |
| 80 | + id: output |
| 81 | + uses: jannekem/run-python-script-action@v1 |
| 82 | + with: |
| 83 | + script: | |
| 84 | + import os |
| 85 | +
|
| 86 | + def write_string(name, value): |
| 87 | + with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: |
| 88 | + print(f'{name}={value}', file=fh) |
| 89 | +
|
| 90 | + def write_float(name, value): |
| 91 | + write_string(name, "{:.2f}".format(float(value))) |
| 92 | +
|
| 93 | + with open("delphi-admin/load-testing/locust/output_stats.csv", "r", encoding="utf-8", errors="ignore") as scraped: |
| 94 | + final_line = scraped.readlines()[-1].split(",") |
| 95 | + write_string('request_count', final_line[2]) |
| 96 | + write_string('failure_count', final_line[3]) |
| 97 | + write_float('med_time', final_line[4]) |
| 98 | + write_float('avg_time', final_line[5]) |
| 99 | + write_float('min_time', final_line[6]) |
| 100 | + write_float('max_time', final_line[7]) |
| 101 | + write_float('requests_per_sec', final_line[9]) |
| 102 | +
|
| 103 | + - name: Archive results as artifacts |
| 104 | + uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: locust-output |
| 107 | + path: | |
| 108 | + delphi-admin/load-testing/locust/output_*.csv |
0 commit comments