15
15
# Make sure 1. this is a PR, not an issue 2. it contains "/run performance test" anywhere in the body
16
16
if : github.event.issue.pull_request && contains(github.event.comment.body, '/run performance test')
17
17
runs-on : ubuntu-latest
18
+ outputs :
19
+ request_count : ${{ steps.output.outputs.request_count }}
20
+ failure_count : ${{ steps.output.outputs.failure_count }}
21
+ med_time : ${{ steps.output.outputs.med_time }}
22
+ avg_time : ${{ steps.output.outputs.avg_time }}
23
+ min_time : ${{ steps.output.outputs.min_time }}
24
+ max_time : ${{ steps.output.outputs.max_time }}
25
+ requests_per_sec : ${{ steps.output.outputs.requests_per_sec }}
18
26
steps :
19
27
- name : Set up WireGuard
20
28
uses :
egor-tensin/[email protected]
@@ -52,19 +60,60 @@ jobs:
52
60
run : |
53
61
cd ../driver
54
62
sudo make web sql="${{ secrets.DB_CONN_STRING }}"
63
+ - name : Check out delphi-admin
64
+ uses : actions/checkout@v3
65
+ with :
66
+ repository : cmu-delphi/delphi-admin
67
+ token : ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
68
+ path : delphi-admin
55
69
- name : Build & run Locust
70
+ continue-on-error : true # sometimes ~2-5 queries fail, we shouldn't end the run if that's the case
56
71
run : |
57
- cd ../driver/repos/ delphi/delphi-epidata/tests/performance
72
+ cd delphi-admin/load-testing/locust
58
73
docker build -t locust .
59
- docker run --net=host -v $PWD:/mnt/locust -e CSV=/mnt/locust/v4-requests-smaller.csv locust -f /mnt/locust/v4.py --host http://127.0.0.1:10080/ --users 10 --spawn-rate 1 --headless -t 15m
74
+ export CSV=v4-requests-as_of.csv
75
+ touch output_stats.csv && chmod 666 output_stats.csv
76
+ touch output_stats_history.csv && chmod 666 output_stats_history.csv
77
+ touch output_failures.csv && chmod 666 output_failures.csv
78
+ touch output_exceptions.csv && chmod 666 output_exceptions.csv
79
+ 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
80
+ - name : Produce output for summary
81
+ id : output
82
+ uses : jannekem/run-python-script-action@v1
83
+ with :
84
+ script : |
85
+ import os
86
+
87
+ def write_string(name, value):
88
+ with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
89
+ print(f'{name}={value}', file=fh)
90
+
91
+ def write_float(name, value):
92
+ write_string(name, "{:.2f}".format(float(value)))
60
93
61
- comment-output :
94
+ with open("delphi-admin/load-testing/locust/output_stats.csv", "r", encoding="utf-8", errors="ignore") as scraped:
95
+ final_line = scraped.readlines()[-1].split(",")
96
+ write_string('request_count', final_line[2])
97
+ write_string('failure_count', final_line[3])
98
+ write_float('med_time', final_line[4])
99
+ write_float('avg_time', final_line[5])
100
+ write_float('min_time', final_line[6])
101
+ write_float('max_time', final_line[7])
102
+ write_float('requests_per_sec', final_line[9])
103
+
104
+ - name : Archive results as artifacts
105
+ uses : actions/upload-artifact@v3
106
+ with :
107
+ name : locust-output
108
+ path : |
109
+ delphi-admin/load-testing/locust/output_*.csv
110
+
111
+ comment-success :
62
112
runs-on : ubuntu-latest
63
- if : success() || failure() # but not if skipped
113
+ if : success()
64
114
needs : run-perftests
65
115
steps :
66
116
- name : Comment run results
67
- # URL that links to run results
68
117
env :
69
118
GITHUB_WORKFLOW_URL : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
70
119
uses : actions/github-script@v5
@@ -75,6 +124,33 @@ jobs:
75
124
issue_number: context.issue.number,
76
125
owner: context.repo.owner,
77
126
repo: context.repo.repo,
78
- body: '✅ Performance tests complete! Click here to view results: ${{ env.GITHUB_WORKFLOW_URL }}'
127
+ body: `✅ Performance tests complete! Result summary:
128
+ - Total requests: **${{ needs.run-perftests.outputs.request_count }}**
129
+ - Total failures: **${{ needs.run-perftests.outputs.failure_count }}**
130
+ - Min response time: **${{ needs.run-perftests.outputs.min_time }} ms**
131
+ - Max response time: **${{ needs.run-perftests.outputs.max_time }} ms**
132
+ - Average response time: **${{ needs.run-perftests.outputs.avg_time }} ms**
133
+ - Median response time: **${{ needs.run-perftests.outputs.med_time }} ms**
134
+ - Requests per second: **${{ needs.run-perftests.outputs.requests_per_sec }}**
135
+
136
+ Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
79
137
})
80
138
139
+ comment-failure :
140
+ runs-on : ubuntu-latest
141
+ if : failure()
142
+ needs : run-perftests
143
+ steps :
144
+ - name : Comment run results
145
+ env :
146
+ GITHUB_WORKFLOW_URL : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
147
+ uses : actions/github-script@v5
148
+ with :
149
+ github-token : ${{secrets.GITHUB_TOKEN}}
150
+ script : |
151
+ github.rest.issues.createComment({
152
+ issue_number: context.issue.number,
153
+ owner: context.repo.owner,
154
+ repo: context.repo.repo,
155
+ body: `❌ Performance tests failed! Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
156
+ })
0 commit comments