#! /bin/bash function add2buffer { echo "`date`: $1" } function do_print { echo "summary: $1" } # Change to test directory cd `dirname $0` # parse arguments verbosity="1" while getopts "v:H:t:" flag do case "$flag" in v) verbosity=$OPTARG;; H) host=$OPTARG;; t) timeout=$OPTARG;; esac done # For now, never give failures - just warnings NAG_CRITICAL=$NAG_WARNING # Default to successful job exitcode=$NAG_OK # Print environment information now="`date -u +'%F %T'` UTC" currdir=$PWD host=`uname -n` pilotid=`/usr/bin/id` pilotidu=`/usr/bin/id -u` pilotidg=`id -G | tr ' ' '\n' | sort -n | tr '\n' ' '` add2buffer "Ran at $now on host $host, directory $currdir, as user:" add2buffer "$pilotid" # Check that $X509_USER_PROXY points to an existing file if [ -z "$X509_USER_PROXY" ]; then do_print "Error: X509_USER_PROXY is not defined" exit $NAG_CRITICAL fi if [ -f "$X509_USER_PROXY" ]; then add2buffer "X509_USER_PROXY=$X509_USER_PROXY" else do_print "Error: X509_USER_PROXY points to a non existing location" exit $NAG_CRITICAL fi # workaround to suppress voms errors on OSG export VOMS_PROXY_INFO_DONT_VERIFY_AC="1" # Setup the grid environment: if [ -n "$OSG_GRID" ] ; then [ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh fi dn=`voms-proxy-info --identity` fqan=`voms-proxy-info --fqan | head -1` add2buffer "DN: $dn" add2buffer "Primary FQAN: $fqan" # Set the CMS environment if [ -n "$VO_CMS_SW_DIR" ]; then SW_DIR=$VO_CMS_SW_DIR add2buffer "VO_CMS_SW_DIR=$VO_CMS_SW_DIR" elif [ -n "$OSG_APP" ] ; then SW_DIR=$OSG_APP/cmssoft/cms add2buffer "OSG_APP/cmssoft/cms=$OSG_APP/cmssoft/cms" elif [ -n "$CVMFS" ] ; then SW_DIR=$CVMFS/cms.cern.ch add2buffer "CVMFS (via env)=$CVMFS/cms.cern.ch" elif [ -e "/cvmfs/cms.cern.ch" ] ; then SW_DIR=/cvmfs/cms.cern.ch add2buffer "CVMFS=/cvmfs/cms.cern.ch" else do_print "Error: None of OSG_APP, VO_CMS_SW_DIR, or CVMFS are present." exit $NAG_CRITICAL fi if [ ! -f $SW_DIR/cmsset_default.sh ]; then do_print "Error: cmssw setup file $SW_DIR/cmsset_default.sh not existing" exit $NAG_CRITICAL fi add2buffer "CMS configuration file: $SW_DIR/cmsset_default.sh" export SCRAM_ARCH=slc5_amd64_gcc462 source $SW_DIR/cmsset_default.sh err=$? if [ $err != 0 ]; then do_print "Error: CMS software initialisation script cmsset_default.sh failed" exit $NAG_CRITICAL fi if [ -z $CMS_PATH ]; then do_print "Error: CMS_PATH not defined" exit $NAG_CRITICAL fi if [ ! -d $CMS_PATH ] ; then do_print "Error: CMS_PATH directory $CMS_PATH not existing" exit $NAG_CRITICAL fi # Parse the local config file and find site name if [ ! -d $CMS_PATH/SITECONF/local/JobConfig ] ; then do_print "Error: JobConfig directory $CMS_PATH/SITECONF/local/JobConfig not existing" exit $NAG_CRITICAL fi ConfigFile=${CMS_PATH}/SITECONF/local/JobConfig/site-local-config.xml if [ ! -f $ConfigFile ] ; then do_print "Error: Local Configuration file site-local-config.xml not existing" exit $NAG_CRITICAL fi add2buffer "Local configuration file: $ConfigFile" grep -q "site name" $ConfigFile err=$? if [ $err != 0 ] ; then do_print "Error: site name string missing in config file" exit $NAG_CRITICAL fi siteName=`grep "site name" $ConfigFile | grep -v "subsite name" | cut -d'"' -f2` add2buffer "Site name: $siteName" cmssw_file="/store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root" xrootd_file="root://cms-xrd-global.cern.ch//store/test/xrootd/$siteName/$cmssw_file" add2buffer "Xrootd file we will test: $xrootd_file" cmssw_version="CMSSW_5_3_1" scramv1 p CMSSW $cmssw_version err=$? if [ $err != 0 ] ; then do_print "Error: cannot make $cmssw_version release area (SCRAM_ARCH=$SCRAM_ARCH)" exit $NAG_CRITICAL fi cd $cmssw_version if [ $? != 0 ] ; then do_print "Error: cannot cd into $cmssw_version directory" exit $NAG_CRITICAL fi cat > test_xrootd.py << EOF import FWCore.ParameterSet.Config as cms process = cms.Process('XrootdTest') process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring("$xrootd_file"), ) process.SiteLocalConfigService = cms.Service("SiteLocalConfigService", debugLevel = cms.untracked.uint32(1), ) process.dump = cms.EDAnalyzer("EventContentAnalyzer", listContent=cms.untracked.bool(False), getData=cms.untracked.bool(True)) process.load("FWCore.MessageService.MessageLogger_cfi") process.MessageLogger.cerr.FwkReport.reportEvery = 10 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) ) process.p = cms.Path(process.dump) EOF eval `scramv1 runtime -sh` err=$? if [ $err != 0 ] ; then do_print "Error $err: Cannot setup $cmssw_version environment (SCRAM_ARCH=$SCRAM_ARCH)" exit $NAG_CRITICAL fi cmsRun test_xrootd.py err=$? if [ $err -ne 0 ]; then do_print "cmsRun failed." exit $NAG_CRITICAL fi # exit if [ $exitcode -ne $NAG_OK ]; then do_print "Warning: execution contains warnings" else do_print "Success" fi exit $exitcode