Skip to content

fix cache cleanup

fix cache cleanup #1

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]