bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_mtr/mtr_test.sh

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