CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
conddbCopyTest.CopyTest Class Reference

Public Member Functions

def __init__ (self, db)
 
def execute (self, sourceTag, baseFile, destTag, synchro, destSince, success, expectedAction)
 
def log (self, msg)
 

Public Attributes

 db
 
 errors
 
 logFileName
 

Detailed Description

Definition at line 46 of file conddbCopyTest.py.

Constructor & Destructor Documentation

def conddbCopyTest.CopyTest.__init__ (   self,
  db 
)

Definition at line 47 of file conddbCopyTest.py.

47  def __init__(self, db):
48  self.db = db
49  self.errors = 0
50  self.logFileName = 'conddbCopyTest.log'
51 

Member Function Documentation

def conddbCopyTest.CopyTest.execute (   self,
  sourceTag,
  baseFile,
  destTag,
  synchro,
  destSince,
  success,
  expectedAction 
)

Definition at line 58 of file conddbCopyTest.py.

References conddbCopyTest.copy(), conddbCopyTest.CopyTest.errors, conddbCopyTest.CopyTest.log(), crabFunctions.CrabTask.log, and conddbCopyTest.CopyTest.logFileName.

58  def execute( self, sourceTag, baseFile, destTag, synchro, destSince, success, expectedAction ):
59  insertedSince = None
60  metaDestFile = '%s.txt' %destTag
61  #shutil.copyfile( baseFile, destFile )
62  self.log( '# ---------------------------------------------------------------------------')
63  self.log( '# Testing tag %s with synch=%s, destSince=%s - expecting ret=%s action=%s' %(destTag,synchro,destSince,success,expectedAction))
64 
65  descr = 'Testing conditionsUpload with synch:%s - expected action: %s' %(synchro,expectedAction)
66  beforeUpload = datetime.datetime.utcnow()
67  ret = copy( sourceTag, destTag, destSince, self.logFileName )
68  if ret != success:
69  self.log( 'ERROR: the return value for the copy of tag %s with sychro %s was %s, while the expected result is %s' %(destTag,synchro,ret,success))
70  self.errors += 1
71  else:
72  row = self.db.getLastInsertedSince( destTag, beforeUpload )
73  if ret == True:
74  if expectedAction == 'CREATE' or expectedAction == 'INSERT' or expectedAction == 'APPEND':
75  if destSince != row[0]:
76  self.log( 'ERROR: the since inserted is %s, expected value is %s - expected action: %s' %(row[0],destSince,expectedAction))
77  self.errors += 1
78  else:
79  self.log( '# OK: Found expected value for last since inserted: %s timestamp: %s' %(row[0],row[1]))
80  insertedSince = row[0]
81  elif expectedAction == 'SYNCHRONIZE':
82  if destSince == row[0]:
83  self.log( 'ERROR: the since inserted %s has not been synchronized with the FCSR - expected action: %s' %(row[0],expectedAction))
84  self.errors += 1
85  else:
86  self.log( '# OK: Found synchronized value for the last since inserted: %s timestamp: %s' %(row[0],row[1]))
87  insertedSince = row[0]
88  else:
89  self.log( 'ERROR: found an appended since %s - expected action: %s' %(row[0],expectedAction))
90  self.errors += 1
91  else:
92  if not row is None:
93  self.log( 'ERROR: found new insered since: %s timestamp: %s' %(row[0],row[1]))
94  self.errors += 1
95  if expectedAction != 'FAIL':
96  self.log( 'ERROR: Upload failed. Expected value: %s' %(destSince))
97  self.errors += 1
98  else:
99  self.log( '# OK: Upload failed as expected.')
100  return insertedSince
101 
102 
def copy(sourceTag, destTag, since, logFileName)
def execute(self, sourceTag, baseFile, destTag, synchro, destSince, success, expectedAction)
def conddbCopyTest.CopyTest.log (   self,
  msg 
)

Definition at line 52 of file conddbCopyTest.py.

References conddbCopyTest.CopyTest.logFileName.

Referenced by conddbCopyTest.CopyTest.execute(), and conditionUploadTest.UploadTest.upload().

52  def log( self, msg ):
53  print msg
54  with open(self.logFileName,'a') as logFile:
55  logFile.write(msg)
56  logFile.write('\n')
57 

Member Data Documentation

conddbCopyTest.CopyTest.db

Definition at line 48 of file conddbCopyTest.py.

conddbCopyTest.CopyTest.errors
conddbCopyTest.CopyTest.logFileName