docker-tests: support userspace and kernel backends
parent
fed0c859c8
commit
414e9c83fb
|
@ -17,5 +17,5 @@ jobs:
|
||||||
- name: Build the Docker images
|
- name: Build the Docker images
|
||||||
run: docker-tests/build-docker-images.sh
|
run: docker-tests/build-docker-images.sh
|
||||||
- name: Run the Docker tests
|
- name: Run the Docker tests
|
||||||
run: docker-tests/run-docker-tests.sh
|
run: docker-tests/run-docker-tests.sh userspace
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,31 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
shopt -s nocasematch
|
||||||
|
|
||||||
SELF_DIR="$(dirname "$0")"
|
SELF_DIR="$(dirname "$0")"
|
||||||
cd "$SELF_DIR/.."
|
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() {
|
cmd() {
|
||||||
echo "[#] $*" >&2
|
echo "[#] $*" >&2
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -31,6 +53,7 @@ SERVER_CONTAINER=$(cmd docker create -it --rm \
|
||||||
--ip 172.18.1.1 \
|
--ip 172.18.1.1 \
|
||||||
--volume /dev/net/tun:/dev/net/tun \
|
--volume /dev/net/tun:/dev/net/tun \
|
||||||
--env RUST_LOG=debug \
|
--env RUST_LOG=debug \
|
||||||
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
innernet-server)
|
innernet-server)
|
||||||
cmd docker start -a "$SERVER_CONTAINER" &
|
cmd docker start -a "$SERVER_CONTAINER" &
|
||||||
|
@ -46,6 +69,7 @@ PEER1_CONTAINER=$(cmd docker create --rm -it \
|
||||||
--ip 172.18.1.2 \
|
--ip 172.18.1.2 \
|
||||||
--volume /dev/net/tun:/dev/net/tun \
|
--volume /dev/net/tun:/dev/net/tun \
|
||||||
--env INTERFACE=evilcorp \
|
--env INTERFACE=evilcorp \
|
||||||
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
innernet)
|
innernet)
|
||||||
info "peer1 started as $PEER1_CONTAINER"
|
info "peer1 started as $PEER1_CONTAINER"
|
||||||
|
@ -86,6 +110,7 @@ PEER2_CONTAINER=$(docker create --rm -it \
|
||||||
--volume /dev/net/tun:/dev/net/tun \
|
--volume /dev/net/tun:/dev/net/tun \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--env INTERFACE=evilcorp \
|
--env INTERFACE=evilcorp \
|
||||||
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
innernet)
|
innernet)
|
||||||
info "peer2 started as $PEER2_CONTAINER"
|
info "peer2 started as $PEER2_CONTAINER"
|
||||||
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
|
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DEFAULT_ARGS="--backend userspace"
|
|
||||||
|
|
||||||
INTERFACE="${INTERFACE:-innernet}"
|
INTERFACE="${INTERFACE:-innernet}"
|
||||||
innernet $DEFAULT_ARGS install \
|
innernet $INNERNET_ARGS install \
|
||||||
--name "$INTERFACE" \
|
--name "$INTERFACE" \
|
||||||
--delete-invite \
|
--delete-invite \
|
||||||
--no-write-hosts \
|
--no-write-hosts \
|
||||||
/app/invite.toml
|
/app/invite.toml
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
innernet $DEFAULT_ARGS up --no-write-hosts "$INTERFACE"
|
innernet $INNERNET_ARGS up --no-write-hosts "$INTERFACE"
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DEFAULT_ARGS="--backend userspace"
|
INNERNET_ARGS="--backend userspace"
|
||||||
|
|
||||||
innernet-server \
|
innernet-server \
|
||||||
$DEFAULT_ARGS \
|
$INNERNET_ARGS \
|
||||||
new \
|
new \
|
||||||
--network-name "evilcorp" \
|
--network-name "evilcorp" \
|
||||||
--network-cidr "10.66.0.0/16" \
|
--network-cidr "10.66.0.0/16" \
|
||||||
|
@ -12,7 +12,7 @@ innernet-server \
|
||||||
--listen-port 51820
|
--listen-port 51820
|
||||||
|
|
||||||
innernet-server \
|
innernet-server \
|
||||||
$DEFAULT_ARGS \
|
$INNERNET_ARGS \
|
||||||
add-cidr evilcorp \
|
add-cidr evilcorp \
|
||||||
--name "humans" \
|
--name "humans" \
|
||||||
--cidr "10.66.1.0/24" \
|
--cidr "10.66.1.0/24" \
|
||||||
|
@ -20,7 +20,7 @@ innernet-server \
|
||||||
--yes
|
--yes
|
||||||
|
|
||||||
innernet-server \
|
innernet-server \
|
||||||
$DEFAULT_ARGS \
|
$INNERNET_ARGS \
|
||||||
add-peer evilcorp \
|
add-peer evilcorp \
|
||||||
--name "admin" \
|
--name "admin" \
|
||||||
--cidr "humans" \
|
--cidr "humans" \
|
||||||
|
@ -30,4 +30,4 @@ innernet-server \
|
||||||
--invite-expires "30d" \
|
--invite-expires "30d" \
|
||||||
--yes
|
--yes
|
||||||
|
|
||||||
innernet-server $DEFAULT_ARGS serve evilcorp
|
innernet-server $INNERNET_ARGS serve evilcorp
|
||||||
|
|
Loading…
Reference in New Issue