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 118 of file addOnTests.py.

00119                       :
00120         print ",".join(self.commands.keys())
00121         return

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

Definition at line 122 of file addOnTests.py.

00123                              :
00124 
00125         fullPath = self.relPath + rFile
00126         if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
00127         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                      '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',
00100                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py')],
00101                      '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',
00102                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_GRun.py')],
00103                      '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',
00104                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_HIon.py')],
00105                      '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', 
00106                                'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PIon.py')],
00107                      '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',
00108                                'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnData_HLT_PIon.py')],
00109                      }
00110 
00111         self.commands={}
00112         for dirName, command in lines.items():
00113             self.commands[dirName] = command
00114 
00115         for dirName, commandList in hltTests.items():
00116             self.commands[dirName] = commandList
00117         return
        
def addOnTests::StandardTester::runTests (   self,
  testList = None 
)

Definition at line 128 of file addOnTests.py.

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

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

Definition at line 197 of file addOnTests.py.

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

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.