Requirements:
- Docker (with buildx plugin:
sudo apt install docker-buildx-plugin
) - Linux Traffic Control (tc) with Network Emulation (netem)
Python setup
# Tests use Python 3.10
# It can be installed using `virtualenv`
# Install it if missing
sudo apt-get install virtualenv
# Initialize virtualenv
virtualenv .venv --python=python3.10
Build and run
# Dockerfiles take local release or debug binaries (if release is missing)
cargo build --workspace --release
cargo build -p ya-relay-client --example http_client --release
# Switch to Python 3.10
source .venv/bin/activate
# Install poetry
pip install poetry
# Install dependencies
poetry install
# Run tests
poetry run pytest
Running one specific test
poetry run pytest test_client.py::test_client
Test development checks
source .venv/bin/activate
# Assuming build and run was alredy performed
poetry run poe checks
Enabling debug logs (printing Docker containers output)
poetry run pytest --log-cli-level=debug
ya-relay
latency tests require enabling Network Emulation (NETEM) feature.
To enable it necessary is to build boot image.
# Install necessary tools
sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev
# Clone WSL2 linux kernel repository (tested on 5.15.90.4)
git clone --no-tags --no-recurse-submodules --depth=1 --branch linux-msft-wsl-5.15.90.4 [email protected]:microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel;
# Configure build
make menuconfig
# Select `< Load >` and use path `arch/x86/configs/config-wsl`.
# Then go to
# `Networking support`` -> `Networking options` -> `QoS and/or fair queuing`
# and mark "Network emulator (NETEM)" as "<*>" (using Space key).
# Finally `< Save >` config as `my_config` and `< Exit >` from menu.
# Build boot image
make -j8 KCONFIG_CONFIG=my_config
Copy boot image from WSL2-Linux-Kernel/arch/x86/boot/bzImage
in WSL2 filesystem into e.g. C:\Users\%USERNAME%\bzImage
.
Configure boot image in C:\Users\%USERNAME%\.wslconfig
(replace USERNAME
):
[wsl2]
kernel=C:\\Users\\USERNAME\\bzImage
Run wsl --shutdown
and start WSL again.