bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_traceroute/traceroute_test.sh

Christoph Galuschka 08145a
#!/bin/sh
Christoph Galuschka 08145a
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 08145a
Christoph Galuschka 722da5
TEST=traceroute
Christoph Galuschka 722da5
t_Log "Running $0 - running ${TEST} to webhost"
Christoph Galuschka 08145a
Christoph Galuschka 372989
# Testing availability of network
Christoph Galuschka 372989
if [ $SKIP_QA_HARNESS -eq 1 ]; then
Christoph Galuschka 372989
  HOST="www.centos.org"
Christoph Galuschka 372989
else
Christoph Galuschka 372989
  HOST="repo.centos.qa"
Christoph Galuschka 372989
fi
Christoph Galuschka 372989
Christoph Galuschka 372989
IP=$(ping -qn -c 1 ${HOST} | grep -i 'ping '${HOST})
Christoph Galuschka 372989
Christoph Galuschka 372989
regex='PING\ '${HOST}'\ \(([0-9.]*)\).*'
Christoph Galuschka 8e8c03
if [[ $IP =~ $regex ]]
Christoph Galuschka 372989
then
Christoph Galuschka 372989
  t_Log "resolved ${HOST} successfully - continuing"
Christoph Galuschka 372989
  ping -q -c 2 -i 0.25 ${HOST}
Christoph Galuschka 372989
  if [ $? = 0 ]
Christoph Galuschka 8e8c03
  then
Christoph Galuschka 372989
    t_Log "$HOST is reachable - continuing"
Christoph Galuschka 372989
    COUNT=$( traceroute -n ${HOST} | grep -c ${BASH_REMATCH[1]} )
Christoph Galuschka 372989
    if [ $COUNT = 2 ]
Christoph Galuschka 372989
    then
Christoph Galuschka 722da5
      t_Log "${TEST} reached ${HOST}"
Christoph Galuschka 372989
      ret_val=0
Christoph Galuschka 372989
    else
Christoph Galuschka 722da5
      t_Log "${TEST} didn't reach ${HOST}"
Christoph Galuschka 372989
      ret_val=1
Christoph Galuschka 372989
    fi
Christoph Galuschka 08145a
  fi
Christoph Galuschka 08145a
else
Christoph Galuschka 372989
  t_Log "$HOST seems to be unavailable - skipping"
Christoph Galuschka 08145a
  ret_val=0
Christoph Galuschka 08145a
fi
Christoph Galuschka 08145a
Christoph Galuschka 722da5
t_CheckExitStatus $ret_val