Skip to content

Commit

Permalink
Fix docker tests (#282)
Browse files Browse the repository at this point in the history
* better docker test output

* force wireguard-go builder and rust image to same debian version
  • Loading branch information
mcginty authored Aug 23, 2023
1 parent b90024d commit 376ab64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docker-tests/Dockerfile.innernet
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
####################################################################################################
## WireGuard
####################################################################################################
FROM golang:latest as wireguard
ARG wg_go_tag=0.0.20210323
ARG wg_tools_tag=v1.0.20210315
FROM golang:bookworm as wireguard
ARG wg_go_tag=0.0.20230223
ARG wg_tools_tag=v1.0.20210914

RUN mkdir /repo \
&& curl -L https://github.com/WireGuard/wireguard-go/archive/refs/tags/0.0.20210424.tar.gz \
&& curl -L https://github.com/WireGuard/wireguard-go/archive/refs/tags/0.0.20230223.tar.gz \
| tar -xzC /repo --strip-components=1 \
&& cd /repo \
&& make
&& CGO_ENABLED=0 make

####################################################################################################
## Final image
####################################################################################################
FROM rust:slim
FROM rust:slim-bookworm
RUN apt-get update && \
apt-get install -y --no-install-recommends libsqlite3-dev iproute2 iputils-ping build-essential clang libclang-dev && \
rm -rf /var/lib/apt/lists/*
Expand Down
21 changes: 13 additions & 8 deletions docker-tests/run-docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ cd "$SELF_DIR/.."
if [[ $# -eq 1 ]]; then
case "$1" in
kernel)
INNERNET_ARGS=""
INNERNET_ARGS="-vvv"
;;
userspace)
INNERNET_ARGS="--backend userspace"
INNERNET_ARGS="-vvv --backend userspace"
;;
*)
echo "invalid backend (must be kernel or userspace)"
Expand All @@ -36,6 +36,7 @@ info() {
}

tmp_dir=$(mktemp -d -t innernet-tests-XXXXXXXXXX)
info "temp dir: $tmp_dir"
cleanup() {
info "Cleaning up."
rm -rf "$tmp_dir"
Expand All @@ -56,7 +57,7 @@ SERVER_CONTAINER=$(cmd docker create -it --rm \
--env INNERNET_ARGS="$INNERNET_ARGS" \
--cap-add NET_ADMIN \
innernet)
cmd docker start -a "$SERVER_CONTAINER" &
cmd docker start -a "$SERVER_CONTAINER" | sed -e 's/^/\x1B[0;95mserver\x1B[0m: /' &

info "server started as $SERVER_CONTAINER"
info "Waiting for server to initialize."
Expand All @@ -69,12 +70,13 @@ PEER1_CONTAINER=$(cmd docker create --rm -it \
--ip 172.18.1.2 \
--volume /dev/net/tun:/dev/net/tun \
--env INTERFACE=evilcorp \
--env RUST_LOG=trace \
--env INNERNET_ARGS="$INNERNET_ARGS" \
--cap-add NET_ADMIN \
innernet /app/start-client.sh)
info "peer1 started as $PEER1_CONTAINER"
cmd docker cp "$tmp_dir/peer1.toml" "$PEER1_CONTAINER:/app/invite.toml"
cmd docker start "$PEER1_CONTAINER"
cmd docker start -a "$PEER1_CONTAINER" | sed -e 's/^/\x1B[0;96mpeer 1\x1B[0m: /' &
sleep 10

info "Creating a new CIDR from first peer."
Expand Down Expand Up @@ -114,7 +116,7 @@ PEER2_CONTAINER=$(docker create --rm -it \
innernet /app/start-client.sh)
info "peer2 started as $PEER2_CONTAINER"
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
cmd docker start "$PEER2_CONTAINER"
cmd docker start -a "$PEER2_CONTAINER" | sed -e 's/^/\x1B[0;93mpeer 2\x1B[0m: /' &
sleep 10

info "Creating short-lived invitation for third peer."
Expand Down Expand Up @@ -144,7 +146,7 @@ cmd docker exec "$PEER1_CONTAINER" innernet \

info "peer2 started as $PEER2_CONTAINER"
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
cmd docker start "$PEER2_CONTAINER"
cmd docker start -a "$PEER2_CONTAINER" | sed -e 's/^/\x1B[0;93mpeer 2\x1B[0m: /' &
sleep 10

info "Creating invitation for fourth and fifth peer from first peer."
Expand Down Expand Up @@ -189,11 +191,14 @@ PEER5_CONTAINER=$(docker create --rm -it \
innernet /app/start-client.sh)
cmd docker cp "$tmp_dir/peer5.toml" "$PEER5_CONTAINER:/app/invite.toml"

cmd docker start "$PEER4_CONTAINER"
cmd docker start -a "$PEER4_CONTAINER" | sed -e 's/^/\x1B[0;92mpeer 4\x1B[0m: /' &
info "peer4 started as $PEER4_CONTAINER"
cmd docker start -a "$PEER5_CONTAINER" &
cmd docker start -a "$PEER5_CONTAINER" | sed -e 's/^/\x1B[0;94mpeer 5\x1B[0m: /' &
info "peer5 started as $PEER5_CONTAINER"

info "Checking connectivity betweeen peers."
cmd docker exec "$PEER2_CONTAINER" ping -c3 10.66.0.1
cmd docker exec "$PEER2_CONTAINER" ping -c3 10.66.1.1

echo
info "test succeeded."

0 comments on commit 376ab64

Please sign in to comment.