Skip to content

Commit def98eb

Browse files
ci: add automated hole-punch tests
Related: libp2p/test-plans#304. Pull-Request: #4549. Co-authored-by: diegomrsantos <[email protected]>
1 parent d15bb69 commit def98eb

File tree

10 files changed

+487
-9
lines changed

10 files changed

+487
-9
lines changed

.github/workflows/interop-test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,20 @@ jobs:
3737
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
3838
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
3939
worker-count: 16
40+
run-holepunching-interop:
41+
name: Run hole-punch interoperability tests
42+
runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: docker/setup-buildx-action@v3
46+
- name: Build image
47+
run: docker buildx build --load -t rust-libp2p-head . -f hole-punching-tests/Dockerfile
48+
- name: Run tests
49+
uses: libp2p/test-plans/.github/actions/run-interop-hole-punch-test@master
50+
with:
51+
test-filter: rust-libp2p-head
52+
extra-versions: ${{ github.workspace }}/hole-punching-tests/version.json
53+
s3-cache-bucket: libp2p-by-tf-aws-bootstrap
54+
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
55+
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
56+
worker-count: 1

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ members = [
1515
"examples/relay-server",
1616
"examples/rendezvous",
1717
"examples/upnp",
18+
"hole-punching-tests",
1819
"identity",
1920
"interop-tests",
2021
"misc/allow-block-list",

hole-punching-tests/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "hole-punching-tests"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
license = "MIT"
7+
8+
[dependencies]
9+
anyhow = "1"
10+
env_logger = "0.10.0"
11+
futures = "0.3.28"
12+
libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] }
13+
log = "0.4"
14+
redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] }
15+
tokio = { version = "1.29.1", features = ["full"] }
16+
serde = { version = "1.0.188", features = ["derive"] }
17+
serde_json = "1.0.107"

hole-punching-tests/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1.5-labs
2+
FROM rust:1.73.0 as builder
3+
4+
# Run with access to the target cache to speed up builds
5+
WORKDIR /workspace
6+
ADD . .
7+
8+
# Build the relay as a statically-linked binary. Unfortunately, we must specify the `--target` explicitly. See https://msfjarvis.dev/posts/building-static-rust-binaries-for-linux/.
9+
RUN --mount=type=cache,target=./target \
10+
--mount=type=cache,target=/usr/local/cargo/registry \
11+
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package hole-punching-tests --target $(rustc -vV | grep host | awk '{print $2}')
12+
13+
RUN --mount=type=cache,target=./target \
14+
mv ./target/$(rustc -vV | grep host | awk '{print $2}')/release/hole-punching-tests /usr/local/bin/hole-punching-tests
15+
16+
FROM alpine:3
17+
COPY --from=builder /usr/local/bin/hole-punching-tests /usr/bin/hole-punch-client
18+
RUN --mount=type=cache,target=/var/cache/apk apk add bind-tools jq curl tcpdump iproute2-tc
19+
ENV RUST_BACKTRACE=1

0 commit comments

Comments
 (0)