Commit 2ab1240
authored
tests: add patchbay tests (#3986)
## Description
Adds a first round of tests using our new network simulation framework,
[patchbay](https://github.com/n0-computer/patchbay). Patchbay uses Linux
network namespaces to create isolated network topologies with routers,
NATs, and link impairment. This lets us test actual holepunching and NAT
traversal in realistic conditions, without needing any external
infrastructure.
The test suite covers establishing a direct path in different scenarios:
- Holepunching: two devices behind destination-independent NATs connect
via relay, then upgrade to direct.
- Uplink switching: a device changes its network uplink (v4 and v6)
mid-connection and recovers a direct path.
- Interface changes: network interfaces are added or removed while
connected
- Link outage recovery: a device goes offline and comes back, direct
connection resumes
- Degraded links: increasing levels of impairment (latency, jitter,
packet loss) are applied to either side of a connection and holepunching
still succeeds
Some tests that iroh doesn't pass yet are included but marked
`#[ignore]`. They should be un-ignored as we improve things.
### Running the tests
On Linux, things just work with user namespace support:
```sh
cargo make patchbay
# expands to:
cargo nextest run -p iroh --features qlog --test patchbay --profile patchbay
# run a specific test with logs:
RUST_LOG=trace cargo make patchbay holepunch_simple --nocapture
```
Test output is saved in `./target/testdir-current/patchbay/<test-name>`.
Patchbay currently collects tracing logs for each device, qlog files (if
the feature is enabled), and endpoint metrics.
There's also a browser UI for viewing timelines, topologies, and logs.
The UI can also be used to compare different test runs.
```sh
cargo install --git https://github.com/n0-computer/patchbay patchbay-cli
patchbay serve --testdir --open
```
On macOS you'll need to run the patchbay tests in a VM or container. The
`patchbay` CLI includes a tool to set up a container or QEMU VM for
this.
```sh
# both commands default to the container backend on macOS and native on linux
patchbay test -p iroh --test patchbay
patchbay serve --testdir --open
# use --vm to force VM mode even on linux
```
See the [patchbay docs](https://n0-computer.github.io/patchbay/) and
[README](https://github.com/n0-computer/patchbay) for more details.
## Notes and open questions
There's a draft PR with some more tests: #4065, but they need more
thought and work to really cover what we want to test.
## Breaking Changes
None.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.1 parent 065b448 commit 2ab1240
10 files changed
Lines changed: 1439 additions & 99 deletions
File tree
- .config
- .github/workflows
- iroh
- tests
- patchbay
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| 140 | + | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
0 commit comments