CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
addOnTests.StandardTester Class Reference
Inheritance diagram for addOnTests.StandardTester:

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.

66 
67  def __init__(self, nThrMax=4):
68 
69  self.threadList = []
70  self.maxThreads = nThrMax
71  self.prepare()
72 
73  return

Member Function Documentation

def addOnTests.StandardTester.activeThreads (   self)

Definition at line 74 of file addOnTests.py.

References MatrixRunner.MatrixRunner.threadList, and addOnTests.StandardTester.threadList.

Referenced by addOnTests.StandardTester.runTests().

74 
75  def activeThreads(self):
76 
77  nActive = 0
78  for t in self.threadList:
79  if t.isAlive() : nActive += 1
80 
81  return nActive
def addOnTests.StandardTester.dumpTest (   self)

Definition at line 124 of file addOnTests.py.

References join().

125  def dumpTest(self):
126  print ",".join(self.commands.keys())
127  return
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def addOnTests.StandardTester.file2Path (   self,
  rFile 
)

Definition at line 128 of file addOnTests.py.

References addOnTests.StandardTester.devPath, and addOnTests.StandardTester.relPath.

129  def file2Path(self,rFile):
130 
131  fullPath = self.relPath + rFile
132  if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
133  return fullPath
def addOnTests.StandardTester.prepare (   self)

Definition at line 82 of file addOnTests.py.

82 
83  def prepare(self):
84 
85  self.devPath = os.environ['LOCALRT'] + '/src/'
86  self.relPath = self.devPath
87  if os.environ.has_key('CMSSW_RELEASE_BASE') and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
88 
89  lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
90  'fastsim1' : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTestFake_cfg.py')],
91  'fastsim2' : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTest_cfg.py')],
92  #'fastsim3' : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/ExampleWithHLT_1E31_cfg.py')],
93  'fastsim4' : ['cmsRun '+self.file2Path('FastSimulation/Configuration/test/IntegrationTestWithHLT_cfg.py')],
94  'pat1' : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
95  }
96 
97  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',
98  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_GRun.py'),
99  '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'],
100  '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',
101  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py'),
102  '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'],
103  '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',
104  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_GRun.py'),
105  'cmsDriver.py RelVal -s HLT:GRun,RAW2DIGI,L1Reco,RECO --data --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_DATA.root --fileout file:RelVal_Raw_GRun_DATA_HLT_RECO.root'],
106  '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',
107  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnData_HLT_HIon.py'),
108  'cmsDriver.py RelVal -s HLT:HIon,RAW2DIGI,L1Reco,RECO --data --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_DATA.root --fileout file:RelVal_Raw_HIon_DATA_HLT_RECO.root'],
109  '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',
110  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PIon.py'),
111  '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'],
112  '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',
113  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnData_HLT_PIon.py'),
114  'cmsDriver.py RelVal -s HLT:PIon,RAW2DIGI,L1Reco,RECO --data --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_DATA.root --fileout file:RelVal_Raw_PIon_DATA_HLT_RECO.root'],
115  }
117  self.commands={}
118  for dirName, command in lines.items():
119  self.commands[dirName] = command
120 
121  for dirName, commandList in hltTests.items():
122  self.commands[dirName] = commandList
123  return
def addOnTests.StandardTester.runTests (   self,
  testList = None 
)

Definition at line 134 of file addOnTests.py.

References MatrixRunner.MatrixRunner.activeThreads(), addOnTests.StandardTester.activeThreads(), addOnTests.StandardTester.commands, MatrixRunner.MatrixRunner.maxThreads, addOnTests.StandardTester.maxThreads, MatrixRunner.MatrixRunner.threadList, and addOnTests.StandardTester.threadList.

135  def runTests(self, testList = None):
136 
137  actDir = os.getcwd()
138 
139  if not os.path.exists('addOnTests'):
140  os.makedirs('addOnTests')
141  os.chdir('addOnTests')
142 
143  nfail=0
144  npass=0
145  report=''
146 
147  print 'Running in %s thread(s)' % self.maxThreads
148 
149  for dirName, command in self.commands.items():
150 
151  if testList and not dirName in testList:
152  del self.commands[dirName]
153  continue
154 
155  # make sure we don't run more than the allowed number of threads:
156  while self.activeThreads() >= self.maxThreads:
157  time.sleep(10)
158  continue
159 
160  print 'Preparing to run %s' % str(command)
161  current = testit(dirName, command)
162  self.threadList.append(current)
163  current.start()
164  time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec
165 
166  # wait until all threads are finished
167  while self.activeThreads() > 0:
168  time.sleep(5)
169 
170  # all threads are done now, check status ...
171  for pingle in self.threadList:
172  pingle.join()
173  for f in pingle.nfail: nfail += f
174  for p in pingle.npass: npass += p
175  report += pingle.report
176  print pingle.report
177  sys.stdout.flush()
178 
179  reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail)
180  print reportSumm
181 
182  runall_report_name='runall-report.log'
183  runall_report=open(runall_report_name,'w')
184  runall_report.write(report+reportSumm)
185  runall_report.close()
186 
187  # get the logs to the logs dir:
188  print '==> in :', os.getcwd()
189  print ' going to copy log files to logs dir ...'
190  if not os.path.exists('logs'):
191  os.makedirs('logs')
192  for dirName in self.commands:
193  cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
194  print "going to ",cmd
195  os.system(cmd)
196 
197  import pickle
198  pickle.dump(self.commands, open('logs/addOnTests.pkl', 'w') )
199 
200  os.chdir(actDir)
201 
202  return
def addOnTests.StandardTester.upload (   self,
  tgtDir 
)

Definition at line 203 of file addOnTests.py.

204  def upload(self, tgtDir):
205 
206  print "in ", os.getcwd()
207 
208  if not os.path.exists(tgtDir):
209  os.makedirs(tgtDir)
210 
211  cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
212  try:
213  print 'executing: ',cmd
214  ret = os.system(cmd)
215  if ret != 0:
216  print "ERROR uploading logs:", ret, cmd
217  except Exception, e:
218  print "EXCEPTION while uploading addOnTest-logs : ", str(e)
219 
220  return
221 

Member Data Documentation

addOnTests.StandardTester.commands

Definition at line 116 of file addOnTests.py.

Referenced by addOnTests.StandardTester.runTests().

addOnTests.StandardTester.devPath

Definition at line 84 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

addOnTests.StandardTester.maxThreads

Definition at line 69 of file addOnTests.py.

Referenced by addOnTests.StandardTester.runTests().

addOnTests.StandardTester.relPath

Definition at line 85 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

addOnTests.StandardTester.threadList

Definition at line 68 of file addOnTests.py.

Referenced by addOnTests.StandardTester.activeThreads(), and addOnTests.StandardTester.runTests().