CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
conditionUploadTest.UploadTest Class Reference

Public Member Functions

def __init__ (self, db)
 
def log (self, msg)
 
def upload (self, inputTag, baseFile, destTag, synchro, destSince, success, expectedAction)
 

Public Attributes

 db
 
 errors
 
 logFileName
 

Detailed Description

Definition at line 104 of file conditionUploadTest.py.

Constructor & Destructor Documentation

◆ __init__()

def conditionUploadTest.UploadTest.__init__ (   self,
  db 
)

Definition at line 105 of file conditionUploadTest.py.

105  def __init__(self, db):
106  self.db = db
107  self.errors = 0
108  self.logFileName = 'conditionUploadTest.log'
109 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ log()

def conditionUploadTest.UploadTest.log (   self,
  msg 
)

Definition at line 110 of file conditionUploadTest.py.

References conddbCopyTest.CopyTest.logFileName, conditionUploadTest.UploadTest.logFileName, and print().

Referenced by personalPlayback.Playback.do_create_lumi(), personalPlayback.Playback.do_exec(), personalPlayback.FrameworkJob.do_exec(), personalPlayback.FrameworkJob.start_run(), and conditionUploadTest.UploadTest.upload().

110  def log( self, msg ):
111  print(msg)
112  with open(self.logFileName,'a') as logFile:
113  logFile.write(msg)
114  logFile.write('\n')
115 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ upload()

def conditionUploadTest.UploadTest.upload (   self,
  inputTag,
  baseFile,
  destTag,
  synchro,
  destSince,
  success,
  expectedAction 
)

Definition at line 116 of file conditionUploadTest.py.

References Histograms_PPSDiamondSampicTimingCalibrationPCLWorker.db, conddbCopyTest.CopyTest.db, conddb_version_mgr.version_db.db, conditionUploadTest.UploadTest.db, conddb_version_mgr.conddb_tool.db, HcalLutManager.db, conddbCopyTest.CopyTest.errors, conditionUploadTest.UploadTest.errors, conddbCopyTest.CopyTest.log(), conditionUploadTest.UploadTest.log(), cond::persistency::Logger.log(), cond::CredentialStore.log(), crabFunctions.CrabTask.log, conddbCopyTest.CopyTest.logFileName, conditionUploadTest.UploadTest.logFileName, conditionUploadTest.makeMetadataFile(), and conditionUploadTest.uploadFile().

116  def upload( self, inputTag, baseFile, destTag, synchro, destSince, success, expectedAction ):
117  insertedSince = None
118  destFile = '%s.db' %destTag
119  metaDestFile = '%s.txt' %destTag
120  shutil.copyfile( baseFile, destFile )
121  self.log( '# ---------------------------------------------------------------------------')
122  self.log( '# Testing tag %s with synch=%s, destSince=%s - expecting ret=%s action=%s' %(destTag,synchro,destSince,success,expectedAction))
123 
124  descr = 'Testing conditionsUpload with synch:%s - expected action: %s' %(synchro,expectedAction)
125  makeMetadataFile( inputTag, destTag, destSince, descr )
126  beforeUpload = datetime.datetime.utcnow()
127  ret = uploadFile( destFile, self.logFileName )
128  if ret != success:
129  self.log( 'ERROR: the return value for the upload of tag %s with sychro %s was %s, while the expected result is %s' %(destTag,synchro,ret,success))
130  self.errors += 1
131  else:
132  row = self.db.getLastInsertedSince( destTag, beforeUpload )
133  if ret == True:
134  if expectedAction == 'CREATE' or expectedAction == 'INSERT' or expectedAction == 'APPEND':
135  if destSince != row[0]:
136  self.log( 'ERROR: the since inserted is %s, expected value is %s - expected action: %s' %(row[0],destSince,expectedAction))
137  self.errors += 1
138  else:
139  self.log( '# OK: Found expected value for last since inserted: %s timestamp: %s' %(row[0],row[1]))
140  insertedSince = row[0]
141  elif expectedAction == 'SYNCHRONIZE':
142  if destSince == row[0]:
143  self.log( 'ERROR: the since inserted %s has not been synchronized with the FCSR - expected action: %s' %(row[0],expectedAction))
144  self.errors += 1
145  else:
146  self.log( '# OK: Found synchronized value for the last since inserted: %s timestamp: %s' %(row[0],row[1]))
147  insertedSince = row[0]
148  else:
149  self.log( 'ERROR: found an appended since %s - expected action: %s' %(row[0],expectedAction))
150  self.errors += 1
151  else:
152  if not row is None:
153  self.log( 'ERROR: found new insered since: %s timestamp: %s' %(row[0],row[1]))
154  self.errors += 1
155  if expectedAction != 'FAIL':
156  self.log( 'ERROR: Upload failed. Expected value: %s' %(destSince))
157  self.errors += 1
158  else:
159  self.log( '# OK: Upload failed as expected.')
160  os.remove( destFile )
161  os.remove( metaDestFile )
162  return insertedSince
163 
164 
def upload(url, args, files)
def uploadFile(fileName, logFileName)
def makeMetadataFile(inputTag, destTag, since, description)

Member Data Documentation

◆ db

conditionUploadTest.UploadTest.db

Definition at line 106 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

◆ errors

conditionUploadTest.UploadTest.errors

Definition at line 107 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

◆ logFileName

conditionUploadTest.UploadTest.logFileName