forked from virtuallynathan/qpep
-
Notifications
You must be signed in to change notification settings - Fork 2
346 lines (302 loc) · 11 KB
/
performance.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
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
name: PerformanceTests
env:
SERVER_ADDRESS: ${{ inputs.server_private_address || '172.31.38.198' }}
LISTEN_ADDRESS: 127.0.0.1
SERVER_PUBLIC_ADDRESS: ${{ inputs.server_public_address || '35.163.142.7' }}
CLIENT_LISTEN_ADDRESS: ${{ inputs.client_listen_address || '172.31.21.30' }}
SERVER_WAIT_TIMEOUT: ${{ inputs.server_wait_timeout || 150 }}
CONNECT_DELAY_MS: ${{ inputs.connect_delay_ms || 100 }}
CONNECT_DELAY_DEVICE: ${{ inputs.connect_delay_device || 'eth0' }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_INSTANCE_ID: ${{ secrets.AWS_INSTANCE_ID }}
on:
schedule:
- cron: '1 1 * * *'
workflow_dispatch:
inputs:
server_public_address:
description: 'public address for the server'
type: string
default: 35.163.142.7
required: true
server_private_address:
description: 'private address for the server'
type: string
default: 172.31.38.198
required: true
client_listen_address:
description: 'private address for the client to listen on'
type: string
default: 172.31.21.30
required: true
server_wait_timeout:
description: 'Server global timeout for tests'
type: integer
default: 150
required: false
connect_delay_ms:
description: 'connection delay in milliseconds set on the server'
type: integer
default: 0
required: true
connect_delay_device:
description: 'serverside network device to set delay on'
type: string
default: eth0
required: true
keep_aws_running:
description: 'keeps aws vm running for subsequent runs'
type: boolean
default: false
required: true
run-name: Performance Testing [${{ github.event_name }}][${{ github.head_ref || github.ref_name }}] - ${{ inputs.server_public_address || '35.163.142.7' }}/${{ inputs.connect_delay_ms || '500' }}ms delay
jobs:
launch-aws-vm:
runs-on: ubuntu-latest
steps:
- name: Install AWS cli
id: install-aws-cli
uses: unfor19/install-aws-cli-action@master
with:
version: "2"
- run: |
aws --version
# run the instance
aws ec2 start-instances --instance-ids ${{ secrets.AWS_INSTANCE_ID }}
shell: bash
- run: |
# assure that the instance is stopped on error
aws ec2 stop-instances --instance-ids ${{ secrets.AWS_INSTANCE_ID }}
shell: bash
if: ${{ failure() && ! inputs.keep_aws_running }}
stop-aws-vm:
runs-on: ubuntu-latest
needs: run-client
if: ${{ always() && ! inputs.keep_aws_running }}
steps:
- name: Install AWS cli
id: install-aws-cli
uses: unfor19/install-aws-cli-action@master
with:
version: "2"
- run: |
# assure that the instance is stopped even on error
aws ec2 stop-instances --instance-ids ${{ secrets.AWS_INSTANCE_ID }}
shell: bash
run-client:
runs-on: vm-client
needs: launch-aws-vm
strategy:
matrix:
download_size: [ 100, 10, 1 ]
connections_number: [ 4, 1 ]
steps:
- uses: actions/checkout@v3
with:
clean: true
ref: ${{ github.head_ref || github.ref_name }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.10
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
static: false
version: 8.1.0
- name: Prepare
shell: powershell
run: |
New-Item -Path . -Name "build" -ItemType "directory" -Force
New-Item -Path . -Name "build/config" -ItemType "directory" -Force
$config = Get-Content -Path ./docker/client-env/qpep.yml.tpl
$config = $config.replace('<QPEP_GATEWAY>',$env:SERVER_PUBLIC_ADDRESS)
$config = $config.replace('<QPEP_ADDRESS>',$env:CLIENT_LISTEN_ADDRESS)
$config > ./build/config/qpep.yml
Copy-Item "./windivert/x64/*" -Destination "./build"
- name: Prepare tests reporting
run: |
go install github.com/jstemmer/[email protected]
- name: Build Client
shell: cmd
run: |
set CGO_ENABLED=1
set GOOS=windows
set GOHOSTARCH=amd64
set GOHOSTOS=windows
go build -v -o build/qpep.exe
- name: Run Client
shell: powershell
run: |
cd build/
Start-Process qpep.exe -Wait -ArgumentList ("/client /service install")
Start-Process qpep.exe -Wait -ArgumentList ("/client /service start")
Start-Sleep -Seconds 5
- name: Wait Server
shell: powershell
run: |
$Stoploop = $false
[ int ]$Retrycount = "60"
do {
try {
Write-Host "Echoing server..."
Invoke-WebRequest -Uri "http://${{ env.SERVER_PUBLIC_ADDRESS }}:444/api/v1/server/status" -UseBasicParsing -TimeoutSec 2
Write-Host "Job completed"
$Stoploop = $true
}
catch {
$Retrycount = $Retrycount - 1
if ($Retrycount -gt 0){
Start-Sleep -Seconds 2
}
else {
Write-Error "Could not get server after 20 retries." -ErrorAction Stop
}
}
}
While ($Stoploop -eq $false)
- name: Run Tests
shell: cmd
run: |
cd docker/speedtests/
go test speed_test.go -v -c -o speedtests.test
.\speedtests.test -target_url http://${{ env.SERVER_PUBLIC_ADDRESS }}:8080/target_${{ matrix.download_size }}M.dat ^
-expect_mb ${{ matrix.download_size }} -connections_num ${{ matrix.connections_number }} ^
-test.v -test.timeout 5m > speedtests.out
go run utils/plotter.go output.csv "Client speed test [Delay:${{ env.CONNECT_DELAY_MS }}ms][TargetSize:${{ matrix.download_size }}M][Connections:${{ matrix.connections_number }}]"
- name: Stop Client
if: always()
shell: powershell
run: |
cd build/
Start-Process qpep.exe -Wait -ArgumentList ("/client /service stop")
Start-Process qpep.exe -Wait -ArgumentList ("/client /service uninstall")
Start-Sleep -Seconds 5
try {
Get-Process qpep | Stop-Process
}
catch
{ }
- name: Reset Proxy
if: always()
run: |
go run docker/speedtests/utils/reset_proxy_util.go
- uses: actions/upload-artifact@v3
with:
name: client_${{ env.CONNECT_DELAY_MS }}ms_${{ matrix.download_size }}MB_${{ matrix.connections_number }}conn
path: |
${{ github.workspace }}/docker/speedtests/output.csv
${{ github.workspace }}/docker/speedtests/speedtests.out
${{ github.workspace }}/docker/speedtests/speedtests.log
${{ github.workspace }}/build/*.log
- uses: actions/upload-artifact@v3
with:
name: graph_client_${{ env.CONNECT_DELAY_MS }}ms_${{ matrix.download_size }}MB_${{ matrix.connections_number }}conn
path: |
${{ github.workspace }}/docker/speedtests/data.png
- name: Auto-cancel workflow on error
if: failure()
uses: andymckay/[email protected]
run-server:
runs-on: vm-server
needs: launch-aws-vm
steps:
- name: Pre-Cleanup
run: |
sudo rm -rf docker/server-data-env/output/* || true
- uses: actions/checkout@v3
with:
clean: true
ref: ${{ github.head_ref || github.ref_name }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.10
- name: Build Server
env:
QPEP_BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
docker version
cd docker/
pushd build-linux/
docker build --no-cache -t project-faster/qpep_server .
- name: Run data server
run: |
cd docker/server-data-env/
pushd http-data/
bash gen-local-data.sh
popd
docker compose up -d
- name: Run Server
run: |
cd docker/server-env/
docker compose up -d
- name: Reset connection delay
run: |
sudo bash ${{ github.workspace }}/.github/workflows/set_delay_port.sh -d
- name: Set connection delay
if: inputs.connect_delay_device > 0
run: |
sudo bash ${{ github.workspace }}/.github/workflows/set_delay_port.sh "${{ env.CONNECT_DELAY_MS }}" "${{ env.CONNECT_DELAY_DEVICE }}"
- name: Wait Tests
timeout-minutes: 60 # max allowed timeouts
run: |
# initial wait for server setup
sleep 60
echo [Starting wait for tests execution...]
CONN_NUM=1
RETRIES=${{ env.SERVER_WAIT_TIMEOUT }}
while ! (( RETRIES <= 0 ));
do
CONN_NUM=$(curl -s -XGET -H 'Accept:application/json' http://127.0.0.1:444/api/v1/server/echo | jq .total_connections || true)
echo "Connections alive: $CONN_NUM"
if (( CONN_NUM <= 0 )); then
(( RETRIES -= 1 )) || true
echo "Remaining $RETRIES retries"
else
(( RETRIES=${{ env.SERVER_WAIT_TIMEOUT }} )) || true
echo "Remaining $RETRIES retries"
fi
sleep 1
done
echo [Wait done]
- name: Stop Server Container
if: always()
run: |
cd docker/server-env/
docker compose down -v
- name: Stop Data Server Container
if: always()
run: |
cd docker/server-data-env/
docker compose down -v
- name: Generate results
run: |
cd docker/speedtests/
go run utils/plotter.go ${{ github.workspace }}/docker/server-data-env/output/data.csv "Server speed test [Delay:${{ env.CONNECT_DELAY_MS }}ms]" "perf-dw-speed"
- uses: actions/upload-artifact@v3
with:
name: server_${{ env.CONNECT_DELAY_MS }}ms
path: |
${{ github.workspace }}/docker/server-data-env/output/data.csv
${{ github.workspace }}/build/*.log
- uses: actions/upload-artifact@v3
with:
name: graph_server_${{ env.CONNECT_DELAY_MS }}ms
path: |
${{ github.workspace }}/docker/speedtests/data.png
- name: Cleanup
if: always()
run: |
sudo bash ${{ github.workspace }}/.github/workflows/set_delay_port.sh -d || true
sudo rm -rf docker/server-data-env/output/* || true
- name: Clean Docker data
if: failure()
run: |
docker system prune -af || true
- name: Auto-cancel workflow on error
if: failure()
uses: andymckay/[email protected]