8 from xml.dom.minidom
import parse, parseString
9 import CondCore.RegressionTest.common_db
as common_db
10 import CondCore.RegressionTest.results_db
as results_db
11 import CondCore.RegressionTest.reference_db
as reference_db
18 xml = dom.getElementsByTagName(
"xml")
22 testData = xm.getElementsByTagName(
"test")
25 if "name" in it.attributes.keys():
26 tLabel = str(it.attributes[
"name"].value)
29 if foundLabel ==
True:
30 inits = it.getElementsByTagName(
"init")
31 finals = it.getElementsByTagName(
"final")
32 seqs = it.getElementsByTagName(
"sequence")
34 commands = init.getElementsByTagName(
"command")
35 for command
in commands:
38 if "exec" in command.attributes.keys():
39 commPars0 = str(command.attributes[
"exec"].value)
40 if "env" in command.attributes.keys():
41 commPars1 = str(command.attributes[
"env"].value)
42 initSeq.append((commPars0,commPars1))
44 commands = seq.getElementsByTagName(
"command")
45 for command
in commands:
49 if "exec" in command.attributes.keys():
50 commPars0 = str(command.attributes[
"exec"].value)
51 if "result" in command.attributes.keys():
52 commPars2 = str(command.attributes[
"result"].value)
53 if "env" in command.attributes.keys():
54 commPars1 = str(command.attributes[
"env"].value)
55 mainSeq.append( (commPars0,commPars1,commPars2) )
57 commands = final.getElementsByTagName(
"command")
58 for command
in commands:
61 if "exec" in command.attributes.keys():
62 commPars0 = str(command.attributes[
"exec"].value)
63 if "env" in command.attributes.keys():
64 commPars1 = str(command.attributes[
"env"].value)
65 finalSeq.append( (commPars0,commPars1) )
67 return initSeq,mainSeq,finalSeq
72 srcPath = os.path.join(path, release,
"src")
74 if [ $RETVAL = 0 ]; then
75 echo "Setting environment variables for """+release+
""" """+arch+
""" "
76 echo "path : """+path+
""""
77 eval pushd """+srcPath+
"""
79 if [ $RETVAL = 0 ]; then
80 export SCRAM_ARCH="""+arch+
"""
82 if [ $RETVAL = 0 ]; then
83 eval `scram runtime -sh`
85 if [ $RETVAL = 0 ]; then
86 export TNS_ADMIN=/afs/cern.ch/project/oracle/admin
88 if [ $RETVAL = 0 ]; then
94 TRELEASE="""+release+
"""
97 TMAPNAME="""+release+
"""_"""+arch+
"""
98 TMAINDB="""+CONNECTION_STRING+
"""
99 TAUXDB="""+
"oracle://cms_orcoff_prep/CMS_COND_WEB"+
"""
100 TUSERNAME="""+USERNAME+
"""
101 TPASSWORD="""+PASSWORD+
"""
102 TTEST=$LOCALRT/test/$TARCH
103 TBIN=$LOCALRT/bin/$TARCH
104 TAUTH="""+AUTH_PATH+
"""
105 TSEED="""+str(random.randrange(1, 10))+
"""
106 echo "Environment variables set successfully"
108 echo "Setting environment failed on """+release+
""" """+arch+
""" return code : $RETVAL"
111 echo "----------------------------------------------"
117 if [ $RETVAL = 0 ]; then
118 echo "Executing Command """+runStr+
""" "
119 echo "with $TRELEASE $TARCH :"
122 if [ $RETVAL != 0 ]; then
123 echo "Task failed on $TRELEASE $TARCH return code : $RETVAL"
125 echo "Task performed successfully"
131 def RunTest(label,testSeq, release, arch, path, refRelease, refArch, refPath ):
134 echo "*****************************************************************************************"
135 echo "Reference release: """+refRelease+
""" "
136 echo "Arch: """+refArch+
""" "
137 echo "Path: """+refPath+
""" "
138 echo "*****************************************************************************************"
145 finalSeq = testSeq[2]
148 echo "==============================================="
151 if step[1] ==
"cand" and currEnv != 1:
152 cmds +=
SetEnv(release,arch,path)
154 elif step[1] ==
"ref" and currEnv != 2:
155 cmds +=
SetEnv(refRelease, refArch,refPath)
158 print "-> test sequence"
161 echo "==============================================="
164 if step[1] ==
"cand" and currEnv != 1:
165 cmds +=
SetEnv(release,arch,path)
167 elif step[1] ==
"ref" and currEnv != 2:
168 cmds +=
SetEnv(refRelease, refArch,refPath)
171 cmds +=
'RCODE['+str(nr)+
']=$RETVAL'
177 for step
in finalSeq:
179 echo "==============================================="
182 if step[1] ==
"cand" and currEnv != 1:
183 cmds +=
SetEnv(release,arch,path)
185 elif step[1] ==
"ref" and currEnv != 2:
186 cmds +=
SetEnv(refRelease, refArch,refPath)
190 echo "==============================================="
191 echo "Script return code : ${RCODE[1]}"
192 echo "!L!"""+label+
"""!TR!"""+release+
"""!TA!"""+arch+
"""!RR!"""+refRelease+
"""!RA!"""+refArch
193 for i
in range (0, nr):
194 cmds+=
"!C"+str(i)+
"!${RCODE["+str(i)+
"]}"
203 echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" """
204 pipe = subprocess.Popen(cmdList, shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
205 stdout_value = pipe.communicate()[0]
216 self.out_value =
None
218 def runOnDb(self, label, release, arch, path):
220 print 'Running test "'+label+
'" on rel='+release+
' arch='+arch+
' from path= '+path
223 echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
224 echo "Candidate release: """+release+
""" "
225 echo "Arch: """+arch+
""" "
226 echo "Path: """+path+
""" "
227 echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
230 self.n_res = len(testSeq[1])
232 print "Error : no test sequence found for label %s"%label
235 for step
in testSeq[1]:
236 self.resTags.append( step[2] )
237 releases = self.refDb.listReleases( relID )
239 cmd =
RunTest( label,testSeq, release, arch, path, rel[0], rel[1], rel[2])
245 def runOnReference(self, label, release, arch, path, refRelease, refArch, refPath):
247 print "Testing "+release+
" "+arch+
" from path: "+path
251 echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
252 echo "Candidate release: """+release+
""" "
253 echo "Arch: """+arch+
""" "
254 echo "Path: """+path+
""" "
255 echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
257 testSeq =
ParseXML(
"sequences.xml", label)
258 self.n_res = len( testSeq[1] )
260 print "Error : no test sequence found for label %s"%label
263 for step
in testSeq[1]:
264 self.resTags.append( step[2] )
265 cmd =
RunTest(label,testSeq, release, arch, path, refRelease, refArch, refPath)
273 reStr =
"\!L\!([^!]+)\!TR\!([^!]+)\!TA\!([^!]+)\!RR\!([^!]+)\!RA\!([^!]+)"
274 for i
in range (0, self.n_res):
275 reStr +=
"\!C"+str(i)+
"\!(\d+)"
278 pattern = re.compile(reStr)
279 matching = pattern.findall(self.out_value)
280 stdoutMod = pattern.sub(
"", self.out_value)
281 timeStamp = self.resDb.getDate()
285 runID = self.resDb.getNewRunId()
286 for match
in matching:
289 self.resDb.writeResult(runID, timeStamp, match,self.resTags)
290 for i
in range(5, len(match)):
291 if( match[i] != str(0) ):
295 self.resDb.addResultLog(runID, stdoutMod)
296 print "Test '%s' runID=%d" %(self.label, runID)
297 print "Exit status=%s" %stat
298 print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
301 print "Command line arguments :"
302 print "-F (--full) -t [test_label] -r [release] -a [arch] -p [path]: runs the full test. "
303 print "-S (--self) -t [test_label] -r [release] -a [arch] -p [path]: runs the self test. "
304 print "-R [ref_release] -A [ref_arch] -P [ref_path] -t [test_label] -r [release] -a [arch] -p [path]: runs the test against the specified ref release. "
305 print " optional flag -w: write the test result in the database. "
308 if(os.path.exists(path)):
309 if(os.path.exists(os.path.join(path, release))):
310 if(os.path.exists(os.path.join(path, release,
"test", arch))):
313 print "Architecture not found"
316 print "Release not found"
319 print "Path not found"
323 opts, args = getopt.getopt(sys.argv[1:],
"FSR:A:P:t:r:a:p:hw", [
'full',
'self',
'help'])
324 except getopt.GetoptError, err:
340 if o
in (
"-F",
"--full"):
342 elif o
in (
"-S",
"--self"):
360 elif o
in (
"-h",
"--help"):
364 assert False,
"unhandled option"
365 if( fflag ==
False and sflag ==
False and REF_RELEASE ==
None ):
366 print "Error: missing main run option."
369 if ( LABEL ==
None ):
371 print "Error: missing -l (label) parameter"
372 if(RELEASE ==
None ):
374 print "Error: missing -r (release) parameter"
377 print "Error: missing -a (architecture) parameter"
380 print "Error: missing -p (path) parameter"
383 print "Error: bad path specified for the release"
389 if( fflag ==
True and done==
False ):
390 ret = test.runOnDb(LABEL, RELEASE, ARCH, PATH)
392 if( sflag ==
True and done==
False ):
393 ret = test.runOnReference(LABEL, RELEASE, ARCH, PATH, RELEASE, ARCH, PATH)
395 if( REF_RELEASE !=
None and done==
False ):
396 if( REF_ARCH ==
None ):
398 print "Error: missing -A (ref architecture) parameter"
399 if( REF_PATH ==
None):
401 print "Error: missing -P (ref path) parameter"
402 if(
CheckPath(REF_RELEASE, REF_ARCH, REF_PATH) ==
False):
404 print "Error: bad path specified for the ref release"
406 ret = test.runOnReference(LABEL, RELEASE, ARCH, PATH, REF_RELEASE, REF_ARCH, REF_PATH)
408 if ( done ==
True and ret>0 ):
409 test.finalize( wflag )
Evaluator * parse(const T &text)
def getDBConnectionParams
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)