diff options
author | tiptorrent development team <tiptorrent@soleta.eu> | 2021-08-17 00:05:31 +0200 |
---|---|---|
committer | tiptorrent development team <tiptorrent@soleta.eu> | 2021-09-29 15:47:43 +0200 |
commit | 2610239d62d744294e55d44e46937bd6dea87559 (patch) | |
tree | a14c9da8d4156e31cd311b036287e7aa9c90a40f /tests |
initial commit
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/network-setup.sh | 84 | ||||
-rwxr-xr-x | tests/run-clients.sh | 18 |
2 files changed, 102 insertions, 0 deletions
diff --git a/tests/network-setup.sh b/tests/network-setup.sh new file mode 100755 index 0000000..c8f16db --- /dev/null +++ b/tests/network-setup.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +if [ $UID -ne 0 ] +then + echo "You must be root to run this test script" + exit 0 +fi + +# / c1 +# /- c2 +# srv ----- br -- c3 +# \- c4 + +start () { + ip netns add srv + ip netns add br + ip netns add c1 + ip netns add c2 + ip netns add c3 + ip netns add c4 + + ip link add veth0 netns srv type veth peer name veth0 netns br + ip link add veth1 netns br type veth peer name veth0 netns c1 + ip link add veth2 netns br type veth peer name veth0 netns c2 + ip link add veth3 netns br type veth peer name veth0 netns c3 + ip link add veth4 netns br type veth peer name veth0 netns c4 + + ip -net br link set up dev veth0 + ip -net br link set up dev veth1 + ip -net br link set up dev veth2 + ip -net br link set up dev veth3 + ip -net br link set up dev veth4 + ip -net br link add name br0 type bridge + ip -net br link set dev veth0 master br0 + ip -net br link set dev veth1 master br0 + ip -net br link set dev veth2 master br0 + ip -net br link set dev veth3 master br0 + ip -net br link set dev veth4 master br0 + ip -net br link set up dev br0 + + ip -net srv addr add 10.141.10.1/24 dev veth0 + ip -net srv link set up dev veth0 + ip netns exec srv .././grepo --max-clients 1 --redirect --root . & + + ip -net c1 addr add 10.141.10.2/24 dev veth0 + ip -net c1 link set up dev veth0 + ip netns exec c1 .././tiptorrent --max-clients 1 & + + ip -net c2 addr add 10.141.10.3/24 dev veth0 + ip -net c2 link set up dev veth0 + ip netns exec c2 .././tiptorrent --max-clients 1 & + + ip -net c3 addr add 10.141.10.4/24 dev veth0 + ip -net c3 link set up dev veth0 + ip netns exec c3 .././tiptorrent --max-clients 1 & + + ip -net c4 addr add 10.141.10.5/24 dev veth0 + ip -net c4 link set up dev veth0 + ip netns exec c4 .././tiptorrent --max-clients 1 & +} + +stop () { + ip netns del srv + ip netns del br + ip netns del c1 + ip netns del c2 + ip netns del c3 + ip netns del c4 + killall -15 tiptorrent +} + +case $1 in +start) + start + ;; +stop) + stop + ;; +*) + echo "$0 [start|stop]" + ;; +esac + +exit 0 diff --git a/tests/run-clients.sh b/tests/run-clients.sh new file mode 100755 index 0000000..3857494 --- /dev/null +++ b/tests/run-clients.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ ! -f TEST ] +then + echo "create the TEST first, e.g. dd if=/dev/urandom of=TEST bs=750M count=1 iflag=fullblock" + exit 0 +fi + +if [ $UID -ne 0 ] +then + echo "You must be root to run this test script" + exit 0 +fi + +ip netns exec c1 wget http://10.141.10.1:9999/TEST -O /dev/null & +ip netns exec c2 wget http://10.141.10.1:9999/TEST -O /dev/null & +ip netns exec c3 wget http://10.141.10.1:9999/TEST -O /dev/null & +ip netns exec c4 wget http://10.141.10.1:9999/TEST -O /dev/null & |