CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 66 of file addOnTests.py.

Constructor & Destructor Documentation

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

Definition at line 68 of file addOnTests.py.

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

Member Function Documentation

def addOnTests.StandardTester.activeThreads (   self)

Definition at line 76 of file addOnTests.py.

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

Referenced by addOnTests.StandardTester.runTests().

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

Definition at line 124 of file addOnTests.py.

References join(), and print().

125  def dumpTest(self):
126  print(",".join(self.commands.keys()))
127  return
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
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 84 of file addOnTests.py.

84 
85  def prepare(self):
86 
87  self.devPath = os.environ['LOCALRT'] + '/src/'
88  self.relPath = self.devPath
89  if 'CMSSW_RELEASE_BASE' in os.environ and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
90 
91  lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
92  'fastsim' : ["cmsDriver.py TTbar_8TeV_TuneCUETP8M1_cfi --conditions auto:run1_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot Realistic8TeVCollision"],
93  'fastsim1' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc_l1stage1 --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_25ns"],
94  'fastsim2' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_2016"],
95  'pat1' : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
96  }
97 
98  hltTests = {}
99  hltFlag_data = ' realData=True globalTag=@ inputFiles=@ '
100  hltFlag_mc = ' realData=False globalTag=@ inputFiles=@ '
101  from Configuration.HLT.addOnTestsHLT import addOnTestsHLT
102  hltTestsToAdd = addOnTestsHLT()
103  for key in hltTestsToAdd:
104  if '_data_' in key:
105  hltTests[key] = [hltTestsToAdd[key][0],
106  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+hltFlag_data,
107  hltTestsToAdd[key][2]]
108  elif '_mc_' in key:
109  hltTests[key] = [hltTestsToAdd[key][0],
110  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+hltFlag_mc,
111  hltTestsToAdd[key][2]]
112  else:
113  hltTests[key] = [hltTestsToAdd[key][0],
114  'cmsRun '+self.file2Path(hltTestsToAdd[key][1]),
115  hltTestsToAdd[key][2]]
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, print(), str, 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  if testList:
150  self.commands = {d:c for d,c in self.commands.items() if d in testList}
151  for dirName, command in self.commands.items():
152 
153  # make sure we don't run more than the allowed number of threads:
154  while self.activeThreads() >= self.maxThreads:
155  time.sleep(10)
156  continue
157 
158  print('Preparing to run %s' % str(command))
159  current = testit(dirName, command)
160  self.threadList.append(current)
161  current.start()
162  time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec
163 
164  # wait until all threads are finished
165  while self.activeThreads() > 0:
166  time.sleep(5)
167 
168  # all threads are done now, check status ...
169  for pingle in self.threadList:
170  pingle.join()
171  for f in pingle.nfail: nfail += f
172  for p in pingle.npass: npass += p
173  report += pingle.report
174  print(pingle.report)
175  sys.stdout.flush()
176 
177  reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail)
178  print(reportSumm)
179 
180  runall_report_name='runall-report.log'
181  runall_report=open(runall_report_name,'w')
182  runall_report.write(report+reportSumm)
183  runall_report.close()
184 
185  # get the logs to the logs dir:
186  print('==> in :', os.getcwd())
187  print(' going to copy log files to logs dir ...')
188  if not os.path.exists('logs'):
189  os.makedirs('logs')
190  for dirName in self.commands:
191  cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
192  print("going to ",cmd)
193  os.system(cmd)
194 
195  import pickle
196  pickle.dump(self.commands, open('logs/addOnTests.pkl', 'wb'), protocol=2)
197 
198  os.chdir(actDir)
199 
200  return
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
def addOnTests.StandardTester.upload (   self,
  tgtDir 
)

Definition at line 201 of file addOnTests.py.

References print(), and str.

202  def upload(self, tgtDir):
203 
204  print("in ", os.getcwd())
205 
206  if not os.path.exists(tgtDir):
207  os.makedirs(tgtDir)
208 
209  cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
210  try:
211  print('executing: ',cmd)
212  ret = os.system(cmd)
213  if ret != 0:
214  print("ERROR uploading logs:", ret, cmd)
215  except Exception as e:
216  print("EXCEPTION while uploading addOnTest-logs : ", str(e))
217 
218  return
219 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)

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

Referenced by addOnTests.StandardTester.file2Path().

addOnTests.StandardTester.maxThreads

Definition at line 71 of file addOnTests.py.

Referenced by addOnTests.StandardTester.runTests().

addOnTests.StandardTester.relPath

Definition at line 87 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

addOnTests.StandardTester.threadList

Definition at line 70 of file addOnTests.py.

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