Commit ccffa9b4 authored by Edita Kizinevic's avatar Edita Kizinevic
Browse files

Use fn-req instead of the python client

parent 20921522
#!/bin/bash
shopt -s expand_aliases
SCRIPT_REVISION="2019-03-05, Dave Dykstra and Edita Kizinevič"
# Source the CMS environment
if [ -n "$OSG_GRID" ] ; then
[ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh
if [ -d $OSG_APP/cmssoft/cms ] ;then
if [ -d $OSG_APP/cmssoft/cms ] ; then
SW_DIR=$OSG_APP/cmssoft/cms
elif [ -d $CVMFS/cms.cern.ch ] ; then
SW_DIR=$CVMFS/cms.cern.ch
......@@ -33,8 +37,133 @@ if [ $result != 0 -o $result2 == 0 ] ; then
fi
rm -f $tmpfile
# Execute main test script
$SAME_SENSOR_HOME/tests/test_squid.py > squid.out 2>&1
result=$?
cat squid.out
exit $result
# Print out node name
node=`hostname`
echo "node: $node"
echo
# Check that environmental variable SAME_OK is set
if [ -z "$SAME_OK" ] ; then
echo "ERROR: SAME_OK not defined"
exit 1
fi
# Check that environmental variable SAME_ERROR is set
if [ -z "$SAME_ERROR" ] ; then
echo "ERROR: SAME_ERROR not defined"
exit 1
fi
# Check that environmental variable SAME_WARNING is set
if [ -z "$SAME_WARNING" ] ; then
echo "ERROR: SAME_WARNING not defined"
exit 1
fi
# Check that environmental variable CMS_PATH is set
if [ -z "$CMS_PATH" ] ; then
echo "ERROR: CMS_PATH not defined"
exit 1
fi
# Print script version information
echo "script version: $SCRIPT_REVISION"
echo
# Create Working Directory
mkdir squid
cd squid
current=`pwd`
echo "Current directory is: ${current}"
echo
# Set up CMSSW
echo "Set up CMSSW ... starting"
CMSREL="`scram l | grep -B 1 "cms.cern.ch" | grep " CMSSW" | tail -1 | awk '{print $2}'`"
scram p $CMSREL
if [ $? -ne 0 ] ; then
echo "ERROR: $CMSREL not available"
exit $SAME_WARNING
fi
echo "Set up CMSSW ... completed"
echo
cd $CMSREL/src
cmsenv
# Function to check proxies
# $1 - list of proxies
check_proxies() {
for PART in $1; do
proxy=`echo $PART | sed 's/^.*(/(/'`
case $proxy in
*"(proxyurl="*)
hostname=${proxy#*//}
hostname=${hostname%:*}
IP_addresses=`host $hostname | awk '{ print $NF }'`
if [ "$IP_addresses" == "3(NXDOMAIN)" ]; then
echo "Host $hostname not found"
echo
ever_failed=true
continue
fi
IPv4_addresses=()
IPv6_addresses=()
for IP_address in $IP_addresses; do
if [[ $IP_address =~ .*:.* ]]; then
IPv6_addresses+=( "[$IP_address]" )
else
IPv4_addresses+=( $IP_address )
fi
done
if [ ${#IPv4_addresses[@]} -eq 0 ]; then
# The frontier client does not work with IPv6 addresses in URLs for now
IP_addresses=( $hostname ) # ( "${IPv6_addresses[@]}" )
else
IP_addresses=( "${IPv4_addresses[@]}" )
fi
for IP_address in "${IP_addresses[@]}"; do
proxy_IP=`echo $proxy | sed "s/$hostname/$IP_address/g"`
echo "Query $proxy started:" `date`
echo 'select 1 from dual' | FRONTIER_SERVER="$proxy_IP(serverurl=http://cmsfrontier.cern.ch:8000/FrontierProd)(failovertoserver=no)" fn-req > $output
if grep -q " 1 NUMBER" $output ; then
echo "$proxy_IP is OK"
else
echo "$proxy_IP is FAILED:"
cat $output
ever_failed=true
fi
echo "Query $proxy ended:" `date`
echo
done
;;
*"(proxyconfigurl="*)
echo "Converting $proxy proxyconfigurl to configurl started:" `date`
echo
PROXYLIST="`echo 'select 1 from dual' | FRONTIER_LOG_LEVEL=debug FRONTIER_SERVER="$proxy(serverurl=http://cmsfrontier.cern.ch:8000/FrontierProd)(failovertoserver=no)" fn-req 2>&1 | sed -n '/returned "PROXY/{s/.*returned "//;s/PROXY /(proxyurl=/g;s/;/)/g;s/"/)/;p;q}'`"
check_proxies "$PROXYLIST"
echo "Converting $proxy proxyconfigurl to configurl ended:" `date`
echo
;;
esac
done
}
# Print out cmsGetFnConnect frontier://FrontierProd
FNCONNECT="`cmsGetFnConnect frontier://FrontierProd | sed 's/)/) /g'`"
echo "Contents of cmsGetFnConnect frontier://FrontierProd are:"
echo "$FNCONNECT" | tr " " "\n"
echo
# Check proxies
output="output.txt"
ever_failed=false
check_proxies "$FNCONNECT"
#Check test results
if $ever_failed ; then
echo "Proxy test is FAILED."
exit $SAME_ERROR
else
echo "Proxy test is OK"
exit $SAME_OK
fi
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment