forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabend-performance-dispatch.yaml
More file actions
353 lines (350 loc) · 16.9 KB
/
databend-performance-dispatch.yaml
File metadata and controls
353 lines (350 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
on:
repository_dispatch:
types: [ run_perf, rerun_perf, rerun_perf_all ]
name: Build Docker Image on official docker hub (primary for benchmarking and CI tests)
jobs:
slack-notification-start:
name: Slack Notification Start
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://avatars.githubusercontent.com/u/80994548?s=200&v=4
SLACK_COLOR: good
SLACK_CHANNEL: github-activity
SLACK_MESSAGE: 'start databend performance test!'
SLACK_TITLE: databend performance test
SLACK_USERNAME: databend messager
build-current:
name: Build current databend image
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' || github.event.action == 'rerun_perf' }}
runs-on: perf-test
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_ORG: datafuselabs
GITHUB_REPO: databend
GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
SHA: ${{ github.event.client_payload.CURRENT_BRANCH }}
PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }}
LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }}
UUID: ${{ github.event.client_payload.UUID }}
ITERATION: 100
REGION: ${{ github.event.client_payload.REGION }}
BUCKET: ${{ github.event.client_payload.BUCKET }}
ENDPOINT: ${{ github.event.client_payload.ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
AWS_DEFAULT_OUTPUT: json
steps:
- name: Update status to pending
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
run: |
echo "update github pr status"
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"pending","context":"build-current-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Checkout given branch
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: actions/checkout@v2
with:
ref: ${{ env.SHA }}
- name: build all binary
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
id: make_release
run: |
# enable sccache
sccache --start-server
echo $HOME
export SCCACHE_DIR=/home/runner/.cache/sccache
export RUSTC_WRAPPER=sccache
cargo build --bin=databend-query --bin=databend-meta --target x86_64-unknown-linux-gnu --release
mkdir -p distro
sccache --show-stats
mv target/x86_64-unknown-linux-gnu/release/databend-query ./distro/databend-query
mv target/x86_64-unknown-linux-gnu/release/databend-meta ./distro/databend-meta
mv docker/bootstrap.sh ./distro/bootstrap.sh
mv docker/databend-query-docker.toml ./distro/databend-query-docker.toml
- name: Set up QEMU
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_NAMESPACE }}/databend:perf-${{ env.SHA }}
context: .
platforms: linux/amd64
file: ./docker/cache/Dockerfile
- name: bypass
if: ${{ github.event.action == 'rerun_perf' }}
run: |
echo "bypass build current image step"
# - name: Delete all resources
# if: always()
# run: |
# sccache --stop-server
- name: Update status to failure
if: failure()
run: |
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"failure","context":"build-current-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Update status to success
if: success()
run: |
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"success","context":"build-current-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
build-release:
name: Build reference databend image
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' || github.event.action == 'rerun_perf' }}
runs-on: perf-test
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_ORG: datafuselabs
GITHUB_REPO: databend
GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
SHA: ${{ github.event.client_payload.REF_BRANCH }}
PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }}
LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }}
UUID: ${{ github.event.client_payload.UUID }}
ITERATION: 10
REGION: ${{ github.event.client_payload.REGION }}
BUCKET: ${{ github.event.client_payload.BUCKET }}
ENDPOINT: ${{ github.event.client_payload.ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
AWS_DEFAULT_OUTPUT: json
steps:
- name: Update status to pending
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
run: |
echo "update github pr status"
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"pending","context":"build-ref-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Check out branch
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: actions/checkout@v2
with:
ref: ${{ env.SHA }}
- name: build all binary
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
id: make_debug
run: |
sccache --start-server
echo $HOME
export SCCACHE_DIR=/home/runner/.cache/sccache
export RUSTC_WRAPPER=sccache
cargo build --bin=databend-query --bin=databend-meta --target x86_64-unknown-linux-gnu --release
mkdir -p distro
sccache --show-stats
mv target/x86_64-unknown-linux-gnu/release/databend-query ./distro/databend-query
mv target/x86_64-unknown-linux-gnu/release/databend-meta ./distro/databend-meta
mv docker/bootstrap.sh ./distro/bootstrap.sh
- name: Set up QEMU
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' }}
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_NAMESPACE }}/databend:perf-${{ env.SHA }}
context: .
platforms: linux/amd64
file: ./docker/cache/Dockerfile
- name: bypass
if: ${{ github.event.action == 'rerun_perf' }}
run: |
echo "bypass build ref image step"
- name: Update status to failure
if: failure()
run: |
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"failure","context":"build-ref-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Update status to success
if: success()
run: |
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"success","context":"build-ref-image-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
run_funcbench:
name: Running databend single performance testing
if: ${{ github.event.action == 'run_perf' || github.event.action == 'rerun_perf_all' || github.event.action == 'rerun_perf' }}
runs-on: perf-test
needs: [ build-current, build-release ]
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_ORG: datafuselabs
GITHUB_REPO: databend
GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
CPU: 4300m
MEMORY: 4Gi
# define reference and compare branches for performance test
# suppose branch building for current and reference works well
CURRENT: ${{ github.event.client_payload.CURRENT_BRANCH }}
REFERENCE: ${{ github.event.client_payload.REF_BRANCH }}
PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }}
LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }}
UUID: ${{ github.event.client_payload.UUID }}
ITERATION: 10
# S3 storage for report and status updates
CLUSTER_NAME: ${{ github.run_id }}
REGION: ${{ github.event.client_payload.REGION }}
BUCKET: ${{ github.event.client_payload.BUCKET }}
ENDPOINT: ${{ github.event.client_payload.ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
AWS_DEFAULT_OUTPUT: json
DELETE_CLUSTER_AFTER_RUN: false
steps:
- name: Update status to pending
run: |
echo "update github pr status"
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"pending","context":"run-perf-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: datafuselabs/test-infra
ref: main
- name: build latest binary
run: |
export PATH=$PATH:/usr/local/go/bin
make build
- uses: AbsaOSS/k3d-action@v1.5.0
name: "Create Single Cluster"
with:
cluster-name: ${{env.CLUSTER_NAME}}
args: >-
-p "8083:80@agent[0]"
-p "8443:443@agent[0]"
-p "5053:53/udp@agent[0]"
-p "8084:80@agent[1]"
-p "8444:443@agent[1]"
-p "5054:53/udp@agent[1]"
--api-port 127.0.0.1:6445
--agents 2
--no-lb
--k3s-server-arg "--no-deploy=traefik,servicelb,metrics-server"
--timeout 360s
--wait
- name: testing environment set up
run: |
kubectl label node k3d-${{ env.CLUSTER_NAME }}-agent-0 test-branch=${{env.CURRENT}}
kubectl label node k3d-${{ env.CLUSTER_NAME }}-agent-1 test-branch=${{env.REFERENCE}}
kubectl wait -n kube-system --timeout=360s --for condition=Ready --all pods
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml
kubectl apply -f ./manifests/lb_configs.yaml
kubectl delete ns runner-system --ignore-not-found
kubectl create ns runner-system
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml
kubectl wait -n metallb-system --timeout=360s --for condition=Ready --all pods
- name: Start performance testing
id: perf
run: >-
echo ${{ env.UUID }};
export ENDPOINT=$(echo $ENDPOINT | grep -oP '(http|https)://\K\S+');
echo $ENDPOINT;
make resource_apply -j 2;
echo "Successfully deployed test pods, start to do performance test";
make run_perf -j 2;
kubectl logs -n default -l tag=current -f >current.log &
kubectl logs -n default -l tag=ref -f >ref.log &
kubectl wait --for=condition=complete jobs --all -n default --timeout=7200s 2>/dev/null;
echo "Finished performance tests, upload reports";
aws s3 --endpoint-url ${{ env.ENDPOINT }} cp ./current.log s3://$BUCKET/${{ env.PR_NUMBER}}/${{env.LAST_COMMIT_SHA}}/${{env.UUID}}/log/current.log;
aws s3 --endpoint-url ${{ env.ENDPOINT }} cp ./ref.log s3://$BUCKET/${{ env.PR_NUMBER}}/${{env.LAST_COMMIT_SHA}}/${{env.UUID}}/log/ref.log;
make run_compare;
kubectl wait --for=condition=complete jobs --all -n default --timeout=7200s 2>/dev/null;
export REPORT=${{ env.ENDPOINT }}/report/${{ env.PR_NUMBER}}/${{env.LAST_COMMIT_SHA}}/${{env.UUID}}/performance.html;
export UPLOADED=$(for i in {1..10}; do if [[ $(curl -i -s $REPORT | grep -c "<Code>NoSuchKey</Code>") == 0 ]]; then echo "Uploaded" && break; else kubectl delete jobs -n default --all && make run_compare && kubectl wait --for=condition=complete jobs --all -n default --timeout=7200s 2>/dev/null && echo "retry"; fi; done | grep -c "Uploaded");
if [[ $UPLOADED == 0 ]]; then echo "cannot upload compare file to S3" && exit 1; else echo "upload success!"; fi;
echo ::set-output name=report::"report url: $REPORT"
- name: Update status to failure
if: failure()
run: |
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"failure","context":"run-perf-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Slack Notification Fail
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://avatars.githubusercontent.com/u/80994548?s=200&v=4
SLACK_COLOR: ${{ job.status }}
SLACK_CHANNEL: github-activity
SLACK_MESSAGE: ${{ env.GITHUB_STATUS_TARGET_URL }}
SLACK_TITLE: databend performance test
SLACK_USERNAME: databend messager
- name: Update status to success
if: success()
run: |
export TARGET_URL=${{env.ENDPOINT}}/report/${{ env.PR_NUMBER }}/${{env.LAST_COMMIT_SHA}}/${{ env.UUID }}/performance.html
curl -i -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
--data '{"state":"success","context":"run-perf-status","target_url":"'$TARGET_URL'"}' \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA"
- name: Slack Notification Success
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://avatars.githubusercontent.com/u/80994548?s=200&v=4
SLACK_COLOR: ${{ job.status }}
SLACK_CHANNEL: github-activity
SLACK_MESSAGE: ${{ steps.perf.outputs.report }}
SLACK_TITLE: databend performance test
SLACK_USERNAME: databend messager
- name: Delete all resources
if: always()
run: |
k3d cluster delete ${{ env.CLUSTER_NAME }}