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

def conditionUploadTest.UploadTest.__init__ (   self,
  db 
)

Member Function Documentation

def conditionUploadTest.UploadTest.log (   self,
  msg 
)

Definition at line 110 of file conditionUploadTest.py.

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

Referenced by 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 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def conditionUploadTest.UploadTest.upload (   self,
  inputTag,
  baseFile,
  destTag,
  synchro,
  destSince,
  success,
  expectedAction 
)

Definition at line 116 of file conditionUploadTest.py.

References conddbCopyTest.CopyTest.errors, conditionUploadTest.UploadTest.errors, conddbCopyTest.CopyTest.log(), conditionUploadTest.UploadTest.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(self, inputTag, baseFile, destTag, synchro, destSince, success, expectedAction)
def uploadFile(fileName, logFileName)
def makeMetadataFile(inputTag, destTag, since, description)

Member Data Documentation

conditionUploadTest.UploadTest.db

Definition at line 106 of file conditionUploadTest.py.

conditionUploadTest.UploadTest.errors

Definition at line 107 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

conditionUploadTest.UploadTest.logFileName