diff --git a/README.md b/README.md index b6ee618..d058ef8 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,19 @@ cargo build --release --bin innernet The resulting binary will be located at `./target/release/innernet` +### Testing + +You can manually invoke Docker-based tests assuming you have Docker daemon running. If you specify +`--interactive` flag, it allows you to attach to the server and client innernet Docker +containers, so you can test various innernet commands inside a sandboxed environment. + +``` +docker-tests/build-docker-images.sh +docker-tests/run-docker-tests.sh [--interactive] +``` + +If you are developing a new feature, please consider adding a new test case to `run-docker-tests.sh` ([example PR](https://github.com/tonarino/innernet/pull/310/files#diff-5d47ea0d379e45f35471e2afa48fdba09d2ca4bcf090e16bb1adccebea080081)). + ### Releases Please run the release script from a Linux machine: generated shell completions depend on available wireguard backends and Mac doesn't support the `kernel` backend. diff --git a/docker-tests/run-docker-tests.sh b/docker-tests/run-docker-tests.sh index a5f0ce7..e3c82ee 100755 --- a/docker-tests/run-docker-tests.sh +++ b/docker-tests/run-docker-tests.sh @@ -8,14 +8,19 @@ cd "$SELF_DIR/.." help() { cat >&2 <<-_EOF Usage: "${0##*/}" [options...] () - --userspace Use userspace wireguard instead of kernel one - --verbose Print verbose innernet logs + --interactive Enter interactive mode, providing a chance to attach to innernet docker containers + --userspace Use userspace wireguard instead of kernel one + --verbose Print verbose innernet logs _EOF } TEST_FILTER=() while [[ $# -gt 0 ]]; do case $1 in + --interactive) + INTERACTIVE=true + shift + ;; --userspace) INNERNET_ARGS="$INNERNET_ARGS --backend userspace" shift @@ -135,6 +140,18 @@ cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml" cmd docker start -a "$PEER2_CONTAINER" | sed -e 's/^/\x1B[0;93mpeer 2\x1B[0m: /' & sleep 10 +if [[ $INTERACTIVE == true ]]; then + info "Open a new terminal and connect to one of the docker containers to test innernet commands." + info "" + info "Server:" + info " docker exec -it ${SERVER_CONTAINER:0:12} bash" + info "Admin client:" + info " docker exec -it ${PEER1_CONTAINER:0:12} bash" + info "Non-admin client:" + info " docker exec -it ${PEER2_CONTAINER:0:12} bash" + wait +fi + test_short_lived_invitation() { info "Creating short-lived invitation for third peer." cmd docker exec "$PEER1_CONTAINER" innernet \