Skip to content

Commit

Permalink
Add --interactive mode to docker-tests for testing of interactive com…
Browse files Browse the repository at this point in the history
…mands (#312)

* Add --interactive mode to docker-tests to facilitate interactive testing
of innernet commands.

* Add a section to README about testing.

* Fix href tag
  • Loading branch information
skywhale authored Apr 23, 2024
1 parent 3c69de4 commit 85c8cc3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
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

0 comments on commit 85c8cc3

Please sign in to comment.