Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --interactive mode to docker-tests for testing of interactive commands #312

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 19 additions & 2 deletions docker-tests/run-docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ cd "$SELF_DIR/.."
help() {
cat >&2 <<-_EOF
Usage: "${0##*/}" [options...] (<test>)
--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
Expand Down Expand Up @@ -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 \
Expand Down
Loading