Skip to content

tests: add more patchbay tests#4065

Draft
Frando wants to merge 32 commits intomainfrom
Frando/more-patchbay-tests
Draft

tests: add more patchbay tests#4065
Frando wants to merge 32 commits intomainfrom
Frando/more-patchbay-tests

Conversation

@Frando
Copy link
Copy Markdown
Member

@Frando Frando commented Apr 1, 2026

Description

restores patchbay tests that have been removed from initial PR in #3986
(not yet reviewed, might need more changes)

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.
    • Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are:

@Frando
Copy link
Copy Markdown
Member Author

Frando commented Apr 1, 2026

@Frando Frando mentioned this pull request Apr 1, 2026
3 tasks
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4065/docs/iroh/

Last updated: 2026-04-01T10:54:31Z

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: f0f4217

@Frando Frando force-pushed the Frando/more-patchbay-tests branch from 858177d to b4ef35d Compare April 1, 2026 10:50
@n0bot n0bot bot added this to iroh Apr 1, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Apr 1, 2026
Frando added a commit that referenced this pull request Apr 2, 2026
## 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.
Base automatically changed from Frando/netsim to main April 2, 2026 10:25
@dignifiedquire dignifiedquire moved this from 🚑 Needs Triage to 🏗 In progress in iroh Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

2 participants