CMS 3D CMS Logo

Public Member Functions | Public Attributes

addOnTests::StandardTester Class Reference

List of all members.

Public Member Functions

def __init__
def activeThreads
def dumpTest
def file2Path
def prepare
def runTests
def upload

Public Attributes

 commands
 devPath
 maxThreads
 relPath
 threadList

Detailed Description

Definition at line 64 of file addOnTests.py.


Constructor & Destructor Documentation

def addOnTests::StandardTester::__init__ (   self,
  nThrMax = 4 
)

Definition at line 66 of file addOnTests.py.

00067                                  :
00068 
00069         self.threadList = []
00070         self.maxThreads = nThrMax
00071         self.prepare()
00072 
00073         return


Member Function Documentation

def addOnTests::StandardTester::activeThreads (   self)

Definition at line 74 of file addOnTests.py.

00075                            :
00076 
00077         nActive = 0
00078         for t in self.threadList:
00079             if t.isAlive() : nActive += 1
00080 
00081         return nActive

def addOnTests::StandardTester::dumpTest (   self)

Definition at line 124 of file addOnTests.py.

00125                       :
00126         print ",".join(self.commands.keys())
00127         return

def addOnTests::StandardTester::file2Path (   self,
  rFile 
)

Definition at line 128 of file addOnTests.py.

00129                              :
00130 
00131         fullPath = self.relPath + rFile
00132         if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
00133         return fullPath

def addOnTests::StandardTester::prepare (   self)

Definition at line 82 of file addOnTests.py.

00083                      :
00084     
00085         self.devPath = os.environ['LOCALRT'] + '/src/'
00086         self.relPath = self.devPath
00087         if os.environ.has_key('CMSSW_RELEASE_BASE') and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
00088 
00089         lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')], 
00090                   'fastsim1'  : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTestFake_cfg.py')],
00091                   'fastsim2'  : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTest_cfg.py')],
00092                   #'fastsim3'  : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/ExampleWithHLT_1E31_cfg.py')],
00093                   'fastsim4'  : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTestWithHLT_cfg.py')],
00094                   'pat1'      : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
00095                 }
00096 
00097         hltTests = { 'hlt1' : ['cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:startup --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_Raw_GRun_STARTUP.root',
00098                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_GRun.py'), 
00099                                'cmsDriver.py RelVal -s HLT:GRun,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:startup_GRun --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_GRun_STARTUP.root --fileout file:RelVal_Raw_GRun_STARTUP_HLT_RECO.root'], 
00100                      'hlt2' : ['cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=HeavyIons -n 10 --conditions auto:starthi --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_Raw_HIon_STARTUP.root',
00101                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py'),
00102                                'cmsDriver.py RelVal -s HLT:HIon,RAW2DIGI,L1Reco,RECO --mc --scenario=HeavyIons -n 10 --conditions auto:starthi_HIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_HIon_STARTUP.root --fileout file:RelVal_Raw_HIon_STARTUP_HLT_RECO.root'],
00103                      'hlt3' : ['cmsDriver.py RelVal -s L1REPACK --data --scenario=pp -n 10 --conditions auto:startup --relval 9000,50 --datatier "RAW" --eventcontent RAW --fileout file:RelVal_Raw_GRun_DATA.root --filein /store/data/Run2012A/MuEG/RAW/v1/000/191/718/14932935-E289-E111-830C-5404A6388697.root',
00104                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_GRun.py'),
00105                                'cmsDriver.py RelVal -s HLT:GRun,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:hltonline_GRun --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_GRun_DATA.root --fileout file:RelVal_Raw_GRun_DATA_HLT_RECO.root'],
00106                      'hlt4' : ['cmsDriver.py RelVal -s L1REPACK --data --scenario=HeavyIons -n 10 --conditions auto:starthi --relval 9000,50 --datatier "RAW" --eventcontent RAW --fileout file:RelVal_Raw_HIon_DATA.root --filein /store/hidata/HIRun2011/HIHighPt/RAW/v1/000/182/838/F20AAF66-F71C-E111-9704-BCAEC532971D.root',
00107                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_HIon.py'),
00108                                'cmsDriver.py RelVal -s HLT:HIon,RAW2DIGI,L1Reco,RECO --data --scenario=HeavyIons -n 10 --conditions auto:hltonline_HIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_HIon_DATA.root --fileout file:RelVal_Raw_HIon_DATA_HLT_RECO.root'],
00109                      'hlt5' : ['cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:startup --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_Raw_PIon_STARTUP.root', 
00110                                'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PIon.py'),
00111                                'cmsDriver.py RelVal -s HLT:PIon,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:startup_PIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_PIon_STARTUP.root --fileout file:RelVal_Raw_PIon_STARTUP_HLT_RECO.root'],
00112                      'hlt6' : ['cmsDriver.py RelVal -s L1REPACK --data --scenario=pp -n 10 --conditions auto:startup --relval 9000,50 --datatier "RAW" --eventcontent RAW --fileout file:RelVal_Raw_PIon_DATA.root --filein /store/data/Run2012A/MuEG/RAW/v1/000/191/718/14932935-E289-E111-830C-5404A6388697.root',
00113                                'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnData_HLT_PIon.py'),
00114                                'cmsDriver.py RelVal -s HLT:PIon,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:hltonline_PIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_PIon_DATA.root --fileout file:RelVal_Raw_PIon_DATA_HLT_RECO.root'],
00115                      }
00116 
00117         self.commands={}
00118         for dirName, command in lines.items():
00119             self.commands[dirName] = command
00120 
00121         for dirName, commandList in hltTests.items():
00122             self.commands[dirName] = commandList
00123         return
        
def addOnTests::StandardTester::runTests (   self,
  testList = None 
)

Definition at line 134 of file addOnTests.py.

00135                                        :
00136 
00137         actDir = os.getcwd()
00138 
00139         if not os.path.exists('addOnTests'):
00140             os.makedirs('addOnTests')
00141         os.chdir('addOnTests')
00142 
00143         nfail=0
00144         npass=0
00145         report=''
00146         
00147         print 'Running in %s thread(s)' % self.maxThreads
00148         
00149         for dirName, command in self.commands.items():
00150 
00151             if testList and not dirName in testList:
00152                 del self.commands[dirName]
00153                 continue
00154 
00155             # make sure we don't run more than the allowed number of threads:
00156             while self.activeThreads() >= self.maxThreads:
00157                 time.sleep(10)
00158                 continue
00159             
00160             print 'Preparing to run %s' % str(command)
00161             current = testit(dirName, command)
00162             self.threadList.append(current)
00163             current.start()
00164             time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec 
00165             
00166         # wait until all threads are finished
00167         while self.activeThreads() > 0:
00168             time.sleep(5)
00169             
00170         # all threads are done now, check status ...
00171         for pingle in self.threadList:
00172             pingle.join()
00173             for f in pingle.nfail: nfail  += f
00174             for p in pingle.npass: npass  += p
00175             report += pingle.report
00176             print pingle.report
00177             sys.stdout.flush()
00178             
00179         reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail)
00180         print reportSumm
00181         
00182         runall_report_name='runall-report.log'
00183         runall_report=open(runall_report_name,'w')
00184         runall_report.write(report+reportSumm)
00185         runall_report.close()
00186 
00187         # get the logs to the logs dir:
00188         print '==> in :', os.getcwd()
00189         print '    going to copy log files to logs dir ...'
00190         if not os.path.exists('logs'):
00191             os.makedirs('logs')
00192         for dirName in self.commands:
00193             cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
00194             print "going to ",cmd
00195             os.system(cmd)
00196 
00197         import pickle
00198         pickle.dump(self.commands, open('logs/addOnTests.pkl', 'w') )
00199 
00200         os.chdir(actDir)
00201         
00202         return

def addOnTests::StandardTester::upload (   self,
  tgtDir 
)

Definition at line 203 of file addOnTests.py.

00204                             :
00205 
00206         print "in ", os.getcwd()
00207 
00208         if not os.path.exists(tgtDir):
00209             os.makedirs(tgtDir)
00210         
00211         cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
00212         try:
00213             print 'executing: ',cmd
00214             ret = os.system(cmd)
00215             if ret != 0:
00216                 print "ERROR uploading logs:", ret, cmd
00217         except Exception, e:
00218             print "EXCEPTION while uploading addOnTest-logs : ", str(e)
00219             
00220         return
00221 
                

Member Data Documentation

Definition at line 82 of file addOnTests.py.

Definition at line 82 of file addOnTests.py.

Definition at line 66 of file addOnTests.py.

Definition at line 82 of file addOnTests.py.

Definition at line 66 of file addOnTests.py.