Skip to content

testground: cross-version interoperability#23

Merged
laurentsenta merged 24 commits intolibp2p:masterfrom
laurentsenta:feat/ping-interop
Jul 1, 2022
Merged

testground: cross-version interoperability#23
laurentsenta merged 24 commits intolibp2p:masterfrom
laurentsenta:feat/ping-interop

Conversation

@laurentsenta
Copy link
Copy Markdown
Collaborator

@laurentsenta laurentsenta commented Apr 25, 2022

Add a ping test, and the composition file to build and run it with different versions of go-libp2p.

General idea:

  • We agree on a ping test, and implement it using different libp2p implementations,
  • Testground runs multiple instances of the same test, with different versions of the library.

Content

go test:

We add a single ping-interop/go test. This test can use multiple versions of libp2p with a single codebase:

  • It defines a go.vxxx.mod file (and it's sum) for each version,
  • It defines a compat module that provides a compatibility layer when there are API changes (shims).

Testground composition

We add a testground composition file go-cross-versions.toml
that runs v0.11, v.0.17, v0.19, v0.20, the current master, and an optional branch (if GitReference is in the environment) together.

Locally you can run this with:

GitReference=optionnal-custom-libp2p-branch testground run composition \
    -f ./_compositions/go-cross-versions.toml \
    --collect --wait

Then the test output is shown on the testground dashboard (localhost:8042 for a default daemon that runs locally).
Beware of testground/testground#1329 when you check results.

Note it'll use a go mod replace to test the latest master and latest version of an optional branch.

CI

We define a reusable workflow we can from another repository, it's called with:

jobs:
  run-libp2p-test-plans:
    uses: "singulargarden/test-plans/.github/workflows/test-compatibility.yml@master"
    with:
      composition_file: "ping-interop/_compositions/go-cross-versions.toml"
      test_case: "ping"
      custom_git_reference: "current-pr" # optional
      custom_git_target: "my-fork/go-libp2p" # optional
      testground_endpoint: "https://ci.testground.ipfs.team/" # optional

This action will build & run the test.

Todo:

  • plan/ping: fix test & use go 1.17
  • plan/ping: fix test to make it (more) deterministic on local env
    • ⚠️ It is stable on an Ubuntu machine, but I couldn't get the macos testground to give use reliable result for now
  • plan/ping-interop: implement cross-version testing
    • version 0.19
    • version 0.11
  • ci: provide reusable workflo
  • implement interop feature support in testground
  • remove the shell scripts when It's difficult and error-prone to get a test run status testground/testground#1329 is fixed and merged
  • confirm this is passing on github actions with our self-hosted runners
  • Remove the DEBUG commits used for testing

@laurentsenta laurentsenta force-pushed the feat/ping-interop branch 2 times, most recently from ff2b51d to b58be4b Compare April 28, 2022 13:36
@laurentsenta laurentsenta changed the title WIP testground: cross-version interoperability testground: cross-version interoperability Apr 28, 2022
@laurentsenta laurentsenta marked this pull request as ready for review April 28, 2022 16:51
@galargh
Copy link
Copy Markdown
Member

galargh commented Apr 28, 2022

Unfortunately, I won't be able to meaningfully review this before my short break (until May 4). I'm OK with you moving forward with this though and I can review it post-merge.

Copy link
Copy Markdown
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an in-depth review yet, but a few high-level thoughts:

  1. iiuc, the current setup is limited to testing interop between exactly 2 version. It would be nice to have a setup where we could spin up nodes using multiple different versions, especially as we're going to cut more (and smaller) releases in the future. Is that possible?
  2. code reuse: it would be nice if we could write the code once, and then run it using multiple version. In my mind, this raises two questions:
    1. What if a breaking API change happened between two versions?
    2. How to deal with go.mod

I don't have a good answer for 2., but for 1., it might be nice to use a build flag. The implementation could then work around the breaking interface change.

@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented May 27, 2022

2022-05-27 conversation: there was a verbal call on how to move forward. I'm going to move this to draft. Please publish @laurentsenta again when it's ready for review.

@BigLep BigLep marked this pull request as draft May 27, 2022 16:39
@laurentsenta laurentsenta force-pushed the feat/ping-interop branch 2 times, most recently from 936c9ba to 27a7faa Compare June 24, 2022 13:20
@laurentsenta
Copy link
Copy Markdown
Collaborator Author

2 updates:

  • I moved the proxy to proxy.golang.org, and increased every timeout, and now the test is passing consistently on regular GitHub runners! I still can't believe that was that easy, I've seen a lot of random freezes and fails when developing this on local, but it looks like I was wrong @mxinden, regular runners are enough for this test! 🙇
  • I updated the composition to test forks too, so we are able to test pull request from forks if we want too,

A few runs as example:
(check the "Run composition file" section for parameters & logs)

@mxinden
Copy link
Copy Markdown
Member

mxinden commented Jun 27, 2022

@laurentsenta once this is merged, I can provide the ping Rust implementation based on https://github.com/mxinden/test-plans/tree/compatibility-libp2p. Would appreciate some help hooking it up to the composition test though.

@galargh
Copy link
Copy Markdown
Member

galargh commented Jun 27, 2022

I moved the proxy to proxy.golang.org, and increased every timeout, and now the test is passing consistently on regular GitHub runners! I still can't believe that was that easy, I've seen a lot of random freezes and fails when developing this on local, but it looks like I was wrong @mxinden, regular runners are enough for this test! 🙇

Great that we can move back to the standard runners now but let's track the setup times and have it on a radar because extending timeouts is not a great long-term solution.

Awesome work Laurent ❤️ Let's get it out 🚀

Copy link
Copy Markdown
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo a few comments.

Slight improvement would be to use the latest patch release of every minor release (e.g. v0.19.4 instead of v0.19.0).

ping/go/main.go Outdated
"github.com/libp2p/go-libp2p-core/peer"

"github.com/libp2p/go-libp2p-noise"
noise "github.com/libp2p/go-libp2p-noise"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo is deprecated as of v0.20.0. Same for -tls.

To do things the correct way, we should define a NoiseProtocolID in compat.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

It looks like we also need to pass the Protocol constructor (security(noise.ID, noise.New)), I've implemented a getByName, then moved it into the compat package (less confident about this one).

ping/go/main.go Outdated
security = libp2p.Security(noise.ID, noise.New)
case "tls":
security = libp2p.Security(tls.ID, tls.New)
// TODO: check w/Marten this is fine: We fall into the lowest common denominator for parameters (here, no secio anymore even for legacy versions).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, no need to test secio any more.


[builders."docker:go"]
enabled = true
build_base_image = "golang:1.17-buster"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a dumb question, but what does it mean to specify golang:1.17 here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not dumb at all, it becomes the new default for this test plan, (testground uses 1.16 by default).
We overwrite it in the composition files when we run "real" tests.

I assume if you're trying to run a quick test, you're probably working on the latest version,
so you have one less testground parameter to remember:

testground run single --plan=libp2p/ping/go --testcase=ping --builder=docker:go --runner=local:docker --instances=2 --build-cfg modfile=my.new.go.mod

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I was wondering, the current version is Go 1.18. Not a blocker for this PR though.

@laurentsenta laurentsenta merged commit fb5c863 into libp2p:master Jul 1, 2022
codemaestro64 pushed a commit to codemaestro64/test-plans that referenced this pull request Oct 28, 2025
* plan/ping: fix test & use go 1.17

* plan/ping: fix dedup path

* ping-interop: prepare base module and build script

* ping-interop/go-v0.11: introduce legacy ping test (fix original)

* ci: add interop reusable workflow

* ci: add testground endpoint config

* ping-interop: rewrite with new testground build config feature

* ping-interop: add v0.20 version

* ping-interop: fix build parameters

* ci: add ping-interop-go runner

* ci: use self hosted runner

* ping-interop: name with the current git branch

* ping-interop: use external proxy & drop build cache

* ping-interop: support dependencies changes in go master

* ping-interop: using longer timeout with regulars runners

* ping-interop: move to ping

* README: add ping/go update intructions

* ci: rename compatibility test

* ci: add support for forks

* ping: add doc

* REMOVEME: use a test setup

* ping: update libp2p versions

* ping: add security compat

* ping: smaller compat surface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants