CE-cms-xrootd-fallback 4.94 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /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

62
63
64
65
66
dn=`voms-proxy-info --identity`
fqan=`voms-proxy-info --fqan | head -1`
add2buffer "DN: $dn"
add2buffer "Primary FQAN: $fqan"

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# 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="/store/test/xrootd/CMSSAM/$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