aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tests/netns.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-04-30 22:20:28 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2022-05-05 16:08:26 +0200
commit894152a5b89655863b012b707643f66a06e1c60a (patch)
tree33ad9b650a904f5c796c317fc8354930096a4783 /src/tests/netns.sh
parentnetns: make routing loop test non-fatal (diff)
downloadwireguard-linux-compat-894152a5b89655863b012b707643f66a06e1c60a.tar.xz
wireguard-linux-compat-894152a5b89655863b012b707643f66a06e1c60a.zip
netns: limit parallelism to $(nproc) tests at once
The parallel tests were added to catch queueing issues from multiple cores. But what happens in reality when testing tons of processes is that these separate threads wind up fighting with the scheduler, and we wind up with contention in places we don't care about that decrease the chances of hitting a bug. So just do a test with the number of CPU cores, rather than trying to scale up arbitrarily. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/tests/netns.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tests/netns.sh b/src/tests/netns.sh
index 7693d44..f21d599 100755
--- a/src/tests/netns.sh
+++ b/src/tests/netns.sh
@@ -22,10 +22,12 @@
# interfaces in $ns1 and $ns2. See https://www.wireguard.com/netns/ for further
# details on how this is accomplished.
set -e
+shopt -s extglob
exec 3>&1
export LANG=C
export WG_HIDE_KEYS=never
+NPROC=( /sys/devices/system/cpu/cpu+([0-9]) ); NPROC=${#NPROC[@]}
netns0="wg-test-$$-0"
netns1="wg-test-$$-1"
netns2="wg-test-$$-2"
@@ -147,17 +149,15 @@ tests() {
[[ $(< /proc/version) =~ ^Linux\ version\ 5\.4[.\ ] ]] || return 0
# TCP over IPv4, in parallel
- for max in 4 5 50; do
- local pids=( )
- for ((i=0; i < max; ++i)) do
- n2 iperf3 -p $(( 5200 + i )) -s -1 -B 192.168.241.2 &
- pids+=( $! ); waitiperf $netns2 $! $(( 5200 + i ))
- done
- for ((i=0; i < max; ++i)) do
- n1 iperf3 -Z -t 3 -p $(( 5200 + i )) -c 192.168.241.2 &
- done
- wait "${pids[@]}"
+ local pids=( ) i
+ for ((i=0; i < NPROC; ++i)) do
+ n2 iperf3 -p $(( 5200 + i )) -s -1 -B 192.168.241.2 &
+ pids+=( $! ); waitiperf $netns2 $! $(( 5200 + i ))
done
+ for ((i=0; i < NPROC; ++i)) do
+ n1 iperf3 -Z -t 3 -p $(( 5200 + i )) -c 192.168.241.2 &
+ done
+ wait "${pids[@]}"
}
[[ $(ip1 link show dev wg0) =~ mtu\ ([0-9]+) ]] && orig_mtu="${BASH_REMATCH[1]}"