rust-libp2p/interop-tests
Sumit c52a2fc3af
feat(swarm): allow configuration to idle connection timeout
Previously, a connection would be shut down immediately as soon as its `ConnectionHandler` reports `KeepAlive::No`. As we have gained experience with libp2p, it turned out that this isn't ideal.

For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general.

Both of these needs are currently served by the `keep_alive::Behaviour`. That one does essentially nothing other than statically returning `KeepAlive::Yes` from its `ConnectionHandler`.

It makes much more sense to deprecate `keep_alive::Behaviour` and instead allow users to globally configure an `idle_conncetion_timeout` on the `Swarm`. This timeout comes into effect once a `ConnectionHandler` reports `KeepAlive::No`. To start with, this timeout is 0. Together with https://github.com/libp2p/rust-libp2p/issues/3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour.

Fixes #4121.

Pull-Request: #4161.
2023-09-19 22:32:29 +00:00
..

Interop tests implementation

This folder defines the implementation for the interop tests.

Running this test locally

You can run this test locally by having a local Redis instance and by having another peer that this test can dial or listen for. For example to test that we can dial/listen for ourselves we can do the following:

  1. Start redis (needed by the tests): docker run --rm -p 6379:6379 redis:7-alpine.
  2. In one terminal run the dialer: redis_addr=localhost:6379 ip="0.0.0.0" transport=quic-v1 security=quic muxer=quic is_dialer="true" cargo run --bin ping
  3. In another terminal, run the listener: redis_addr=localhost:6379 ip="0.0.0.0" transport=quic-v1 security=quic muxer=quic is_dialer="false" cargo run --bin native_ping

To test the interop with other versions do something similar, except replace one of these nodes with the other version's interop test.

Running this test with webtransport dialer in browser

To run the webtransport test from within the browser, you'll need the chromedriver in your $PATH, compatible with your Chrome browser. Firefox is not yet supported as it doesn't support all required features yet (in v114 there is no support for certhashes).

  1. Build the wasm package: wasm-pack build --target web
  2. Run the dialer: redis_addr=127.0.0.1:6379 ip=0.0.0.0 transport=webtransport is_dialer=true cargo run --bin wasm_ping

Running this test with webrtc-direct

To run the webrtc-direct test, you'll need the chromedriver in your $PATH, compatible with your Chrome browser.

  1. Start redis: docker run --rm -p 6379:6379 redis:7-alpine.
  2. Build the wasm package: wasm-pack build --target web
  3. With the webrtc-direct listener RUST_LOG=debug,webrtc=off,webrtc_sctp=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer="false" cargo run --bin native_ping
  4. Run the webrtc-direct dialer: RUST_LOG=debug,hyper=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer=true cargo run --bin wasm_ping

Running all interop tests locally with Compose

To run this test against all released libp2p versions you'll need to have the (libp2p/test-plans)[https://github.com/libp2p/test-plans] checked out. Then do the following (from the root directory of this repository):

  1. Build the image: docker build -t rust-libp2p-head . -f interop-tests/Dockerfile.
  2. Build the images for all released versions in libp2p/test-plans: (cd <path to >/libp2p/test-plans/multidim-interop/ && make).
  3. Run the test:
RUST_LIBP2P="$PWD"; (cd <path to >/libp2p/test-plans/multidim-interop/ && npm run test -- --extra-version=$RUST_LIBP2P/interop-tests/ping-version.json --name-filter="rust-libp2p-head")