Public Member Functions | |
def | __init__ |
def | activeThreads |
def | prepare |
def | runTests |
def | upload |
Public Attributes | |
maxThreads | |
threadList |
Definition at line 75 of file addOnTests.py.
def addOnTests::StandardTester::__init__ | ( | self, | |
nThrMax = 4 |
|||
) |
Definition at line 77 of file addOnTests.py.
def addOnTests::StandardTester::activeThreads | ( | self | ) |
Definition at line 84 of file addOnTests.py.
def addOnTests::StandardTester::prepare | ( | self | ) |
Definition at line 92 of file addOnTests.py.
00093 : 00094 00095 cmd = 'ln -s /afs/cern.ch/user/a/andreasp/public/IBTests/read*.py .' 00096 try: 00097 os.system(cmd) 00098 except: 00099 pass 00100 00101 00102 tstPkgs = { 'FastSimulation' : [ 'Configuration' ], 00103 'HLTrigger' : [ 'Configuration' ], 00104 'PhysicsTools' : [ 'PatAlgos' ], 00105 } 00106 00107 #-ap: make sure the actual package is there, not just the subsystem ... 00108 # and set symlinks accordingly ... 00109 pkgPath = os.environ['CMSSW_BASE'] + '/src/' 00110 relPath = '$CMSSW_RELEASE_BASE/src/' 00111 cmd = '' 00112 for tstSys in tstPkgs: 00113 if not os.path.exists(pkgPath + tstSys): 00114 cmd = 'ln -s ' + relPath + tstSys + ' .;' 00115 try: 00116 print 'setting up symlink for ' + tstSys + ' using ' + cmd 00117 os.system(cmd) 00118 except: 00119 pass 00120 else: 00121 for tstPkg in tstPkgs[tstSys]: 00122 if not os.path.exists(pkgPath + tstSys + "/" + tstPkg): 00123 cmd = 'mkdir -p ' + tstSys + '; ln -s ' + relPath + tstSys + '/' + tstPkg + ' ' + tstSys +';' 00124 else: 00125 cmd = 'mkdir -p ' + tstSys + '; ln -s ' + pkgPath + tstSys + '/' + tstPkg + ' ' + tstSys +';' 00126 try: 00127 print 'setting up symlink for ' + tstSys + '/' + tstPkg + ' using ' + cmd 00128 os.system(cmd) 00129 except: 00130 pass 00131 00132 return 00133
def addOnTests::StandardTester::runTests | ( | self | ) |
Definition at line 134 of file addOnTests.py.
00135 : 00136 00137 # make sure we have a way to set the environment in the threads ... 00138 if not os.environ.has_key('CMS_PATH'): 00139 cmsPath = '/afs/cern.ch/cms' 00140 print "setting default for CMS_PATH to", cmsPath 00141 os.environ['CMS_PATH'] = cmsPath 00142 00143 lines = { 'read312RV' : ['cmsRun ../read312RV_cfg.py'], 00144 'fastsim1' : ['cmsRun ../FastSimulation/Configuration/test/IntegrationTestFake_cfg.py'], 00145 'fastsim2' : ['cmsRun ../FastSimulation/Configuration/test/IntegrationTest_cfg.py'], 00146 #'fastsim3' : ['cmsRun ../FastSimulation/Configuration/test/ExampleWithHLT_1E31_cfg.py'], 00147 'fastsim4' : ['cmsRun ../FastSimulation/Configuration/test/IntegrationTestWithHLT_cfg.py'], 00148 'pat1' : ['cmsRun ../PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py'], 00149 } 00150 00151 hltTests = { 'hlt1' : ['cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW -n 10 --conditions auto:startup --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_DigiL1Raw_GRun.root', 00152 'cmsRun ../HLTrigger/Configuration/test/OnLine_HLT_GRun.py' ], 00153 'hlt2' : ['cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW -n 10 --conditions auto:starthi --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_DigiL1Raw_HIon.root', 00154 'cmsRun ../HLTrigger/Configuration/test/OnLine_HLT_HIon.py'], 00155 'hlt3' : ['cmsRun ../HLTrigger/Configuration/test/OnData_HLT_GRun.py'], 00156 'hlt4' : ['cmsRun ../HLTrigger/Configuration/test/OnData_HLT_HIon.py'], 00157 } 00158 00159 commands={} 00160 00161 actDir = os.getcwd() 00162 00163 if not os.path.exists('addOnTests'): 00164 os.makedirs('addOnTests') 00165 os.chdir('addOnTests') 00166 00167 self.prepare() 00168 00169 for dirName, command in lines.items(): 00170 commands[dirName] = command 00171 # print 'Will do: '+command 00172 00173 for dirName, commandList in hltTests.items(): 00174 cmds = commandList 00175 commands[dirName] = cmds 00176 00177 nfail=0 00178 npass=0 00179 report='' 00180 00181 print 'Running in %s thread(s)' % self.maxThreads 00182 00183 for dirName, command in commands.items(): 00184 00185 # make sure we don't run more than the allowed number of threads: 00186 while self.activeThreads() >= self.maxThreads: 00187 time.sleep(10) 00188 continue 00189 00190 print 'Preparing to run %s' % str(command) 00191 current = testit(dirName, command) 00192 self.threadList.append(current) 00193 current.start() 00194 time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec 00195 00196 # wait until all threads are finished 00197 while self.activeThreads() > 0: 00198 time.sleep(5) 00199 00200 # all threads are done now, check status ... 00201 for pingle in self.threadList: 00202 pingle.join() 00203 for f in pingle.nfail: nfail += f 00204 for p in pingle.npass: npass += p 00205 report += pingle.report 00206 print pingle.report 00207 sys.stdout.flush() 00208 00209 reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail) 00210 print reportSumm 00211 00212 runall_report_name='runall-report.log' 00213 runall_report=open(runall_report_name,'w') 00214 runall_report.write(report+reportSumm) 00215 runall_report.close() 00216 00217 # get the logs to the logs dir: 00218 print '==> in :', os.getcwd() 00219 print ' going to copy log files to logs dir ...' 00220 if not os.path.exists('logs'): 00221 os.makedirs('logs') 00222 for dirName in commands.keys(): 00223 cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done" 00224 print "going to ",cmd 00225 os.system(cmd) 00226 00227 import pickle 00228 pickle.dump(commands, open('logs/addOnTests.pkl', 'w') ) 00229 00230 os.chdir(actDir) 00231 00232 return
def addOnTests::StandardTester::upload | ( | self, | |
tgtDir | |||
) |
Definition at line 233 of file addOnTests.py.
00234 : 00235 00236 print "in ", os.getcwd() 00237 00238 # wait until all threads are finished 00239 while self.activeThreads() > 0: 00240 time.sleep(5) 00241 00242 if not os.path.exists(tgtDir): 00243 os.makedirs(tgtDir) 00244 00245 cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) ' 00246 try: 00247 print 'executing: ',cmd 00248 ret = os.system(cmd) 00249 if ret != 0: 00250 print "ERROR uploading logs:", ret, cmd 00251 except Exception, e: 00252 print "EXCEPTION while uploading addOnTest-logs : ", str(e) 00253 00254 return 00255
Definition at line 77 of file addOnTests.py.
Definition at line 77 of file addOnTests.py.