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

00115                       :
00116         print ",".join(self.commands.keys())
00117         return

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

Definition at line 118 of file addOnTests.py.

00119                              :
00120 
00121         fullPath = self.relPath + rFile
00122         if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
00123         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 -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 -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 -n 10 --conditions auto:startup --relval 9000,50 --datatier "RAW" --eventcontent RAW --fileout file:RelVal_Raw_GRun_DATA.root --filein /store/data/Run2011B/MinimumBias/RAW/v1/000/178/479/3E364D71-F4F5-E011-ABD2-001D09F29146.root',
00102                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_GRun.py')],
00103                      'hlt4' : ['cmsDriver.py RelVal -s L1REPACK -n 10 --conditions auto:starthi --relval 9000,50 --datatier "RAW" --eventcontent RAW --fileout file:RelVal_Raw_HIon_DATA.root --filein /store/data/Run2011B/MinimumBias/RAW/v1/000/178/479/3E364D71-F4F5-E011-ABD2-001D09F29146.root',
00104                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_HIon.py')],
00105                      }
00106 
00107         self.commands={}
00108         for dirName, command in lines.items():
00109             self.commands[dirName] = command
00110 
00111         for dirName, commandList in hltTests.items():
00112             self.commands[dirName] = commandList
00113         return
        
def addOnTests::StandardTester::runTests (   self,
  testList = None 
)

Definition at line 124 of file addOnTests.py.

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

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

Definition at line 193 of file addOnTests.py.

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

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.