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 103 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 109 of file conditionUploadTest.py.

References conddbCopyTest.CopyTest.logFileName, and conditionUploadTest.UploadTest.logFileName.

Referenced by conditionUploadTest.UploadTest.upload().

109  def log( self, msg ):
110  print msg
111  with open(self.logFileName,'a') as logFile:
112  logFile.write(msg)
113  logFile.write('\n')
114 
def conditionUploadTest.UploadTest.upload (   self,
  inputTag,
  baseFile,
  destTag,
  synchro,
  destSince,
  success,
  expectedAction 
)

Definition at line 115 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().

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

conditionUploadTest.UploadTest.errors

Definition at line 106 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

conditionUploadTest.UploadTest.logFileName