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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/ksh
############################## standard interface to /sw tools
# Input:
# Environment variables
# SW_BLDDIR current directory (PWD) minus /autofs/na1_ stuff
# SW_ENVFILE file to be sourced which has alternate prog environment
# only to be used in special circumstances
# SW_WORKDIR work dir that local script can use
# Output:
# Return code of 0=success or 1=failure or 2=job submitted
#
# Notes:
# If this script is called from swtest, then swtest requires
# SW_WORKDIR to be set. Then swtest adds a unique path to what
# user gave swtest (action+timestamp+build) and provides this
# script with a uniquely valued SW_WORKDIR. swtest will
# automatically remove this unique workspace when retest is done.
##################################################################
# exit 3 is a signal to the sw infrastructure that this template has not
# been updated; please delete it when ready
if [ -z $SW_BLDDIR ]; then
echo "Error: SW_BLDDIR not set!"
exit 1
else
cd $SW_BLDDIR
fi
if [ -z $SW_ENVFILE ]; then
### Set Environment (do not remove this line only change what is in between)
. ${MODULESHOME}/init/ksh
. ${SW_BLDDIR}/remodule
### End Environment (do not remove this line only change what is in between)
else
. $SW_ENVFILE
fi
############################## app specific section
#
set -o verbose
#clear out status file since re-testing
rm -f status
cd $SW_WORKDIR
#-- Four things are required in the PBS script such that it can be followed
# correctly by jenkins:
# 1. The PBS_JOBID (given upon submission with 'qsub') needs to be written
# to the ${SW_BLDDIR}/.running file on submission
# 2. The main output of the test (i.e. typically "aprun" command output)
# needs to be appended to ${SW_BLDDIR}/.running as the test runs
# 3. If the test succeed, the first line of $SW_BLDDIR/status file must be
# the string "verified"
# 4. ${SW_BLDDIR}/.running must be removed after the test completes
cat > ${PACKAGE}.pbs << EOF
#!/bin/bash
#PBS -N ${PACKAGE}
#PBS -j oe
#PBS -l nodes=1:ppn=32,walltime=30:00
set -o verbose
cd \$PBS_O_WORKDIR
TIME="/usr/bin/time -f 'elapsed %e'"
UPTIME=/usr/bin/uptime
#-- Wrapped aprun and Real aprun:
W_APRUN=`which aprun`
R_APRUN=/usr/bin/aprun
#-- Test with XALT's aprun wrapper
echo "W_APRUN: \$W_APRUN" | tee -a ${SW_BLDDIR}/.running
eval \$TIME \$W_APRUN -n 1 \$UPTIME 2>&1 | tee w_aprun.log | tee -a ${SW_BLDDIR}/.running
#-- Test with real aprun
echo "R_APRUN: \$R_APRUN" | tee -a ${SW_BLDDIR}/.running
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
eval \$TIME \$R_APRUN -n 1 \$UPTIME 2>&1 | tee r_aprun.log | tee -a ${SW_BLDDIR}/.running
echo "verified" > ${SW_BLDDIR}/status
grep elapsed w_aprun.log | grep -v time | awk '{print "YVALUE=",\$2}' \
| sed 's/ //g' > ${SW_BLDDIR}/w_aprun
grep elapsed r_aprun.log | grep -v time | awk '{print "YVALUE=",\$2}' \
| sed 's/ //g' > ${SW_BLDDIR}/r_aprun
JOBID=\`echo \$PBS_JOBID | cut -d "." -f1 \`
chmod 775 ${SW_BLDDIR}/status
rm ${SW_BLDDIR}/.running
cat \${JOBID}.OU >> ${SW_BLDDIR}/test.log
cat ${PACKAGE}.log >> ${SW_BLDDIR}/test.log
chmod 664 ${SW_BLDDIR}/test.log
EOF
#submit job and touch .running file - marker to infrastructure that
qsub ${PACKAGE}.pbs > ${SW_BLDDIR}/.running
# qsub returns 0 on successful job launch, so if failure return 1
if [ $? -ne 0 ]; then
echo "Error submitting job"
rm -f .running
exit 1
else
echo "Job submitted"
cat ${SW_BLDDIR}/.running
exit 2
fi
cd ../
cd ../../
############################### if this far, return 0
exit 0