selftests: mptcp: more stable diag tests
commit42fb6cddec
upstream. The mentioned test-case still use an hard-coded-len sleep to wait for a relative large number of connection to be established. On very slow VM and with debug build such timeout could be exceeded, causing failures in our CI. Address the issue polling for the expected condition several times, up to an unreasonable high amount of time. On reasonably fast system the self-tests will be faster then before, on very slow one we will still catch the correct condition. Fixes:df62f2ec3d
("selftests/mptcp: add diag interface tests") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
536d2a6a4f
Коммит
0b842b9e84
|
@ -61,6 +61,39 @@ chk_msk_nr()
|
|||
__chk_nr "grep -c token:" $*
|
||||
}
|
||||
|
||||
wait_msk_nr()
|
||||
{
|
||||
local condition="grep -c token:"
|
||||
local expected=$1
|
||||
local timeout=20
|
||||
local msg nr
|
||||
local max=0
|
||||
local i=0
|
||||
|
||||
shift 1
|
||||
msg=$*
|
||||
|
||||
while [ $i -lt $timeout ]; do
|
||||
nr=$(ss -inmHMN $ns | $condition)
|
||||
[ $nr == $expected ] && break;
|
||||
[ $nr -gt $max ] && max=$nr
|
||||
i=$((i + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
printf "%-50s" "$msg"
|
||||
if [ $i -ge $timeout ]; then
|
||||
echo "[ fail ] timeout while expecting $expected max $max last $nr"
|
||||
ret=$test_cnt
|
||||
elif [ $nr != $expected ]; then
|
||||
echo "[ fail ] expected $expected found $nr"
|
||||
ret=$test_cnt
|
||||
else
|
||||
echo "[ ok ]"
|
||||
fi
|
||||
test_cnt=$((test_cnt+1))
|
||||
}
|
||||
|
||||
chk_msk_fallback_nr()
|
||||
{
|
||||
__chk_nr "grep -c fallback" $*
|
||||
|
@ -109,7 +142,7 @@ ip -n $ns link set dev lo up
|
|||
echo "a" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p 10000 -l -t ${timeout_poll} \
|
||||
./mptcp_connect -p 10000 -l -t ${timeout_poll} -w 20 \
|
||||
0.0.0.0 >/dev/null &
|
||||
wait_local_port_listen $ns 10000
|
||||
chk_msk_nr 0 "no msk on netns creation"
|
||||
|
@ -117,7 +150,7 @@ chk_msk_nr 0 "no msk on netns creation"
|
|||
echo "b" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} \
|
||||
./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} -w 20 \
|
||||
127.0.0.1 >/dev/null &
|
||||
wait_connected $ns 10000
|
||||
chk_msk_nr 2 "after MPC handshake "
|
||||
|
@ -129,13 +162,13 @@ flush_pids
|
|||
echo "a" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} \
|
||||
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} -w 20 \
|
||||
0.0.0.0 >/dev/null &
|
||||
wait_local_port_listen $ns 10001
|
||||
echo "b" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} \
|
||||
./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} -w 20 \
|
||||
127.0.0.1 >/dev/null &
|
||||
wait_connected $ns 10001
|
||||
chk_msk_fallback_nr 1 "check fallback"
|
||||
|
@ -146,7 +179,7 @@ for I in `seq 1 $NR_CLIENTS`; do
|
|||
echo "a" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p $((I+10001)) -l -w 10 \
|
||||
./mptcp_connect -p $((I+10001)) -l -w 20 \
|
||||
-t ${timeout_poll} 0.0.0.0 >/dev/null &
|
||||
done
|
||||
wait_local_port_listen $ns $((NR_CLIENTS + 10001))
|
||||
|
@ -155,12 +188,11 @@ for I in `seq 1 $NR_CLIENTS`; do
|
|||
echo "b" | \
|
||||
timeout ${timeout_test} \
|
||||
ip netns exec $ns \
|
||||
./mptcp_connect -p $((I+10001)) -w 10 \
|
||||
./mptcp_connect -p $((I+10001)) -w 20 \
|
||||
-t ${timeout_poll} 127.0.0.1 >/dev/null &
|
||||
done
|
||||
sleep 1.5
|
||||
|
||||
chk_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
|
||||
wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
|
||||
flush_pids
|
||||
|
||||
exit $ret
|
||||
|
|
Загрузка…
Ссылка в новой задаче