Skip to content

Commit ae5833e

Browse files
authored
test(netwatch): add patchbay network simulation tests (#131)
## Description Add patchbay tests that exercise netwatch's interface and route detection inside virtual network namespaces. The tests cover v4-only, v6-only, dual-stack, and v4-to-v6 replug scenarios. Also adds patchbay CI workflow, nextest patchbay profile, and a cargo-make task to match the iroh project's patchbay setup. ## Notes & open questions Two of the four tests are currently ignored: they expose a bug where default_route() fails to detect IPv6 default routes on Linux because /proc/net/route only contains IPv4 entries and the netlink fallback is never reached. See #132 for a fix. <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] 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. - [ ] Tests if relevant. - [ ] All breaking changes documented.
1 parent 2cdaf61 commit ae5833e

8 files changed

Lines changed: 386 additions & 16 deletions

File tree

.config/nextest.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@ run-in-isolation = { max-threads = 32 }
77
[[profile.ci.overrides]]
88
filter = 'test(::run_in_isolation::)'
99
test-group = 'run-in-isolation'
10-
threads-required = 32
10+
threads-required = 32
11+
12+
[profile.default]
13+
default-filter = 'not binary(patchbay)'
14+
15+
[profile.patchbay]
16+
fail-fast = false
17+
test-threads = 1
18+
default-filter = 'binary(patchbay)'
19+
slow-timeout = { period = "30s", terminate-after = 4 }

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
3232
timeout-minutes: 30
3333
runs-on: [self-hosted, linux, X64]
34+
env:
35+
RUSTFLAGS: "-Dwarnings --cfg skip_patchbay"
3436
strategy:
3537
fail-fast: false
3638
matrix:
@@ -120,6 +122,8 @@ jobs:
120122
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
121123
timeout-minutes: 30
122124
runs-on: [self-hosted, linux, X64]
125+
env:
126+
RUSTFLAGS: "-Dwarnings --cfg skip_patchbay"
123127
strategy:
124128
fail-fast: false
125129
matrix:

.github/workflows/patchbay.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Patchbay Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: patchbay-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
RUST_BACKTRACE: 1
15+
SCCACHE_CACHE_SIZE: "10G"
16+
17+
jobs:
18+
patchbay_tests:
19+
name: Patchbay Tests
20+
timeout-minutes: 15
21+
runs-on: [self-hosted, linux, X64]
22+
env:
23+
RUSTC_WRAPPER: "sccache"
24+
steps:
25+
- name: Enable unprivileged user namespaces
26+
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
27+
continue-on-error: true
28+
29+
- uses: actions/checkout@v6
30+
- uses: dtolnay/rust-toolchain@stable
31+
- uses: mozilla-actions/sccache-action@v0.0.9
32+
- name: Install cargo-make and cargo-nextest
33+
uses: taiki-e/install-action@v2
34+
with:
35+
tool: nextest@0.9.80,cargo-make
36+
37+
- name: Build patchbay tests
38+
run: cargo make patchbay --no-run
39+
40+
- name: Run patchbay tests
41+
run: |
42+
set -o pipefail
43+
cargo make patchbay 2>&1 | tee "$RUNNER_TEMP/logs.txt"
44+
env:
45+
PATCHBAY_LOG: trace
46+
RUST_LOG: trace
47+
48+
- name: Upload test results
49+
if: always()
50+
uses: actions/upload-artifact@v7
51+
with:
52+
name: patchbay-testdir-${{ github.sha }}
53+
path: |
54+
${{ runner.temp }}/logs.txt
55+
retention-days: 7
56+
if-no-files-found: ignore

0 commit comments

Comments
 (0)