CE-cms-dummy 10.7 KB
Newer Older
Stefano Belforte's avatar
Stefano Belforte committed
1
#!/bin/sh
Stefano Belforte's avatar
Stefano Belforte committed
2

Stefano Belforte's avatar
Stefano Belforte committed
3
4
5
6
7
info=0
note=0
warning=0
error=0

Stefano Belforte's avatar
Stefano Belforte committed
8
9
cat $SAME_SENSOR_HOME/tests/CMS-SAM-Banner.html

Stefano Belforte's avatar
Stefano Belforte committed
10
11
echo '<h1><a href="#summary">Jump to test summary</a></h1>'
echo "<h2>Preliminary checks</h2>"
12
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
13
echo "version 2-11 13:00"
Stefano Belforte's avatar
Stefano Belforte committed
14
set -x
15
16
17
18
uname -a
date
voms-proxy-info -identity -fqan
id
Stefano Belforte's avatar
Stefano Belforte committed
19
cp -v $SAME_SENSOR_HOME/tests/fetch-from-web .
Stefano Belforte's avatar
Stefano Belforte committed
20
#ls -l fetch-from-web
Stefano Belforte's avatar
Stefano Belforte committed
21
cp -v $SAME_SENSOR_HOME/tests/CMS-SAM-Banner.html .
Stefano Belforte's avatar
Stefano Belforte committed
22
env|grep SAME
Stefano Belforte's avatar
Stefano Belforte committed
23
set +x
Stefano Belforte's avatar
Stefano Belforte committed
24
echo "</pre>"
25

Stefano Belforte's avatar
Stefano Belforte committed
26
echo "<h2>Checking software directory for CMS VO</h2>"
27
if [ -n "$OSG_APP" ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
28
    SW_DIR=$OSG_APP/cmssoft/cms
Stefano Belforte's avatar
Stefano Belforte committed
29
30
    [ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh
    echo "Checking variable: \$OSG_APP/cmssoft/cms=$OSG_APP/cmssoft/cms"
31
32
elif [ -n "$VO_CMS_SW_DIR" ] ; then
    SW_DIR=$VO_CMS_SW_DIR
Stefano Belforte's avatar
Stefano Belforte committed
33
    echo "Checking variable: \$VO_CMS_SW_DIR=$VO_CMS_SW_DIR"
Stefano Belforte's avatar
Stefano Belforte committed
34
35
else
    echo "ERROR: Neither VO_CMS_SW_DIR nor OSG_APP defined"
Stefano Belforte's avatar
Stefano Belforte committed
36
    echo "summary: SW_DIR_UNDEF"
Stefano Belforte's avatar
Stefano Belforte committed
37
38
39
    exit $SAME_ERROR
fi
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
40
41
set -x
ls -ld $SW_DIR
Stefano Belforte's avatar
Stefano Belforte committed
42
result=$?
Stefano Belforte's avatar
Stefano Belforte committed
43
set +x
Stefano Belforte's avatar
Stefano Belforte committed
44
echo "</pre>"
Stefano Belforte's avatar
Stefano Belforte committed
45
46
echo

Stefano Belforte's avatar
Stefano Belforte committed
47
48
if [ $result != 0 ]
    then
Stefano Belforte's avatar
Stefano Belforte committed
49
50
    echo "ERROR: software directory non existent or non readable"
    echo "summary: NO_SW_DIR"
Stefano Belforte's avatar
Stefano Belforte committed
51
52
    exit $SAME_ERROR
fi
Stefano Belforte's avatar
Stefano Belforte committed
53
54
55
56
57
58

if [ ! -f $SW_DIR/cmsset_default.sh ] ; then
    echo "<h3>"
    echo "ERROR: cmssw setup file $SW_DIR/cmsset_default.sh not existing"
    echo "</h3>"
    echo "summary: NO_SETUP_SCRIPT"
Stefano Belforte's avatar
Stefano Belforte committed
59
60
61
    exit $SAME_ERROR
fi

Stefano Belforte's avatar
Stefano Belforte committed
62
63
echo "<h2>Sourcing the CMS environment</h2>"
export SCRAM_ARCH=slc4_ia32_gcc345
Stefano Belforte's avatar
Stefano Belforte committed
64
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
65
source $SW_DIR/cmsset_default.sh
66
67
result=$?
echo "</pre>"
Stefano Belforte's avatar
Stefano Belforte committed
68

Stefano Belforte's avatar
Stefano Belforte committed
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
if [ $result != 0 ]
    then
    echo "<h3>"
    echo "ERROR: CMS software initialisation script cmsset_default.sh failed"
    echo "summary: NO_SETUP_SCRIPT"
    echo "</h3>"
    exit $SAME_ERROR
fi

echo "<h2>Make sure configuration directory is there</h2>"
echo "Checking variable: \$CMS_PATH=$CMS_PATH"
echo "<p>"
if [ -z $CMS_PATH ]; then
    echo "<h3>"
    echo "ERROR: CMS_PATH not defined"
    echo "summary: CMS_PATH_UNDEF"
    echo "</h3>"
    exit $SAME_ERROR
fi

if [ ! -d $CMS_PATH ] ; then
    echo "<h3>"
    echo "ERROR: CMS_PATH directory $CMS_PATH not existing"
    echo "summary: NO_CMS_PATH"
    echo "</h3>"
    exit $SAME_ERROR
fi

if [ ! -d $CMS_PATH/SITECONF/local/JobConfig ] ; then
    echo "<h3>"
    echo "ERROR: JobConfig directory $CMS_PATH/SITECONF/local/JobConfig not existing"
    echo "summary: NO_JOBCONFIG_DIR"
    echo "</h3>"
    exit $SAME_ERROR
fi

echo "<p>"
echo "OK"

echo "<h2>Make sure configuration file exists</h2>"

ConfigFile=${CMS_PATH}/SITECONF/local/JobConfig/site-local-config.xml
echo "Configuration file: $ConfigFile"
echo "<p>"

if [ ! -f $ConfigFile ] ; then
    echo "<h3>"
    echo "ERROR: Local Configuration file site-local-config.xml not existing"
    echo "summary: NO_SITELOCALCONFIG"
    echo "</h3>"
    exit $SAME_ERROR
fi
echo "<p>"
echo "OK"
echo "dump of Local Configuration file is <a href=\"#CfgDump\">here</a>"

echo "<h2>Make sure local configuration file has entries for TriviaFileCatalog,
local stage, site name and Squid</h2>"

grep -q "trivialcatalog" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: TrivialFileCatlog string missing"
    errorSummary="summary: NO_TFC"
    error=1
fi

grep -q "local-stage-out" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: LocalStageOut string missing"
    errorSummary="summary: NO_LOCALSTAGEOUT"
    error=1
fi

grep -q "site name" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: site name string missing"
    errorSummary="summary: NO_SiteName"
    error=1
fi

grep -q "frontier-connect" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: Frontier Configuration string missing"
    errorSummary="summary: NO_FRONTIER_CONFIG"
    error=1
fi

if [ $error == 0 ] ; then
 echo "<p>"
 echo "OK"
fi

echo "<p>"

echo "<h2>Make sure TFC file is where config file says it should be</h2>"
TFCfile=`grep "trivialcatalog" $ConfigFile | cut -d':' -f2| cut -d'?' -f1|head -1`
echo "Checking file: $TFCfile"

if [ ! -f $TFCfile ] ; then
    echo "ERROR: TrivialFileCatalg $TFCfile not existing"
    errorSummary="summary: NO_TFC file"
    error=1
fi
#if [ $err == 1 ] ; then
#    exit $SAME_ERROR
#fi

echo "<p>"
echo "OK"
echo "<p>"

if [ $error == 1 ] ; then
    echo "<h3>"
    echo "ERROR: invalid local configuration file $ConfigFile"
    echo $errorSummary
    echo "</h3>"
Stefano Belforte's avatar
Stefano Belforte committed
189
190
fi

Stefano Belforte's avatar
Stefano Belforte committed
191
192
193
echo "<h2>Compare local configuration file and TFC with CVS</h2>"

siteName=`grep "site name" $ConfigFile | grep -v "subsite name" | cut -d'"' -f2`
Stefano Belforte's avatar
Stefano Belforte committed
194
195
196
197
let seconds=`date %s`-`stat -c%Y $ConfigFile`
let localConfigFileAgeInHours=$seconds/3600
echo local configuration file ${ConfigFile} is ${localConfigFileAgeInHours} hours old

Stefano Belforte's avatar
Stefano Belforte committed
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
echo "siteName =" $siteName
subSiteName=`grep "subsite name" $ConfigFile | cut -d'"' -f2`
_subSiteName=
if [ "x$subSiteName" == "x" ] ; then
   echo "subSiteName =" $subSiteName
else
   echo "subSiteName =" $subSiteName
   _subSiteName=_`echo $subSiteName`
fi
echo "<br>"

asCvs=1
cvsUrl="\"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/JobConfig/site-local-config${_subSiteName}.xml?rev=HEAD&content-type=text/plain\""
ConfigFileFromCVS=`mktemp /tmp/site-local-config-from-CVS.xml.XXX`
echo "Fetch CVS copy of local config from $cvsUrl<br>"
./fetch-from-web $cvsUrl $ConfigFileFromCVS
rc=$?
echo "rc = $rc <br>"
[ $rc == $SAME_INFO ] && info=1
[ $rc == $SAME_WARNING ] && warning=1

#if [ $rc == $SAME_WARNING ] || [ $rc == $SAME_ERROR ] ; then
#  echo "<br>INFO: failed to access CVS Web repository<bre>"
#else


if [ $rc == $SAME_OK ] || [ $rc == $SAME_INFO ] ; then
  diff -q -w -B $ConfigFile $ConfigFileFromCVS
  if [ $? == 1 ] ; then asCvs=0; fi
  echo "<br>"
  if [ $asCvs == 0 ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
229
230
231
232
233
234
235
236
    if [ $localConfigFileAgeInHours -gt 72 ] then
      error=1
      echo "<strong>ERROR: local site configuration file differ from CVS</strong>"
    else
      warning=1
      echo "<strong>WARNING: local site configuration file differ from CVS</strong>"
      echo "<br>will become error if this difference lasts more then 72h"
    fi
Stefano Belforte's avatar
Stefano Belforte committed
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    diffList=`mktemp /tmp/diflist.XXXX`
    diff $ConfigFile $ConfigFileFromCVS > $diffList
    echo "<pre>"
    cat $diffList | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
    echo "</pre>"
    rm -f $diffList
  else
    echo "OK local site configuration file agrees with CVS copy"
    echo "<br>"
  fi
  rm -f $ConfigFileFromCVS
else
  echo "<br>INFO: failed to access CVS Web repository<bre>"
  info=1
Stefano Belforte's avatar
Stefano Belforte committed
251
fi
Stefano Belforte's avatar
Stefano Belforte committed
252
253
254
255
echo "<br>"

echo "dump of Local Configuration file is <a href=\"#CfgDump\">here</a>"
echo "<br>"
Stefano Belforte's avatar
Stefano Belforte committed
256

Stefano Belforte's avatar
Stefano Belforte committed
257
TFCfileName=`echo $TFCfile | awk -F'/' '{print $NF}'`
Stefano Belforte's avatar
Stefano Belforte committed
258
259
260
261

let seconds=`date %s`-`stat -c%Y $ConfigFile`
let localTFCfileAgeInHours=$seconds/3600
echo local configuration file ${TFCfile} is ${localTFCfileAgeInHours} hours old
Stefano Belforte's avatar
Stefano Belforte committed
262
263

asCvs=1
Stefano Belforte's avatar
Stefano Belforte committed
264
#cvsUrl="\"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/PhEDEx/storage${_subSiteName}.xml?rev=HEAD&content-type=text/plain\""
Stefano Belforte's avatar
Stefano Belforte committed
265

Stefano Belforte's avatar
Stefano Belforte committed
266
267
268
269
cvsUrl="\"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/PhEDEx/${TFCfileName}?rev=HEAD&content-type=text/plain\""

echo "<pre>"
echo TFCfileName: $TFCfileName
Stefano Belforte's avatar
Stefano Belforte committed
270
271
272
echo cvsUrl $cvsUrl
echo"</pre>"

Stefano Belforte's avatar
Stefano Belforte committed
273
TfcFileFromCVS=`mktemp /tmp/storage-from-CVS.xml.XXXX`
Stefano Belforte's avatar
Stefano Belforte committed
274
echo "Fetch CVS copy of TFC from $cvsUrl<br>"
Stefano Belforte's avatar
Stefano Belforte committed
275
276
277
278
279
280
281
282
283
284
285
286
287
288
./fetch-from-web $cvsUrl $TfcFileFromCVS
rc=$?
echo "rc = $rc <br>"
[ $rc == $SAME_INFO ] && info=1
[ $rc == $SAME_WARNING ] && warning=1

#if [ $rc == $SAME_WARNING ] || [ $rc == $SAME_ERROR ] ; then
#  echo "<br>INFO: failed to access CVS Web repository<bre>"
#else
if [ $rc == $SAME_OK ] || [ $rc == $SAME_INFO ] ; then
  diff -q -w -B $TFCfile $TfcFileFromCVS
  if [ $? == 1 ] ; then asCvs=0; fi
  echo "<br>"
  if [ $asCvs == 0 ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
289
290
291
292
293
294
295
    if [ $localTFCfileAgeInHours -gt 72 ] then
      error=1
      echo "<strong>ERROR: local Trivial Catalog File file differ from CVS</strong>"
    else
      echo "<strong>WARNING: local Trivial Catalog File differ from CVS</strong>"
      echo "<br>will become error if this difference lasts more then 72h"
    fi
Stefano Belforte's avatar
Stefano Belforte committed
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
    diffList=`mktemp /tmp/diflist.XXXX`
    diff $TFCfile $TfcFileFromCVS > $diffList
    echo "<pre>"
    cat $diffList | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
    echo "</pre>"
    rm -f $diffList
  else
    echo "OK local Trivial File Catalog file agrees with CVS copy"
    echo "<br>"
  fi
  rm -f $TfcFileFromCVS
else
  echo "<br>INFO: failed to access CVS Web repository<bre>"
  info=1
fi

echo "<p>dump of TFC file is <a href=\"#TFCDump\">here</a>"


echo "<p>"


echo "<h2>Verify presence of commands needed for remote stageout</h2>"
echo "Needs at least ( lcg_utils 1.6.7 and gfal 1.10.8 ) or ( srmcp 2.0 ) " 

echo "<p>"
322
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
stageOutError=1

which lcg-cp
rc=$?
if [ $rc == 0 ] ; then
  lcg-cp --version
  lcgVersion=`lcg-cp --version|grep "lcg_util"|cut -d'-' -f2`
  gfalVersion=`lcg-cp --version|grep GFAL|cut -d'-' -f3`
  lcgV1=`echo $lcgVersion|cut -d. -f1`
  lcgV2=`echo $lcgVersion|cut -d. -f2`
  lcgV3=`echo $lcgVersion|cut -d. -f3`
  gfalV1=`echo $gfalVersion|cut -d. -f1`
  gfalV2=`echo $gfalVersion|cut -d. -f2`
  gfalV3=`echo $gfalVersion|cut -d. -f3`
  lcgOK=0
  if [ $lcgV1 -gt 1 ] ; then
    lcgOK=1
  else
    if [ $lcgV1 -eq 1 ] && [ $lcgV2 -gt 6 ] ; then
      lcgOK=1
    else
      if [ $lcgV2 -eq 6 ] && [ $lcgV3 -ge 7 ] ; then
	lcgOK=1
      fi
    fi
  fi
  gfalOK=0
  if [ $gfalV1 -gt 1 ] ; then
    gfalOK=1
  else
    if [ $gfalV1 -eq 1 ] && [ $gfalV2 -gt 10 ] ; then
      gfalOK=1
    else
      if [ $gfalV2 -eq 10 ] && [ $gfalV3 -ge 8 ] ; then
	 gfalOK=1
      fi
    fi
  fi

  if [ $lcgOK == 1 ] ; then
      if [ $gfalOK == 1 ] ; then
	  stageOutError=0
      fi
  fi
fi

echo "</pre><p><pre>"

which srmcp
rc=$?

if [ $rc == 0 ] ; then
  srmcp -version | grep -v WARNING
  srmcpVersion=`srmcp -version 2>&1|egrep "Client version"|awk '{print $(NF)'}`
  srmcpV1=`echo $srmcpVersion|cut -d. -f1`
  srmcpV2=`echo $srmcpVersion|cut -d. -f2`
#  srmcpV3=`echo $srmcpVersion|cut -d. -f3`
  if [ $srmcpV1 -ge 2 ] ; then
      stageOutError=0
  fi
fi


echo "</pre>"
if [ $stageOutError == 1  ] ; then
    echo "ERROR: No validated command for remote stageout available"
    error=1
else
    echo "OK"
fi
echo "<p>"




echo "<p>"
echo "<hr>"
echo "<p>"


echo "<h2>Dump of local configuration files</h2><br>"

echo "<h3><a name="CfgDump"></a>Configuration File Dump</h3><pre>"
cat $ConfigFile  | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
Stefano Belforte's avatar
Stefano Belforte committed
407
408
echo "</pre>"

Stefano Belforte's avatar
Stefano Belforte committed
409
410
411
echo "<h3><a name="TFCDump"></a>TFC file Dump</h3><pre>"
cat $TFCfile  | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
echo "</pre>"
Stefano Belforte's avatar
Stefano Belforte committed
412

Stefano Belforte's avatar
Stefano Belforte committed
413
414
415
416
417
418
419
echo '<h1><a name="summary"> Test Summary</a></h1><p>'


if [ $error == 1 ]
then
  echo "<p><strong> ERROR </strong></p>"
  exit $SAME_ERROR
420
421
fi

Stefano Belforte's avatar
Stefano Belforte committed
422
423
424
425
426
427
428
429
430
431
if [ $warning == 1 ]
then
  echo "<p><strong> WARNING </strong></p>"
  exit $SAME_WARNING
fi

if [ $note == 1 ]
then
  echo "<p><strong> NOTE </strong></p>"
  exit $SAME_NOTE
432
433
fi

Stefano Belforte's avatar
Stefano Belforte committed
434
435
436
437
if [ $info == 1 ]
then
  echo "<p><strong> INFO </strong></p>"
  exit $SAME_INFO
Stefano Belforte's avatar
Stefano Belforte committed
438
fi
439

440

Stefano Belforte's avatar
Stefano Belforte committed
441
echo "<p><strong> OK </strong></p>"
Stefano Belforte's avatar
Stefano Belforte committed
442
exit $SAME_OK