From 06f0c0262205a9627b32c1c3cb5b982455794dc6 Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: May 06 2013 12:17:50 +0000 Subject: traceroute/-path now handle the new CI-environment better (traceroute/-path is blocked by ACLs and returns the ISPs router as final hop). --- diff --git a/tests/p_iputils/tracepath_test.sh b/tests/p_iputils/tracepath_test.sh index 63d273c..e625da0 100755 --- a/tests/p_iputils/tracepath_test.sh +++ b/tests/p_iputils/tracepath_test.sh @@ -15,21 +15,27 @@ t_Log "Running $0 - running ${TEST} to ${HOST}" IP=$(host ${HOST}) FILE=/var/tmp/tracepath_result ret_val=1 +# getting IP-address of default gateway as a fall back +defgw=$(ip route list | grep default | cut -d' ' -f3) -regex='.*address\ ([0-9.]*)' -if [[ $IP =~ $regex ]] +if [[ $IP =~ .*address\ ([0-9.]*) ]] then tracepath -n ${HOST} > ${FILE} COUNT=$(grep -c ${BASH_REMATCH[1]} ${FILE}) TTL=$(grep -c 'Too many hops' ${FILE}) + GW=$(grep -c ${defgw} ${FILE}) if ([ $COUNT = 1 ] || [ $COUNT = 2 ]) - then + then t_Log "${TEST} reached ${HOST}" ret_val=0 elif ([ $COUNT = 0 ] && [ $TTL = 1 ]) - then + then t_Log "${TEST} didn't reach ${HOST} because of too many hops. This is treated as SUCCESS." ret_val=0 + elif ([ $COUNT = 0 ] && [ $GW -gt 0 ]) + then + t_Log "${TEST} didn't reach ${HOST} (maybe because of ACLs on the network), but at least the Default Gateway ${defgw} was reached. Treating as SUCCESS." + ret_val=0 else t_Log "${TEST} didn't return anything we expect - FAILING" ret_val=1 diff --git a/tests/p_traceroute/traceroute_test.sh b/tests/p_traceroute/traceroute_test.sh index 8228efc..a92e653 100755 --- a/tests/p_traceroute/traceroute_test.sh +++ b/tests/p_traceroute/traceroute_test.sh @@ -15,13 +15,15 @@ t_Log "Running $0 - running ${TEST} to ${HOST}" IP=$(host ${HOST}) FILE=/var/tmp/traceroute_result ret_val=1 +# getting IP-address of default gateway as a fall back +defgw=$(ip route list | grep default | cut -d' ' -f3) -regex='.*address\ ([0-9.]*)' -if [[ $IP =~ $regex ]] +if [[ $IP =~ .*address\ ([0-9.]*) ]] then traceroute -n ${HOST} > ${FILE} COUNT=$(grep -c ${BASH_REMATCH[1]} ${FILE}) TTL=$(egrep -c '30 \* \* \*' ${FILE}) + GW=$(grep -c ${defgw} ${FILE}) if [ $COUNT = 2 ] then t_Log "${TEST} reached ${HOST}" @@ -30,9 +32,13 @@ then then t_Log "${TEST} didn't reach ${HOST} because of too many hops/blocked traceroute by ISP. This is treated as SUCCESS." ret_val=0 + elif ([ $COUNT != 2 ] && [ $GW -gt 0 ]) + then + t_Log "${TEST} didn't reach ${HOST} (maybe because of ACLs on the network), but at least the Default Gateway ${defgw} was reached. Treating as SUCCESS." + ret_val=0 else t_Log "${TEST} didn't return anything we expect - FAILING" - ret_val=1 + ret_val=1 fi fi