docker-tests: support userspace and kernel backends

pull/92/head
Jake McGinty 2021-05-21 14:22:43 +09:00
parent fed0c859c8
commit 414e9c83fb
4 changed files with 33 additions and 10 deletions

View File

@ -17,5 +17,5 @@ jobs:
- name: Build the Docker images
run: docker-tests/build-docker-images.sh
- name: Run the Docker tests
run: docker-tests/run-docker-tests.sh
run: docker-tests/run-docker-tests.sh userspace

View File

@ -1,9 +1,31 @@
#!/usr/bin/env bash
set -e
shopt -s nocasematch
SELF_DIR="$(dirname "$0")"
cd "$SELF_DIR/.."
if [[ $# -eq 1 ]]; then
case "$1" in
kernel)
INNERNET_ARGS=""
;;
userspace)
INNERNET_ARGS="--backend userspace"
;;
*)
echo "invalid backend (must be kernel or userspace)"
exit 1
esac
else
cat >&2 <<-_EOF
Usage: "${0##*/}" <BACKEND>
BACKEND: "kernel" or "userspace"
_EOF
exit
fi
cmd() {
echo "[#] $*" >&2
"$@"
@ -31,6 +53,7 @@ SERVER_CONTAINER=$(cmd docker create -it --rm \
--ip 172.18.1.1 \
--volume /dev/net/tun:/dev/net/tun \
--env RUST_LOG=debug \
--env INNERNET_ARGS="$INNERNET_ARGS" \
--cap-add NET_ADMIN \
innernet-server)
cmd docker start -a "$SERVER_CONTAINER" &
@ -46,6 +69,7 @@ PEER1_CONTAINER=$(cmd docker create --rm -it \
--ip 172.18.1.2 \
--volume /dev/net/tun:/dev/net/tun \
--env INTERFACE=evilcorp \
--env INNERNET_ARGS="$INNERNET_ARGS" \
--cap-add NET_ADMIN \
innernet)
info "peer1 started as $PEER1_CONTAINER"
@ -86,6 +110,7 @@ PEER2_CONTAINER=$(docker create --rm -it \
--volume /dev/net/tun:/dev/net/tun \
--cap-add NET_ADMIN \
--env INTERFACE=evilcorp \
--env INNERNET_ARGS="$INNERNET_ARGS" \
innernet)
info "peer2 started as $PEER2_CONTAINER"
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"

View File

@ -1,16 +1,14 @@
#!/bin/bash
set -e
DEFAULT_ARGS="--backend userspace"
INTERFACE="${INTERFACE:-innernet}"
innernet $DEFAULT_ARGS install \
innernet $INNERNET_ARGS install \
--name "$INTERFACE" \
--delete-invite \
--no-write-hosts \
/app/invite.toml
while true; do
innernet $DEFAULT_ARGS up --no-write-hosts "$INTERFACE"
innernet $INNERNET_ARGS up --no-write-hosts "$INTERFACE"
sleep 1
done

View File

@ -1,10 +1,10 @@
#!/bin/bash
set -e
DEFAULT_ARGS="--backend userspace"
INNERNET_ARGS="--backend userspace"
innernet-server \
$DEFAULT_ARGS \
$INNERNET_ARGS \
new \
--network-name "evilcorp" \
--network-cidr "10.66.0.0/16" \
@ -12,7 +12,7 @@ innernet-server \
--listen-port 51820
innernet-server \
$DEFAULT_ARGS \
$INNERNET_ARGS \
add-cidr evilcorp \
--name "humans" \
--cidr "10.66.1.0/24" \
@ -20,7 +20,7 @@ innernet-server \
--yes
innernet-server \
$DEFAULT_ARGS \
$INNERNET_ARGS \
add-peer evilcorp \
--name "admin" \
--cidr "humans" \
@ -30,4 +30,4 @@ innernet-server \
--invite-expires "30d" \
--yes
innernet-server $DEFAULT_ARGS serve evilcorp
innernet-server $INNERNET_ARGS serve evilcorp