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 08145a
t_Log "Running $0 - running traceroute to webhost"
Christoph Galuschka 08145a
Christoph Galuschka 08145a
# Testing availability of network
Karanbir Singh 23b6ba
if [ $SKIP_QA_HARNESS -eq 1 ]; then
Christoph Galuschka 08145a
  HOST="www.centos.org"
Christoph Galuschka 08145a
else
Christoph Galuschka 08145a
  HOST="repo.centos.qa"
Christoph Galuschka 08145a
fi
Christoph Galuschka 08145a
Christoph Galuschka 08145a
ping -q -c 5 -i 0.25 ${HOST}
Christoph Galuschka 08145a
if [ $? = 0 ]
Christoph Galuschka 08145a
then
Christoph Galuschka 08145a
  t_Log "$HOST is available - continuing"
Christoph Galuschka 08145a
  COUNT=$( traceroute ${HOST} | grep -c ${HOST} )
Christoph Galuschka 08145a
  if [ $COUNT = 2 ]
Christoph Galuschka 08145a
  then
Christoph Galuschka 08145a
    t_Log "traceroute reached ${HOST} and nslookup seems to work, too"
Christoph Galuschka 08145a
    ret_val=0
Christoph Galuschka 08145a
  else
Christoph Galuschka 08145a
    t_Log "traceroute didn't reach ${HOST}"
Christoph Galuschka 08145a
    ret_val=1
Christoph Galuschka 08145a
  fi
Christoph Galuschka 08145a
else
Christoph Galuschka 08145a
  t_Log "$HOST seems to be unavailable - skipping"
Christoph Galuschka 08145a
  ret_val=0
Christoph Galuschka 08145a
fi
Christoph Galuschka 08145a
Christoph Galuschka 08145a
t_CheckExitStatus $ret_val