2024-01-01 17:42:17 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
function with_set_x() {
|
|
|
|
set -x
|
|
|
|
"$@"
|
2024-01-02 05:16:22 +01:00
|
|
|
{
|
|
|
|
ec=$?
|
|
|
|
set +x
|
|
|
|
return $ec
|
|
|
|
} 2>/dev/null
|
2024-01-01 17:42:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
./test-bed up -d
|
|
|
|
|
|
|
|
benchmark() {
|
|
|
|
local sshuttle_bin="${1?:}"
|
2024-01-02 07:33:24 +01:00
|
|
|
local node="${2:-'node-1'}"
|
2024-01-01 17:42:17 +01:00
|
|
|
echo -e "\n======== Benchmarking sshuttle: $sshuttle_bin ========"
|
2024-01-02 07:33:24 +01:00
|
|
|
./exec-sshuttle "$node" --sshuttle-bin="$sshuttle_bin" --listen 55771 &
|
2024-01-01 17:42:17 +01:00
|
|
|
sshuttle_pid=$!
|
|
|
|
trap 'kill -0 $sshuttle_pid &>/dev/null && kill -15 $sshuttle_pid' EXIT
|
|
|
|
while ! nc -z localhost 55771; do sleep 0.1; done
|
|
|
|
sleep 1
|
|
|
|
./exec-tool iperf3 1 --time=4
|
|
|
|
with_set_x kill -15 $sshuttle_pid
|
|
|
|
wait $sshuttle_pid || true
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" ]]; then
|
|
|
|
benchmark "$1"
|
|
|
|
else
|
2024-01-02 13:23:20 +01:00
|
|
|
benchmark "${SSHUTTLE_BIN:-sshuttle}" node-1
|
2024-01-02 07:33:24 +01:00
|
|
|
benchmark dev node-1
|
2024-01-01 17:42:17 +01:00
|
|
|
fi
|