Compare commits
4 Commits
bc798acffa
...
a77617ae96
Author | SHA1 | Date | |
---|---|---|---|
|
a77617ae96 | ||
|
ae70278a9f | ||
|
0b486d5d27 | ||
|
d2d25d3621 |
@ -52,6 +52,10 @@ vpn:
|
|||||||
|
|
||||||
# That's it.
|
# That's it.
|
||||||
|
|
||||||
|
tun:
|
||||||
|
# Name of the tun network device which will route VPN traffic.
|
||||||
|
device: isle-tun
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
|
|
||||||
# Allocations defined here are used to store data in the distributed storage
|
# Allocations defined here are used to store data in the distributed storage
|
||||||
|
13
default.nix
13
default.nix
@ -165,8 +165,17 @@ in rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tests = pkgs.writeShellScript "isle-tests" ''
|
tests = pkgs.writeShellScript "isle-tests" ''
|
||||||
export PATH=$PATH:${appImage}/bin
|
export PATH=${appImage}/bin:$PATH
|
||||||
test_dir=${./tests}
|
test_dir=${./tests}
|
||||||
exec $SHELL $test_dir/entrypoint.sh "$@"
|
|
||||||
|
this_user="$(${pkgs.coreutils}/bin/whoami)"
|
||||||
|
|
||||||
|
echo "Requesting sudo in order to set thread capabilities, will drop back down to user '$this_user' immediately"
|
||||||
|
sudo ${pkgs.libcap}/bin/capsh \
|
||||||
|
--caps="cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" \
|
||||||
|
--keep=1 \
|
||||||
|
--user="$this_user" \
|
||||||
|
--addamb=cap_net_admin \
|
||||||
|
-- $test_dir/entrypoint.sh "$@"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func nebulaPmuxProcConfig(
|
|||||||
"respond": true,
|
"respond": true,
|
||||||
},
|
},
|
||||||
"tun": map[string]interface{}{
|
"tun": map[string]interface{}{
|
||||||
"dev": "isle-tun",
|
"dev": daemonConfig.VPN.Tun.Device,
|
||||||
},
|
},
|
||||||
"firewall": daemonConfig.VPN.Firewall,
|
"firewall": daemonConfig.VPN.Firewall,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@ package daemon
|
|||||||
|
|
||||||
import "strconv"
|
import "strconv"
|
||||||
|
|
||||||
|
type ConfigTun struct {
|
||||||
|
Device string `yaml:"device"`
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigFirewall struct {
|
type ConfigFirewall struct {
|
||||||
Conntrack ConfigConntrack `yaml:"conntrack"`
|
Conntrack ConfigConntrack `yaml:"conntrack"`
|
||||||
Outbound []ConfigFirewallRule `yaml:"outbound"`
|
Outbound []ConfigFirewallRule `yaml:"outbound"`
|
||||||
@ -50,6 +54,7 @@ type Config struct {
|
|||||||
VPN struct {
|
VPN struct {
|
||||||
PublicAddr string `yaml:"public_addr"`
|
PublicAddr string `yaml:"public_addr"`
|
||||||
Firewall ConfigFirewall `yaml:"firewall"`
|
Firewall ConfigFirewall `yaml:"firewall"`
|
||||||
|
Tun ConfigTun `yaml:"tun"`
|
||||||
} `yaml:"vpn"`
|
} `yaml:"vpn"`
|
||||||
Storage struct {
|
Storage struct {
|
||||||
Allocations []ConfigStorageAllocation
|
Allocations []ConfigStorageAllocation
|
||||||
|
31
tests/01-create-network.sh
Normal file
31
tests/01-create-network.sh
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
mkdir a
|
||||||
|
mkdir b
|
||||||
|
mkdir c
|
||||||
|
|
||||||
|
cat >daemon.yml <<EOF
|
||||||
|
vpn:
|
||||||
|
tun:
|
||||||
|
device: isle-test
|
||||||
|
storage:
|
||||||
|
allocations:
|
||||||
|
- data_path: a/data
|
||||||
|
meta_path: a/meta
|
||||||
|
capacity: 100
|
||||||
|
- data_path: b/data
|
||||||
|
meta_path: b/meta
|
||||||
|
capacity: 100
|
||||||
|
- data_path: c/data
|
||||||
|
meta_path: c/meta
|
||||||
|
capacity: 100
|
||||||
|
EOF
|
||||||
|
|
||||||
|
isle admin create-network \
|
||||||
|
--config-path daemon.yml \
|
||||||
|
--domain test.isle.com \
|
||||||
|
--hostname primus \
|
||||||
|
--ip-net "10.6.9.1/24" \
|
||||||
|
--name "testing"
|
||||||
|
|
||||||
|
[ "$(cat a/meta/isle/rpc_port)" = "3900" ]
|
||||||
|
[ "$(cat b/meta/isle/rpc_port)" = "3910" ]
|
||||||
|
[ "$(cat c/meta/isle/rpc_port)" = "3920" ]
|
@ -1,14 +1,30 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
REGEXS=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
cat <<EOF
|
||||||
|
USAGE: [flags] [test regexs...]
|
||||||
|
FLAGS
|
||||||
|
--keep-tmp
|
||||||
|
--verbose (-v)
|
||||||
|
--help (-h)
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
-v|--verbose)
|
-v|--verbose)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
shift;
|
shift
|
||||||
|
;;
|
||||||
|
--keep-tmp)
|
||||||
|
KEEP_TMP=1
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "USAGE: [-v|--verbose]"
|
REGEXS+=("$1")
|
||||||
exit 1
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -18,7 +34,7 @@ cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
|
|||||||
root=$(pwd)
|
root=$(pwd)
|
||||||
|
|
||||||
TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
|
TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
|
||||||
trap 'rm -rf $TMPDIR' EXIT
|
if [ -z "$KEEP_TMP" ]; then trap 'rm -rf $TMPDIR' EXIT; fi
|
||||||
|
|
||||||
export TMPDIR
|
export TMPDIR
|
||||||
echo "tmp dir is $TMPDIR"
|
echo "tmp dir is $TMPDIR"
|
||||||
@ -30,25 +46,35 @@ test_files=$(
|
|||||||
| sort -n\
|
| sort -n\
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for r in "${REGEXS[@]}"; do
|
||||||
|
test_files="$(echo "$test_files" | grep -P "$r")"
|
||||||
|
done
|
||||||
|
|
||||||
echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
|
echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
|
||||||
for file in $test_files; do
|
for file in $test_files; do
|
||||||
echo "$file"
|
echo "$file"
|
||||||
|
|
||||||
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
|
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
|
||||||
|
|
||||||
tmp="$TMPDIR/$file.tmp"
|
(
|
||||||
mkdir -p "$tmp"
|
export TMPDIR="$TMPDIR/$file.tmp"
|
||||||
|
export XDG_RUNTIME_DIR="$TMPDIR/.run"
|
||||||
|
export XDG_DATA_HOME="$TMPDIR/.data"
|
||||||
|
|
||||||
if ! (cd "$tmp" && TMPDIR="$tmp" $SHELL -e -x "$root/$file" >"$output" 2>&1); then
|
mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME"
|
||||||
echo "$file FAILED"
|
cd "$TMPDIR"
|
||||||
if [ -z "$VERBOSE" ]; then
|
|
||||||
echo "output of test is as follows"
|
if ! $SHELL -e -x "$root/$file" >"$output" 2>&1; then
|
||||||
echo "------------------------------"
|
echo "$file FAILED"
|
||||||
cat "$TMPDIR/$file.log"
|
if [ -z "$VERBOSE" ]; then
|
||||||
echo "------------------------------"
|
echo "output of test is as follows"
|
||||||
|
echo "------------------------------"
|
||||||
|
cat "$output"
|
||||||
|
echo "------------------------------"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
exit 1
|
)
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e '\nall tests succeeded!'
|
echo -e '\nall tests succeeded!'
|
||||||
|
Loading…
Reference in New Issue
Block a user