Skip to content

Commit f37211b

Browse files
authored
Performance testing testing workflow (#1253)
1 parent c8cc166 commit f37211b

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: One-time performance testing - 9th August 2023
2+
3+
# Run "At every 30th minute on day-of-month 9 in August"
4+
on:
5+
schedule:
6+
- cron: '*/30 * 9 8 *'
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+
runs-on: ubuntu-latest
16+
outputs:
17+
request_count: ${{ steps.output.outputs.request_count }}
18+
failure_count: ${{ steps.output.outputs.failure_count }}
19+
med_time: ${{ steps.output.outputs.med_time }}
20+
avg_time: ${{ steps.output.outputs.avg_time }}
21+
min_time: ${{ steps.output.outputs.min_time }}
22+
max_time: ${{ steps.output.outputs.max_time }}
23+
requests_per_sec: ${{ steps.output.outputs.requests_per_sec }}
24+
steps:
25+
- name: Set up WireGuard
26+
uses: egor-tensin/[email protected]
27+
with:
28+
endpoint: '${{ secrets.WG_PERF_ENDPOINT }}'
29+
endpoint_public_key: '${{ secrets.WG_PERF_ENDPOINT_PUBLIC_KEY }}'
30+
ips: '${{ secrets.WG_PERF_IPS }}'
31+
allowed_ips: '${{ secrets.WG_PERF_ALLOWED_IPS }}'
32+
private_key: '${{ secrets.WG_PERF_PRIVATE_KEY }}'
33+
- name: Check out repository
34+
uses: actions/checkout@v3
35+
- name: Set up repository # mimics install.sh in the README except that delphi is cloned from the PR rather than main
36+
run: |
37+
cd ..
38+
mkdir -p driver/repos/delphi
39+
cd driver/repos/delphi
40+
git clone https://github.com/cmu-delphi/operations
41+
git clone https://github.com/cmu-delphi/utils
42+
git clone https://github.com/cmu-delphi/flu-contest
43+
git clone https://github.com/cmu-delphi/nowcast
44+
cd ../../
45+
46+
cd ..
47+
cp -R delphi-epidata driver/repos/delphi/delphi-epidata
48+
cd -
49+
50+
ln -s repos/delphi/delphi-epidata/dev/local/Makefile
51+
- name: Build & run epidata
52+
run: |
53+
cd ../driver
54+
sudo make web sql="${{ secrets.DB_CONN_STRING }}"
55+
sudo make redis
56+
- name: Check out delphi-admin
57+
uses: actions/checkout@v3
58+
with:
59+
repository: cmu-delphi/delphi-admin
60+
token: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
61+
path: delphi-admin
62+
- name: Build & run Locust
63+
continue-on-error: true # sometimes ~2-5 queries fail, we shouldn't end the run if that's the case
64+
run: |
65+
cd delphi-admin/load-testing/locust
66+
docker build -t locust .
67+
export CSV=v4-requests-small.csv
68+
touch output_stats.csv && chmod 666 output_stats.csv
69+
touch output_stats_history.csv && chmod 666 output_stats_history.csv
70+
touch output_failures.csv && chmod 666 output_failures.csv
71+
touch output_exceptions.csv && chmod 666 output_exceptions.csv
72+
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
73+
- name: Produce output for summary
74+
id: output
75+
uses: jannekem/run-python-script-action@v1
76+
with:
77+
script: |
78+
import os
79+
80+
def write_string(name, value):
81+
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
82+
print(f'{name}={value}', file=fh)
83+
84+
def write_float(name, value):
85+
write_string(name, "{:.2f}".format(float(value)))
86+
87+
with open("delphi-admin/load-testing/locust/output_stats.csv", "r", encoding="utf-8", errors="ignore") as scraped:
88+
final_line = scraped.readlines()[-1].split(",")
89+
write_string('request_count', final_line[2])
90+
write_string('failure_count', final_line[3])
91+
write_float('med_time', final_line[4])
92+
write_float('avg_time', final_line[5])
93+
write_float('min_time', final_line[6])
94+
write_float('max_time', final_line[7])
95+
write_float('requests_per_sec', final_line[9])
96+
97+
- name: Archive results as artifacts
98+
uses: actions/upload-artifact@v3
99+
with:
100+
name: locust-output
101+
path: |
102+
delphi-admin/load-testing/locust/output_*.csv

0 commit comments

Comments
 (0)