Fix ping loss detection

Packet loss detection worked not correct when percentage was lower
than 1% (e.g. 0.172282%). This caused not relevant fails of upgrade
jobs in CI. See example below:

5224 packets transmitted, 5215 received, 0.172282% packet loss, time 5570ms
rtt min/avg/max/mdev = 0.398/0.801/14.855/0.449 ms
Ping loss higher than 1% detected

Change-Id: Ief3fb1d22fc6b69d79b8b28ec8e986437f456e80
This commit is contained in:
Roman Safronov 2019-10-06 09:51:54 +03:00
parent 4749631d43
commit 6ecf38c4ed

View File

@ -11,8 +11,8 @@ PING_RESULT_LOG=$(find ~ -iname 'ping_results*' | sort | tail -1)
tail -2 $PING_RESULT_LOG
# check results
PING_RESULT=$( awk '/[[:digit:]]+% packet loss/' $PING_RESULT_LOG | grep -Eo '[[:digit:]]+%' | sed s/\%// )
if [[ $PING_RESULT -gt {{ loss_threshold|default(1)|int }} ]]; then
PING_RESULT=$( grep 'packet loss' $PING_RESULT_LOG | sed 's/.*,\s\(.*\)%.*$/\1/' )
if [ $(echo "$PING_RESULT > {{ loss_threshold|default(1)|int }}" | bc ) -ne 0 ]; then
echo "Ping loss higher than {{ loss_threshold|default(1)|int }}% detected"
exit 1
fi