Skip to content

Commit

Permalink
ci: add automated hole-punch tests
Browse files Browse the repository at this point in the history
Related: libp2p/test-plans#304.

Pull-Request: #4549.

Co-authored-by: diegomrsantos <[email protected]>
  • Loading branch information
thomaseizinger and diegomrsantos authored Oct 25, 2023
1 parent d15bb69 commit def98eb
Show file tree
Hide file tree
Showing 10 changed files with 487 additions and 9 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/interop-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,20 @@ jobs:
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
worker-count: 16
run-holepunching-interop:
name: Run hole-punch interoperability tests
runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build image
run: docker buildx build --load -t rust-libp2p-head . -f hole-punching-tests/Dockerfile
- name: Run tests
uses: libp2p/test-plans/.github/actions/run-interop-hole-punch-test@master
with:
test-filter: rust-libp2p-head
extra-versions: ${{ github.workspace }}/hole-punching-tests/version.json
s3-cache-bucket: libp2p-by-tf-aws-bootstrap
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
worker-count: 1
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"examples/relay-server",
"examples/rendezvous",
"examples/upnp",
"hole-punching-tests",
"identity",
"interop-tests",
"misc/allow-block-list",
Expand Down
17 changes: 17 additions & 0 deletions hole-punching-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "hole-punching-tests"
version = "0.1.0"
edition = "2021"
publish = false
license = "MIT"

[dependencies]
anyhow = "1"
env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] }
log = "0.4"
redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] }
tokio = { version = "1.29.1", features = ["full"] }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
19 changes: 19 additions & 0 deletions hole-punching-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.73.0 as builder

# Run with access to the target cache to speed up builds
WORKDIR /workspace
ADD . .

# 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/.
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/registry \
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package hole-punching-tests --target $(rustc -vV | grep host | awk '{print $2}')

RUN --mount=type=cache,target=./target \
mv ./target/$(rustc -vV | grep host | awk '{print $2}')/release/hole-punching-tests /usr/local/bin/hole-punching-tests

FROM alpine:3
COPY --from=builder /usr/local/bin/hole-punching-tests /usr/bin/hole-punch-client
RUN --mount=type=cache,target=/var/cache/apk apk add bind-tools jq curl tcpdump iproute2-tc
ENV RUST_BACKTRACE=1
Loading

0 comments on commit def98eb

Please sign in to comment.