CE-cms-mc 2.92 KB
Newer Older
Andrea Sciaba's avatar
Andrea Sciaba committed
1
2
3
4
#!/bin/bash

echo "<h2>Stage out test for the Monte Carlo production</h2>"

Andrea Sciaba's avatar
Andrea Sciaba committed
5
6
echo "<h3>Preliminary checks</h3>"
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
7
8
9
set -x
uname -a
date
Andrea Sciaba's avatar
Andrea Sciaba committed
10
id
Andrea Sciaba's avatar
Andrea Sciaba committed
11
#env | grep -v '^NAGIOS'
Stefano Belforte's avatar
Stefano Belforte committed
12
set +x
Andrea Sciaba's avatar
Andrea Sciaba committed
13
echo "</pre>"
Stefano Belforte's avatar
Stefano Belforte committed
14

Andrea Sciaba's avatar
Andrea Sciaba committed
15
16
# Source the CMS environment
echo "<h3>Sourcing the CMS environment</h3>"
Andrea Sciaba's avatar
Andrea Sciaba committed
17
export SCRAM_ARCH=slc5_amd64_gcc462
18
if [ -n "$OSG_APP" ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
19
    echo "<p>This is an OSG site</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
20
    SW_DIR=$OSG_APP/cmssoft/cms
21
22
    source $OSG_GRID/setup.sh
    result=$?
23
elif [ -n "$VO_CMS_SW_DIR" ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
24
    echo "<p>This is an LCG site</p>"
25
26
    SW_DIR=$VO_CMS_SW_DIR
    result=$?
Andrea Sciaba's avatar
Andrea Sciaba committed
27
else
Andrea Sciaba's avatar
Andrea Sciaba committed
28
    echo "<p>ERROR: neither VO_CMS_SW_DIR nor OSG_APP defined</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
29
30
31
32
    exit $SAME_ERROR
fi
echo "<pre>"
source $SW_DIR/cmsset_default.sh
33
result=$(expr $? + $result)
Andrea Sciaba's avatar
Andrea Sciaba committed
34
35
36
echo "</pre>"
if [ $result != 0 ]
    then
Andrea Sciaba's avatar
Andrea Sciaba committed
37
    echo "<p>ERROR: $VO_CMS_SW_DIR/cmsset_default.sh non existent or non readable</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
38
39
40
    exit $SAME_ERROR
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
echo "WMAgent thinks it found the correct CMSSW setup script"

if [ -e $VO_CMS_SW_DIR/COMP/slc5_amd64_gcc434/external/python/2.6.4/etc/profile.d/init.sh ]
then
    . $VO_CMS_SW_DIR/COMP/slc5_amd64_gcc434/external/python/2.6.4/etc/profile.d/init.sh 
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VO_CMS_SW_DIR/COMP/slc5_amd64_gcc434/external/openssl/0.9.7m/lib:$VO_CMS_SW_DIR/COMP/slc5_amd64_gcc434/external/bz2lib/1.0.5/lib
elif [ -e $OSG_APP/cmssoft/cms/COMP/slc5_amd64_gcc434/external/python/2.6.4/etc/profile.d/init.sh ]
then
    . $OSG_APP/cmssoft/cms/COMP/slc5_amd64_gcc434/external/python/2.6.4/etc/profile.d/init.sh
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OSG_APP/cmssoft/cms/COMP/slc5_amd64_gcc434/external/openssl/0.9.7m/lib:$OSG_APP/cmssoft/cms/COMP/slc5_amd64_gcc434/external/bz2lib/1.0.5/lib
fi
command -v python2.6 > /dev/null
rc=$?
if [[ $rc != 0 ]]
then
    echo "WMAgent Error: Python2.6 isn't available on this worker node." >&2
    echo "WMAgent Error: WMCore/WMAgent REQUIRES python2.6" >&2
    exit 3   
else
    echo "WMAgent found python2.6 at.."
    echo `which python2.6`
fi

export PYTHONPATH=$SAME_SENSOR_HOME/cms-MC-test/lib/python2.6/site-packages:$PYTHONPATH
Andrea Sciaba's avatar
Andrea Sciaba committed
65
66
67
68
69
70
71

echo "<h3>Checking PYTHONPATH</h3>"
echo "<pre>"
echo "PYTHONPATH=$PYTHONPATH"
echo "</pre>"
echo "<h3>Invoking site test</h3>"
echo "<pre>"
72
echo "USER/WHOAMI?:" $USER/`whoami`
Andrea Sciaba's avatar
Andrea Sciaba committed
73
echo "USER ID:" $UID
74
voms-proxy-info -all
Andrea Sciaba's avatar
Andrea Sciaba committed
75
echo "</pre>"
Andrea Sciaba's avatar
Andrea Sciaba committed
76
77
78

cd $SAME_SENSOR_HOME/cms-MC-test/
if [ $? -ne 0 ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
79
   echo "<p>ERROR: Could not access the cms-MC-test directory</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
80
81
   exit $SAME_ERROR
else
Andrea Sciaba's avatar
Andrea Sciaba committed
82
  echo "<pre>"
Andrea Sciaba's avatar
Andrea Sciaba committed
83
  chmod u+x RuntimeSAMStageOut.py 
Andrea Sciaba's avatar
Andrea Sciaba committed
84
  ./RuntimeSAMStageOut.py | sed -e 's/&/&amp;/g' | sed -e 's/</\&lt;/g' | sed -e 's/>/\&gt;/g' 2>&1
Andrea Sciaba's avatar
Andrea Sciaba committed
85
86
  EXIT_STATUS=$?
fi
Andrea Sciaba's avatar
Andrea Sciaba committed
87
88
echo "</pre>"

89
if [ $EXIT_STATUS -ne 0 -a $EXIT_STATUS -ne 4 ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
90
   echo "<p>ERROR: Stage Out Test failed: $EXIT_STATUS</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
91
   exit $SAME_ERROR
92
elif [ $EXIT_STATUS -eq 4 ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
93
   echo "<p>WARNING: Stage Out Test failed to cleanup the test file: $EXIT_STATUS</p>"
94
   exit $SAME_WARNING 
Andrea Sciaba's avatar
Andrea Sciaba committed
95
else
Andrea Sciaba's avatar
Andrea Sciaba committed
96
   echo "<p>Stage Out Test successful</p>"
Andrea Sciaba's avatar
Andrea Sciaba committed
97
98
   exit $SAME_OK
fi