mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-21 15:33:23 +01:00
better test-bed scripts
This commit is contained in:
parent
d4d0fa945d
commit
db9ec36fac
11
hack/README.md
Normal file
11
hack/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Container based test bed for sshuttle
|
||||
|
||||
```bash
|
||||
test-bed up -d # start containers
|
||||
|
||||
exec-sshuttle node-1 # start sshuttle to connect to node-1
|
||||
|
||||
exec-tool curl node-1 # curl to nginx instance running on node1 via IP that is only reachable via sshuttle
|
||||
exec-tool iperf3 node-1 # measure throughput to node-1
|
||||
|
||||
```
|
@ -5,8 +5,6 @@ services:
|
||||
image: ghcr.io/sshuttle/sshuttle-testbed
|
||||
container_name: sshuttle-testbed-node-1
|
||||
hostname: node-1
|
||||
ports:
|
||||
- 22001:2222
|
||||
cap_add:
|
||||
- "NET_ADMIN"
|
||||
environment:
|
||||
@ -15,8 +13,6 @@ services:
|
||||
image: ghcr.io/sshuttle/sshuttle-testbed
|
||||
container_name: sshuttle-testbed-node-2
|
||||
hostname: node-2
|
||||
ports:
|
||||
- 22002:2222
|
||||
cap_add:
|
||||
- "NET_ADMIN"
|
||||
environment:
|
||||
|
@ -9,9 +9,9 @@ if [[ ! $node =~ [1-9]+ ]]; then
|
||||
fi
|
||||
shift
|
||||
|
||||
port="2200$node"
|
||||
port="2222"
|
||||
subnet_args="-N"
|
||||
host=localhost
|
||||
host=$("$(dirname "$0")/test-bed" get-ip "$node")
|
||||
user="test:test"
|
||||
|
||||
if ! command -v sshpass >/dev/null; then
|
||||
|
@ -2,10 +2,11 @@
|
||||
set -e
|
||||
|
||||
tool=${1?:"tool argument missing. should be one of iperf3,ping,curl,ab"}
|
||||
node=${2?:"node argument missing. should be '1' , '2' etc"}
|
||||
node=${2?:"node argument missing. should be 'node-1' , 'node-2' etc"}
|
||||
shift 2
|
||||
|
||||
ip="10.55.$node.77"
|
||||
index=${node#node-}
|
||||
ip="10.55.$index.77"
|
||||
connect_timeout_sec=3
|
||||
|
||||
function with_set_x() {
|
||||
@ -34,4 +35,8 @@ ab)
|
||||
port=8080
|
||||
with_set_x exec ab -n 100 -c 20 -s $connect_timeout_sec "$@" "http://$ip:$port/"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown tool: $tool" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
@ -5,14 +5,15 @@ cd "$(dirname "$0")"
|
||||
function with_set_x() {
|
||||
set -x
|
||||
"$@"
|
||||
{ ec=$?; set +x;return $ec; } 2>/dev/null
|
||||
{
|
||||
ec=$?
|
||||
set +x
|
||||
return $ec
|
||||
} 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
./test-bed up -d
|
||||
|
||||
|
||||
|
||||
benchmark() {
|
||||
local sshuttle_bin="${1?:}"
|
||||
echo -e "\n======== Benchmarking sshuttle: $sshuttle_bin ========"
|
||||
@ -29,12 +30,9 @@ benchmark() {
|
||||
wait $sshuttle_pid || true
|
||||
}
|
||||
|
||||
|
||||
if [[ "$1" ]]; then
|
||||
benchmark "$1"
|
||||
else
|
||||
benchmark "${SSHUTTLE_BIN:-/bin/sshuttle}"
|
||||
benchmark dev
|
||||
fi
|
||||
|
||||
|
||||
|
@ -6,4 +6,4 @@ export PYTHONPATH=.
|
||||
|
||||
set -x
|
||||
python -m pytest .
|
||||
python -m flake8 .
|
||||
python -m flake8 .
|
||||
|
@ -8,10 +8,13 @@ echo -e ">>> Setting up $(hostname) | id: $(id) | $(python --version) \nip: $(ip
|
||||
function with_set_x() {
|
||||
set -x
|
||||
"$@"
|
||||
{ ec=$?; set +x;return $ec; } 2>/dev/null
|
||||
{
|
||||
ec=$?
|
||||
set +x
|
||||
return $ec
|
||||
} 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
iface="$(ip route | awk '/default/ { print $5 }')"
|
||||
default_gw="$(ip route | awk '/default/ { print $3 }')"
|
||||
for addr in ${IP_ADDRESSES//,/ }; do
|
||||
|
@ -2,7 +2,6 @@
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
|
||||
if [[ -z $1 || $1 = -* ]]; then
|
||||
set -- up "$@"
|
||||
fi
|
||||
@ -10,7 +9,11 @@ fi
|
||||
function with_set_x() {
|
||||
set -x
|
||||
"$@"
|
||||
{ ec=$?; set +x;return $ec; } 2>/dev/null
|
||||
{
|
||||
ec=$?
|
||||
set +x
|
||||
return $ec
|
||||
} 2>/dev/null
|
||||
}
|
||||
|
||||
function build() {
|
||||
@ -23,8 +26,17 @@ function compose() {
|
||||
with_set_x docker compose "$@"
|
||||
}
|
||||
|
||||
function get-ip() {
|
||||
local container_name=sshuttle-testbed-"$1"
|
||||
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name"
|
||||
}
|
||||
|
||||
if [[ $* = *--build* ]]; then
|
||||
build
|
||||
if [[ $1 == get-ip ]]; then
|
||||
shift
|
||||
get-ip "$@"
|
||||
else
|
||||
if [[ $* = *--build* ]]; then
|
||||
build
|
||||
fi
|
||||
compose "$@"
|
||||
fi
|
||||
compose "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user