forked from virtuallynathan/qpep
-
Notifications
You must be signed in to change notification settings - Fork 2
393 lines (347 loc) · 12.3 KB
/
common-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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
name: Performance Common
on:
workflow_call:
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: 'address for the client to listen on'
type: string
default: 192.168.1.21
required: true
server_wait_timeout:
description: 'Server global timeout for tests'
type: number
default: 30
required: false
connection_delay_ms:
description: 'connection delay in milliseconds set on the server'
type: number
default: 0
required: false
connection_delay_device:
description: 'serverside network device to set delay on'
type: string
default: eth0
required: true
download_size:
description: 'Size of the file MB to download'
type: number
default: 1
required: false
connections_number:
description: 'Number of concurrent connections to execute'
type: number
default: 1
required: false
backend:
description: 'Backend to use: quic-go or quicly-go'
type: string
default: 'quic-go'
required: false
cca:
description: 'CCA algorithm to use (if supported by the backend)'
type: string
default: 'reno'
required: false
ignore_caches:
description: 'resets caches to force new build'
type: boolean
default: false
required: true
jobs:
build-client:
runs-on: vm-client
steps:
- name: Install the github cli
uses: ksivamuthu/actions-setup-gh-cli@<VERSION>
with:
version:
2.24.3
run: |
gh version
- name: Clear cache
if: ${{ inputs.ignore_caches }}
run: |
gh cache delete qpep-${{ github.head_ref || github.ref_name }}
- name: Restore cached build
if: ${{ ! inputs.ignore_caches }}
id: cache-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/build
key: qpep-${{ github.head_ref || github.ref_name }}
- name: Cleanup
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
shell: powershell
run: rm ${{ github.workspace }}\* -r -force
- uses: actions/checkout@v4
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
with:
clean: true
submodules: true
- name: Set up Go
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
uses: actions/setup-go@v4
with:
go-version: 1.20.14
- name: Set up CMake
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
uses: jwlawson/[email protected]
with:
cmake-version: '3.22.x'
- name: Prepare
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
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>','${{ inputs.server_public_address }}')
$config = $config.replace('<QPEP_ADDRESS>','${{ inputs.client_listen_address }}')
$config = $config.replace('<QPEP_BACKEND>','${{ inputs.backend }}')
$config = $config.replace('<QPEP_CCA>','${{ inputs.cca }}')
$config > ./build/config/qpep.yml
write-host '${{ inputs.server_public_address }}'
write-host '${{ inputs.client_listen_address }}'
write-host $config
Copy-Item "./windivert/x64/*" -Destination "./build"
- name: Build Client (Backends)
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
shell: cmd
run: |
set CGO_ENABLED=1
set GOOS=windows
set GOHOSTARCH=amd64
set GOHOSTOS=windows
cd backend/
go generate
- name: Build Client
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
shell: cmd
run: |
set CGO_ENABLED=1
set GOOS=windows
set GOHOSTARCH=amd64
set GOHOSTOS=windows
go build -v -o build/qpep.exe
- name: Cache build
if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/build
key: qpep-${{ github.head_ref || github.ref_name }}
run-client:
runs-on: vm-client
needs: [build-client, build-server]
strategy:
max-parallel: 1
matrix:
download_size: [ 5, 10 ]
connections_number: [ 1, 4 ]
env:
REMOTE_GATEWAY: ${{ inputs.server_public_address }}
LISTEN_ADDRESS: ${{ inputs.client_listen_address }}
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: Cache build
id: cache-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/build
key: qpep-${{ github.head_ref || github.ref_name }}
fail-on-cache-miss: true
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.14
- name: Prepare tests reporting
run: |
go install github.com/jstemmer/[email protected]
- name: Run Client
shell: cmd
run: |
cd build/
cmd /c "START /b qpep.exe -c"
- name: Wait Server
shell: powershell
run: |
$Stoploop = $false
[ int ]$Retrycount = "20"
do {
try {
Write-Host "Echoing server..."
Invoke-WebRequest -Uri "http://${{ inputs.server_public_address }}:444/api/v1/server/echo" -UseBasicParsing -TimeoutSec 1
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://${{ inputs.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:${{ inputs.connection_delay_ms }}ms][TargetSize:${{ matrix.download_size }}M][Connections:${{ matrix.connections_number }}]"
- name: Stop Client
if: always()
shell: powershell
run: |
Get-Process qpep | Stop-Process
- name: Reset Proxy
if: always()
run: |
go run docker/speedtests/utils/reset_proxy_util.go
- uses: actions/upload-artifact@v4
with:
name: client_${{ inputs.connection_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 }}/docker/speedtests/data.png
${{ github.workspace }}/build/*.log
- name: Auto-cancel workflow on error
if: failure()
uses: andymckay/[email protected]
build-server:
runs-on: vm-server
steps:
- name: Pre-Cleanup
run: |
sudo rm -rf docker/server-data-env/output/* || true
- uses: actions/checkout@v3
with:
clean: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.14
- name: Cleanup all docker
if: ${{ inputs.ignore_caches }}
run: |
docker system prune -af || true
- name: Build Server
run: |
docker version
cd docker/
pushd build-linux/
docker build -t project-faster/qpep_server \
--build-arg QPEP_REPO=https://github.com/${{github.repository}}.git \
--build-arg QPEP_BRANCH=${{ github.head_ref || github.ref_name }} \
--build-arg QPEP_REV=HEAD \
--build-arg QPEP_BACKEND=${{ inputs.backend }} \
--build-arg QPEP_CCA=${{ inputs.cca }} \
.
run-server:
runs-on: vm-server
needs: [ build-client, build-server ]
env:
SERVER_ADDRESS: ${{ inputs.server_private_address }}
SERVER_BACKEND: ${{ inputs.backend }}
SERVER_CCA: ${{ inputs.cca }}
LISTEN_ADDRESS: 127.0.0.1
steps:
- name: Pre-Cleanup
run: |
sudo rm -rf docker/server-data-env/output/* || true
- uses: actions/checkout@v3
with:
clean: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.14
- 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.connection_delay_device > 0
run: |
sudo bash ${{ github.workspace }}/.github/workflows/set_delay_port.sh "${{ matrix.connection_delay_ms }}" "${{ inputs.connection_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=${{ inputs.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=${{ inputs.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:${{ matrix.connection_delay_ms }}ms]" "perf-dw-speed"
- uses: actions/upload-artifact@v3
with:
name: server_${{ matrix.connection_delay_ms }}ms
path: |
${{ github.workspace }}/docker/server-data-env/output/data.csv
${{ github.workspace }}/docker/speedtests/data.png
${{ github.workspace }}/build/*.log
- 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
docker system prune -af || true
- name: Auto-cancel workflow on error
if: failure()
uses: andymckay/[email protected]