Skip to content

Commit

Permalink
Fix: Missed documentation, no TESTING.md
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Le Thanh Duong <olivier@lethanh.be>
  • Loading branch information
hoh and olethanh committed Apr 10, 2024
1 parent e28fcaa commit 1b6d429
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Testing aleph-vm

This procedure describes how to run tests on a local system.

Tests also run on GitHub Actions via [the following workflow](./.github/workflows/test-on-droplets-matrix.yml).

Since these tests create block devices and manipulate network interfaces, they need to run as root.
If you are not comfortable with this, run them in a virtual machine.

## 1. Clone this repository

```shell
git clone https://github.com/aleph-im/aleph-vm.git
```

## 2. Install [hatch](https://hatch.pypa.io/), the project manager

Since installing tools globally is not recommended, we will install `hatch`
in a dedicated virtual environment. Alternatives include using [pipx](https://pipx.pypa.io)
or your distribution.

```shell
python3 -m venv /opt/venv
source /opt/venv/bin/activate

# Inside the venv
pip install hatch
```

## 3. Initialize hatch for running the tests

It is required that the testing virtual environment relies on system packages
for `nftables` instead of the package obtained from `salsa.debian.org` as defined in
[pyproject.toml](./pyproject.toml).

Create the testing virtual environment:
```shell
hatch env create testing
```

Obtain the path to the testing virtual environment.
```
hatch run testing:which python
```

Locate the file named `pyvenv.cfg` in your virtual environment.
Edit it to use system site packages:
```
vim /root/.local/share/hatch/env/virtual/aleph-vm/i5XWCcQ_/testing/pyvenv.cfg
```

Set `include-system-site-packages` to `true`.

Remove the Python library `nftables` from the `hatch` virtual environment:
```shell
hatch run testing:pip uninstall nftables
```

## 4. Run tests

```shell
hatch run testing:test
```

0 comments on commit 1b6d429

Please sign in to comment.