Skip to content

Commit

Permalink
ping/rust: introduce rust cross-version test (libp2p#26)
Browse files Browse the repository at this point in the history
* ping/go: fix composition name

* ping/rust: introduce the ping/rust test

* Showcase version selection through features

Can be run with `cargo check --features libp2pv0450` or `cargo check --features
libp2pv0440`.

* Peer programming session

* ping/rust: experiment with master & current groups

* ping/rust/src/main: Simplify import across versions

* ping/rust/src/main: Remove commented out code

* ping/rust/src/main: Clean up

* ping/rust/Dockerfile: Update crates.io index in separate step

Potentially allows caching.

* ping/rust/Dockerfile: Don't both build and install

Building the binary in release mode is enough.

* ping/rust/src/main: Clean up log lines

* ping/rust: Implement iterations with latency

* ping/rust/src/main: Extract signal and wait logic into fn

* ping/rust/Dockerfile: import caching fixes

* ping/: add cross-version composition

* ping/rust: add json payloads fix

* ping/rust: match iterations id with go

* ping/rust/Dockerfile: improve caching

* ci: introduce workflow ping-interop-rust

* ping/interop: update latest versions

* ping/_compositions: add full ping interop

* ci: resolve git reference to sha

* ping/rust/Dockerfile: drop cargo output

* ping/rust: drop version indirection

* ping/rust/Dockerfile: fix features to support caching

* ping/rust/Dockerfile: do not cache the rewritten package

* ping/_compositions/*: use concurrent_builds

* ping/_compositions/*: drop test_instances count

* ci: build composition then run

* ping: introduce InteropTarget option

* ci: fix interop target & build

* ping/_compositions/*: introduce load_resource

* ci: 10 minutes timeout for the run step

* README: add update instruction for rust & clean go

* ping/rust/Dockerfile: add protocol buffer compiler

* ping/rust/Cargo.lock: cargo update packages

* .github: increase testground timeout

Co-authored-by: Max Inden <mail@max-inden.de>
  • Loading branch information
laurentsenta and mxinden committed Aug 22, 2022
1 parent 3f6b909 commit 072d351
Show file tree
Hide file tree
Showing 19 changed files with 4,970 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-testground/action.yml
Expand Up @@ -35,7 +35,7 @@ runs:
cat <<EOF >> ~/testground/.env.toml
[daemon.scheduler]
task_timeout_min = 30
task_timeout_min = 60
EOF
testground daemon > testground.out 2> testground.err &
fi;
2 changes: 1 addition & 1 deletion .github/workflows/ping-interop-go.yml
Expand Up @@ -26,5 +26,5 @@ jobs:
with:
composition_file: "ping/_compositions/go-cross-versions.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git branch
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
30 changes: 30 additions & 0 deletions .github/workflows/ping-interop-rust.yml
@@ -0,0 +1,30 @@
on:
workflow_dispatch:
inputs:
testground_endpoint:
type: string
required: false
description: testground endpoint
custom_git_reference:
type: string
required: false
description: rust ref
custom_git_target:
type: string
required: false
description: repository to use as replace target
default: github.com/libp2p/rust-libp2p

name: rust-libp2p ping - rust test with testground.

jobs:
run-libp2p-test-plans:
# If you intend to use this workflow from another repo,
# you need to pass the repo and the version:
# uses: "libp2p/test-plans/.github/workflows/run-composition.yml@master"
uses: "./.github/workflows/run-composition.yml"
with:
composition_file: "ping/_compositions/rust-cross-versions.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
39 changes: 39 additions & 0 deletions .github/workflows/ping-interop.yml
@@ -0,0 +1,39 @@
on:
workflow_dispatch:
inputs:
testground_endpoint:
type: string
required: false
description: testground endpoint
custom_git_reference:
description: the git commit or branch we're going to use for the custom target
required: false
type: string
custom_git_target:
description: the custom git fork url we're going to use for the custom target (github.com/some-fork/rust-libp2p)
required: false
type: string
custom_interop_target:
description: in the case of cross-implementation testing, the implementation target (go | rust | ...)
required: false
type: string

name: libp2p ping - go and rust test with testground.

jobs:
run-ping-latest:
uses: "./.github/workflows/run-composition.yml"
with:
composition_file: "ping/_compositions/go-rust-interop-latest.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
custom_interop_target: ${{ github.event.inputs.custom_interop_target }} # go | rust
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
run-ping-all:
uses: "./.github/workflows/run-composition.yml"
with:
composition_file: "ping/_compositions/go-rust-interop.toml"
custom_git_target: ${{ github.event.inputs.custom_git_target }} # nothing or "some-fork/go-libp2p"
custom_git_reference: ${{ github.event.inputs.custom_git_reference }} # a git reference
custom_interop_target: ${{ github.event.inputs.custom_interop_target }} # go | rust
testground_endpoint: ${{ github.event.inputs.testground_endpoint }}
34 changes: 30 additions & 4 deletions .github/workflows/run-composition.yml
Expand Up @@ -4,12 +4,19 @@ on:
workflow_call:
inputs:
composition_file:
description: the workflow we're going to run
required: true
type: string
custom_git_reference:
description: the git commit or branch we're going to use for the custom target
required: false
type: string
custom_git_target:
description: the custom git fork url we're going to use for the custom target (github.com/some-fork/rust-libp2p)
required: false
type: string
custom_interop_target:
description: in the case of cross-implementation testing, the implementation target (go | rust | ...)
required: false
type: string
testground_endpoint:
Expand Down Expand Up @@ -39,20 +46,39 @@ jobs:
working-directory: ./test-plans
run: |
testground plan import --from ./ --name libp2p
- name: Resolve the git references
if: ${{ inputs.custom_git_reference && inputs.custom_git_target }}
id: resolve_reference
working-directory: ./test-plans
run: |
git fetch https://${{ inputs.custom_git_target }} ${{ inputs.custom_git_reference }}
SHA=`git log FETCH_HEAD -n 1 --pretty=format:"%H"`
echo "::set-output name=custom_git_sha::${SHA}"
- name: Build the composition file
working-directory: ./test-plans
run: |
testground build composition \
-f ${{ inputs.composition_file }} \
--wait
env:
GitReference: ${{ steps.resolve_reference.outputs.custom_git_sha || inputs.custom_git_reference }}
GitTarget: ${{ inputs.custom_git_target }}
InteropTarget: ${{ inputs.custom_interop_target }}
- name: Run the composition file
working-directory: ./test-plans
timeout-minutes: 10
run: |
GitReference=${{ inputs.custom_git_reference }} \
GitTarget=${{ inputs.custom_git_target }} \
testground run composition \
testground run composition \
-f ${{ inputs.composition_file }} \
--metadata-repo "${GITHUB_REPOSITORY}" \
--metadata-branch "${GITHUB_REF#refs/heads/}" \
--metadata-commit "${GITHUB_SHA}" \
--collect-file ./result.tgz \
--collect --wait
env:
GitReference: ${{ inputs.custom_git_reference }}
GitReference: ${{ steps.resolve_reference.outputs.custom_git_sha || inputs.custom_git_reference }}
GitTarget: ${{ inputs.custom_git_target }}
InteropTarget: ${{ inputs.custom_interop_target }}
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
Expand Down
26 changes: 20 additions & 6 deletions README.md
Expand Up @@ -9,10 +9,9 @@ This repository contains Testground test plans for libp2p components.

When a new version of libp2p is released, we want to make it permanent in the `ping/go` test folder.

1. In the `ping/_compositions/go-cross-versions.toml` file,
- Find the group for the latest version (`v0.20` for example) and copy it into a new group (`v0.21` for example).
- Update the `selectors` (go tags) and `modfile` options. Update the `build_base_image` if needed.
- Increment the `total_instances` flag (near line 7).
1. In the `ping/_compositions/go.toml` file,
- copy the `[master]` section and turn it into a `[[groups]]` item
- update the `[master]` section with the future version
2. In the `ping/go` folder,
- Add a new compatibility shim in `compat/` if needed, or add your new selector to the latest shim (see `compat/libp2p.v0.17.go` for example).
- Create the new mod and sum files (`go.v0.21.mod` for example). Assuming you're updating from `v$A` to `v$B`, a simple way to do this is to:
Expand All @@ -21,8 +20,23 @@ When a new version of libp2p is released, we want to make it permanent in the `p
- update the `go-libp2p` version, go version, and update the code if needed.
- then `go get -tags v$B && go mod tidy`
3. Run the test on your machine
- Import the test-plans with `testground plan import ./ --name libp2p` (once, from the test-plans root)
- Run with `testground run composition -f ping/_compositions/go-cross-versions.toml --wait`
- Do once, from the test-plans root: import the test-plans with `testground plan import ./ --name libp2p`
- Run the test with `testground run composition -f ping/_compositions/go-cross-versions.toml --wait`

## How to add a new version to ping/rust

When a new version of libp2p is released, we want to make it permanent in the `ping/rust` test folder.

1. In the `ping/_compositions/rust.toml` file,
- Copy the `[master]` section and turn it into a item in the `[[groups]]` array
- Update the `[master]` section with the new master version
2. In the `ping/rust` folder,
- `Cargo.toml`: update the feature flags `libp2pvxxx` to fix the released version and add the new `master`
- `src/main.rs`: Update the `mod libp2p` definition with the new master
- Run `cargo update` if needed. Try to build with `cargo build --features libp2pvxxx`
3. Run the test on your machine
- Do once, from the test-plans root: import the test-plans with `testground plan import ./ --name libp2p`
- Run the test with `testground run composition -f ping/_compositions/rust-cross-versions.toml --wait`

## License

Expand Down
175 changes: 69 additions & 106 deletions ping/_compositions/go-cross-versions.toml
@@ -1,10 +1,9 @@
[metadata]
name = "go-cross-versions {{ .Env.Reference }}"
name = "go-cross-versions {{ .Env.GitReference }}"

[global]
plan = "libp2p/ping/go"
case = "ping"
total_instances = {{ if .Env.GitReference }}7{{ else }}6{{ end }}
builder = "docker:go"
runner = "local:docker"

Expand All @@ -14,108 +13,72 @@
go_proxy_mode = "remote"
go_proxy_url = "https://proxy.golang.org"

[[groups]]
id = "v0.11"
instances = { count = 1 }

[groups.build]
selectors = ['v0.11']

[groups.build_config]
build_base_image = 'golang:1.14-buster'
modfile = "go.v0.11.mod"

[[groups]]
id = "v0.17"
instances = { count = 1 }

[groups.build]
selectors = ['v0.17']

[groups.build_config]
build_base_image = 'golang:1.16-buster'
modfile = "go.v0.17.mod"

[[groups]]
id = "v0.19"
instances = { count = 1 }

[groups.build]
selectors = ['v0.19']

[groups.build_config]
build_base_image = 'golang:1.17-buster'
modfile = "go.v0.19.mod"

[[groups]]
id = "v0.20"
instances = { count = 1 }

[groups.build]
selectors = ['v0.20']

[groups.build_config]
build_base_image = 'golang:1.18-buster'
modfile = "go.v0.20.mod"

[[groups]]
id = "v0.21"
instances = { count = 1 }

[groups.build]
selectors = ['v0.21']

[groups.build_config]
build_base_image = 'golang:1.18-buster'
modfile = "go.v0.21.mod"

[[groups]]
id = "master"
instances = { count = 1 }

[groups.build]
selectors = ['v0.21']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "master"

[groups.build_config]
build_base_image = 'golang:1.18-buster'
modfile = "go.v0.21.mod"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat=1.18
"""

{{ if .Env.GitReference }}
[[groups]]
id = "custom"
instances = { count = 1 }

[groups.build]
selectors = ['v0.20']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "{{ .Env.GitReference }}"
{{ if .Env.GitTarget }}
target = "{{ .Env.GitTarget }}"
{{ end }}

[groups.build_config]
build_base_image = 'golang:1.18-buster'
modfile = "go.v0.20.mod"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat=1.18
"""
{{ with (load_resource "./go.toml" ) }}
{{ range .groups }}
[[groups]]
id = "{{ .Id }}"
instances = { count = 1 }

[groups.build]
selectors = ['{{ .Selector }}']

[groups.build_config]
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"
{{ end }}

{{ with .master }}
[[groups]]
id = "master"
instances = { count = 1 }

[groups.build]
selectors = ['{{ .Selector }}']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "master"

[groups.build_config]
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat={{ .GoVersion }}
"""
{{ end }}

{{ if $.Env.GitReference }}
{{ with .custom }}
[[groups]]
id = "custom"
instances = { count = 1 }

[groups.build]
selectors = ['{{ .Selector }}']

[[groups.build.dependencies]]
module = "github.com/libp2p/go-libp2p"
version = "{{ $.Env.GitReference }}"
{{ if $.Env.GitTarget }}
target = "{{ $.Env.GitTarget }}"
{{ end }}

[groups.build_config]
build_base_image = 'golang:{{ .GoVersion }}-buster'
modfile = "{{ .Modfile }}"

[groups.build_config.dockerfile_extensions]
# deal with dependency changes in master until we create the new vx.y.z instance
pre_build = """
RUN cd ${PLAN_DIR} && \
go mod download github.com/libp2p/go-libp2p && \
go mod tidy -compat={{ .GoVersion }}
"""
{{ end }}
{{ end }}
{{ end }}

0 comments on commit 072d351

Please sign in to comment.