forked from Kong/kong
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (156 loc) · 6.1 KB
/
perf.yml
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
name: Performance Test
on:
pull_request:
issue_comment:
schedule:
# don't know the timezone but it's daily at least
- cron: '0 7 * * *'
env:
terraform_version: '0.15.3'
jobs:
perf:
name: RPS, latency and flamegraphs
runs-on: ubuntu-20.04
if: |
github.event_name == 'schedule' ||
(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'perf(')) ||
(github.event_name == 'issue_comment' && github.event.action == 'created' &&
github.event.issue.pull_request &&
contains('["OWNER", "COLLABORATOR", "MEMBER"]', github.event.comment.author_association) &&
(startsWith(github.event.comment.body, '/perf') || startsWith(github.event.comment.body, '/flamegraph'))
)
steps:
- name: Checkout Kong source code
uses: actions/checkout@v2
# Fetch all history for all tags and branches
with:
fetch-depth: 0
- name: Install OpenResty
run: |
openresty_version=$(cat .requirements | grep RESTY_VERSION= | cut -d= -f2)
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" | \
sudo tee /etc/apt/sources.list.d/openresty.list
sudo apt-get update
sudo apt-get install "openresty=${openresty_version}*" "openresty-resty=${openresty_version}*" -y
sudo apt-mark hold openresty
- name: Install Dependencies
run: |
wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz -O - |tar zxvf -
pushd luarocks-*/
./configure --with-lua=/usr/local/openresty/luajit/ \
--lua-suffix=jit \
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
sudo make install
popd
# just need the lua files to let all imports happy
# the CI won't actually run Kong locally
git clone https://github.com/kong/lua-kong-nginx-module /tmp/lua-kong-nginx-module
pushd /tmp/lua-kong-nginx-module
sudo make LUA_LIB_DIR=/usr/local/share/lua/5.1/ install
popd
# in Kong repository
sudo apt install libyaml-dev -y
sudo make dev
# terraform!
wget https://releases.hashicorp.com/terraform/${{ env.terraform_version }}/terraform_${{ env.terraform_version }}_linux_amd64.zip
unzip terraform_${{ env.terraform_version }}_linux_amd64.zip
sudo mv terraform /usr/bin/
- name: Choose perf suites
id: choose_perf
run: |
suites=$(echo "${{ github.event.comment.body }}" | awk '{print $1}')
tags=$(echo "${{ github.event.comment.body }}" | awk '{print $2}')
if [[ $suite == "/flamegraph" ]]; then
suites="02-flamegraph"
if [[ -z $tags ]]; then
tags="simple"
fi
elif [[ $suite == "/perf" ]]; then
suites="01-rps"
if [[ -z $tags ]]; then
tags="baseline,single_route"
fi
else
# if not specified by comment, run both
suites="01-rps 02-flamegraph"
if [[ -z $tags ]]; then
tags="baseline,single_route,simple"
fi
fi
echo ::set-output name=suites::"$suites"
echo ::set-output name=tags::"$tags"
- name: Run Tests
env:
PERF_TEST_VERSIONS: git:${{ github.sha }},git:master
PERF_TEST_PACKET_PROJECT_ID: ${{ secrets.PERF_TEST_PACKET_PROJECT_ID }}
PERF_TEST_PACKET_AUTH_TOKEN: ${{ secrets.PERF_TEST_PACKET_AUTH_TOKEN }}
PERF_TEST_DRIVER: terraform
run: |
for suite in ${{ steps.choose_perf.outputs.suites }}; do
bin/busted -o gtest spec/04-perf/$suite/ \
-t "${{ steps.choose_perf.outputs.tags }}"
done
- name: Teardown
# Note: by default each job has if: ${{ success() }}
if: always()
env:
PERF_TEST_VERSIONS: git:${{ github.sha }},git:master
PERF_TEST_PACKET_PROJECT_ID: ${{ secrets.PERF_TEST_PACKET_PROJECT_ID }}
PERF_TEST_PACKET_AUTH_TOKEN: ${{ secrets.PERF_TEST_PACKET_AUTH_TOKEN }}
PERF_TEST_DRIVER: terraform
PERF_TEST_TEARDOWN_ALL: "true"
run: |
bin/busted -o gtest spec/04-perf/99-teardown/
- name: Save results
uses: actions/upload-artifact@v2
with:
name: rps-and-latency
path: |
output/result.txt
retention-days: 31
- name: Save flamegrpahs
uses: actions/upload-artifact@v2
with:
name: flamegraphs
path: |
output/*.svg
retention-days: 31
- name: Save error logs
uses: actions/upload-artifact@v2
with:
name: error_logs
path: |
output/*.log
retention-days: 31
- name: Output
id: output
run: |
if [[ "${{ steps.choose_perf.outputs.suites }}" =~ "02-flamegraph" ]]; then
result="Please see Github Actions artifacts for flamegraphs.
"
fi
result="${result}$(cat output/result.txt)" || true
# https://github.community/t/set-output-truncates-multiline-strings/16852/2
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"
echo ::set-output name=result::"$result"
- name: Comment
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request)
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
## :rocket: Performance test result
**Test Suite**: ${{ steps.choose_perf.outputs.suites }} (${{ steps.choose_perf.outputs.tags }})
<details><summary>Click to expand</summary>
```
${{ steps.output.outputs.result }}
Kong error logs are also available in Github Actions artifacts.
```
</details>
[Download Artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts)