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

00113                       :
00114         print ",".join(self.commands.keys())
00115         return

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

Definition at line 116 of file addOnTests.py.

00117                              :
00118 
00119         fullPath = self.relPath + rFile
00120         if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
00121         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_DigiL1Raw_GRun.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_DigiL1Raw_HIon.root',
00100                                'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py')],
00101                      'hlt3' : ['cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_GRun.py')],
00102                      'hlt4' : ['cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_HIon.py')],
00103                      }
00104 
00105         self.commands={}
00106         for dirName, command in lines.items():
00107             self.commands[dirName] = command
00108 
00109         for dirName, commandList in hltTests.items():
00110             self.commands[dirName] = commandList
00111         return
        
def addOnTests::StandardTester::runTests (   self,
  testList = None 
)

Definition at line 122 of file addOnTests.py.

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

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

Definition at line 191 of file addOnTests.py.

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

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.