Skip to content

Commit a34411c

Browse files
authored
ci: update interop workflow (#3331)
Addresses libp2p/test-plans#99
1 parent 73cbbe2 commit a34411c

File tree

8 files changed

+372
-20
lines changed

8 files changed

+372
-20
lines changed

.github/workflows/interop-test.yml

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
name: Interoperability Testing
2-
32
on:
43
pull_request:
54
push:
65
branches:
7-
- master
6+
- "master"
87

98
concurrency:
109
group: ${{ github.workflow }}-${{ github.ref }}
1110
cancel-in-progress: true
1211

1312
jobs:
14-
# NOTE: during a pull request run, github creates a merge commit referenced in `github.sha`
15-
# that merge commit is not a regular commit. You won't find it with a regular `git checkout SHA` and
16-
# tools like `go get repo@SHA` won't find it.
17-
#
18-
# As a workaround, we generate a path to the actual pull request's commit, it looks like:
19-
# `github.com/external-org/go-libp2p@latest-commit-on-their-branch`
20-
run-ping-interop-cross-version:
21-
uses: "libp2p/test-plans/.github/workflows/run-composition.yml@master"
22-
with:
23-
composition_file: "ping/_compositions/rust-cross-versions.toml"
24-
custom_git_target: github.com/${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
25-
custom_git_reference: ${{ github.event.pull_request.head.sha || github.sha }}
26-
run-ping-interop-cross-implementation:
27-
uses: "libp2p/test-plans/.github/workflows/run-composition.yml@master"
13+
build-ping-container:
14+
name: Build Ping interop container
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
submodules: recursive
20+
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
21+
with:
22+
shared-key: interop-tests
23+
save-if: ${{ github.ref == 'refs/heads/master' }}
24+
- name: Install Protoc
25+
run: sudo apt-get install protobuf-compiler
26+
- name: Build image
27+
working-directory: ./test-plans
28+
run: make
29+
- name: Upload ping versions info
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: ping-versions
33+
path: ./test-plans/ping-versions.json
34+
- name: Upload image tar
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: ping-image
38+
path: ./test-plans/ping-image.tar
39+
run-multidim-interop:
40+
name: Run multidimensional interoperability tests
41+
needs: build-ping-container
42+
uses: "libp2p/test-plans/.github/workflows/run-testplans.yml@master"
2843
with:
29-
composition_file: "ping/_compositions/all-interop-latest.toml"
30-
custom_git_target: github.com/${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
31-
custom_git_reference: ${{ github.event.pull_request.head.sha || github.sha }}
32-
custom_interop_target: rust
44+
dir: "multidim-interop"
45+
extra-versions: ping-versions
46+
image-tar: ping-image
47+
test-filter: "rust-libp2p-head"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ members = [
166166
"protocols/request-response",
167167
"swarm",
168168
"swarm-derive",
169+
"test-plans",
169170
"transports/deflate",
170171
"transports/dns",
171172
"transports/noise",

test-plans/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
edition = "2021"
3+
name = "interop-tests"
4+
version = "0.1.0"
5+
publish = false
6+
7+
[dependencies]
8+
anyhow = "1"
9+
async-trait = "0.1.58"
10+
env_logger = "0.9.0"
11+
futures = "0.3.1"
12+
if-addrs = "0.7.0"
13+
log = "0.4"
14+
redis = { version = "0.22.1", features = ["tokio-native-tls-comp", "tokio-comp"] }
15+
tokio = { version = "1.24.1", features = ["full"] }
16+
17+
libp2p = { path = "../", default_features = false, features = ["websocket", "quic", "mplex", "yamux", "tcp", "tokio", "ping", "noise", "tls", "dns", "rsa", "macros", "webrtc"] }
18+
rand = "0.8.5"
19+
strum = { version = "0.24.1", features = ["derive"] }
20+
either = "1.8.0"

test-plans/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM ubuntu:latest
2+
COPY target/release/ping /usr/local/bin/testplan
3+
ENV RUST_BACKTRACE=1
4+
ENTRYPOINT ["testplan"]

test-plans/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all: ping-image.tar
2+
3+
ping-image.tar: Dockerfile Cargo.toml src/bin/ping.rs
4+
cargo build --release -p interop-tests
5+
mkdir -p target/release/
6+
cp ../target/release/ping target/release
7+
docker build -t rust-libp2p-head .
8+
docker image save -o $@ rust-libp2p-head
9+
10+
.PHONY: clean
11+
12+
clean:
13+
rm -rf target
14+
rm ping-image.tar

test-plans/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# test-plans test implementation
2+
3+
This folder defines the implementation for the test-plans interop tests.
4+
5+
# Running this test locally
6+
7+
You can run this test locally by having a local Redis instance and by having
8+
another peer that this test can dial or listen for. For example to test that we
9+
can dial/listen for ourselves we can do the following:
10+
11+
1. Start redis (needed by the tests): `docker run --rm -it -p 6379:6379
12+
redis/redis-stack`.
13+
2. In one terminal run the dialer: `REDIS_ADDR=localhost:6379 ip="0.0.0.0"
14+
transport=quic-v1 security=quic muxer=quic is_dialer="true" cargo run --bin ping`
15+
3. In another terminal, run the listener: `REDIS_ADDR=localhost:6379
16+
ip="0.0.0.0" transport=quic-v1 security=quic muxer=quic is_dialer="false" cargo run --bin ping`
17+
18+
19+
To test the interop with other versions do something similar, except replace one
20+
of these nodes with the other version's interop test.
21+
22+
# Running all interop tests locally with Compose
23+
24+
To run this test against all released libp2p versions you'll need to have the
25+
(libp2p/test-plans)[https://github.com/libp2p/test-plans] checked out. Then do
26+
the following:
27+
28+
1. Build the image: `make`.
29+
2. Build the images for all released versions in `libp2p/test-plans`: `(cd <path
30+
to >/libp2p/test-plans/multidim-interop/ && make)`.
31+
3. Make a folder for the specified extra versions: `mkdir extra-versions && mv ping-versions.json extra-versions`
32+
4. Run the test:
33+
```
34+
RUST_LIBP2P_TEST_PLANS="$PWD"; (cd <path to >/libp2p/test-plans/multidim-interop/ && npm run test -- --extra-versions-dir=$RUST_LIBP2P_TEST_PLANS/extra-versions --name-filter="rust-libp2p-head")

test-plans/ping-versions.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"id": "rust-libp2p-head",
4+
"containerImageID": "rust-libp2p-head",
5+
"transports": [
6+
"ws",
7+
"tcp",
8+
"quic-v1",
9+
"webrtc"
10+
],
11+
"secureChannels": [
12+
"tls",
13+
"noise"
14+
],
15+
"muxers": [
16+
"mplex",
17+
"yamux"
18+
]
19+
}
20+
]

0 commit comments

Comments
 (0)