CMS 3D CMS Logo

Classes | Functions
conditionUploadTest Namespace Reference

Classes

class  DB
 
class  UploadTest
 

Functions

def main ()
 
def makeBaseFile (inputTag, startingSince)
 
def makeMetadataFile (inputTag, destTag, since, description)
 
def uploadFile (fileName, logFileName)
 

Function Documentation

def conditionUploadTest.main ( )

Definition at line 164 of file conditionUploadTest.py.

References makeBaseFile().

164 def main():
165  print 'Testing...'
166  serviceName = 'cms_orcoff_prep'
167  schemaName = 'CMS_CONDITIONS'
168  db = DB(serviceName,schemaName)
169  db.connect()
170  inputTag = 'runinfo_31X_mc'
171  bfile0 = makeBaseFile( inputTag,1)
172  bfile1 = makeBaseFile( inputTag,100)
173  test = UploadTest( db )
174  # test with synch=any
175  tag = 'test_CondUpload_any'
176  test.upload( inputTag, bfile0, tag, 'any', 1, True, 'CREATE' )
177  test.upload( inputTag, bfile1, tag, 'any', 1, False, 'FAIL' )
178  test.upload( inputTag, bfile0, tag, 'any', 200, True, 'APPEND' )
179  test.upload( inputTag, bfile0, tag, 'any', 100, True, 'INSERT')
180  test.upload( inputTag, bfile0, tag, 'any', 200, True, 'INSERT')
181  db.removeTag( tag )
182  # test with synch=validation
183  tag = 'test_CondUpload_validation'
184  test.upload( inputTag, bfile0, tag, 'validation', 1, True, 'CREATE')
185  db.setSynchronizationType( tag, 'validation' )
186  test.upload( inputTag, bfile0, tag, 'validation', 1, True, 'INSERT')
187  test.upload( inputTag, bfile0, tag, 'validation', 200, True, 'APPEND')
188  test.upload( inputTag, bfile0, tag, 'validation', 100, True, 'INSERT')
189  db.removeTag( tag )
190  # test with synch=mc
191  tag = 'test_CondUpload_mc'
192  test.upload( inputTag, bfile1, tag, 'mc', 1, False, 'FAIL')
193  test.upload( inputTag, bfile0, tag, 'mc', 1, True, 'CREATE')
194  db.setSynchronizationType( tag, 'mc' )
195  test.upload( inputTag, bfile0, tag, 'mc', 1, False, 'FAIL')
196  test.upload( inputTag, bfile0, tag, 'mc', 200, False, 'FAIL')
197  db.removeTag( tag )
198  # test with synch=hlt
199  tag = 'test_CondUpload_hlt'
200  test.upload( inputTag, bfile0, tag, 'hlt', 1, True, 'CREATE')
201  db.setSynchronizationType( tag, 'hlt' )
202  test.upload( inputTag, bfile0, tag, 'hlt', 200, True, 'SYNCHRONIZE')
203  fcsr = test.upload( inputTag, bfile0, tag, 'hlt', 100, True, 'SYNCHRONIZE')
204  if not fcsr is None:
205  since = fcsr + 200
206  test.upload( inputTag, bfile0, tag, 'hlt', since, True, 'APPEND')
207  since = fcsr + 100
208  test.upload( inputTag, bfile0, tag, 'hlt', since, True, 'INSERT')
209  db.removeTag( tag )
210  # test with synch=express
211  tag = 'test_CondUpload_express'
212  test.upload( inputTag, bfile0, tag, 'express', 1, True, 'CREATE')
213  db.setSynchronizationType( tag, 'express' )
214  test.upload( inputTag, bfile0, tag, 'express', 200, True, 'SYNCHRONIZE')
215  fcsr = test.upload( inputTag, bfile0, tag, 'express', 100, True, 'SYNCHRONIZE')
216  if not fcsr is None:
217  since = fcsr + 200
218  test.upload( inputTag, bfile0, tag, 'express', since, True, 'APPEND')
219  since = fcsr + 100
220  test.upload( inputTag, bfile0, tag, 'express', since, True, 'INSERT')
221  db.removeTag( tag )
222  # test with synch=prompt
223  tag = 'test_CondUpload_prompt'
224  test.upload( inputTag, bfile0, tag, 'prompt', 1, True, 'CREATE')
225  db.setSynchronizationType( tag, 'prompt' )
226  test.upload( inputTag, bfile0, tag, 'prompt', 200, True, 'SYNCHRONIZE')
227  fcsr = test.upload( inputTag, bfile0, tag, 'prompt', 100, True, 'SYNCHRONIZE')
228  if not fcsr is None:
229  since = fcsr + 200
230  test.upload( inputTag, bfile0, tag, 'prompt', since, True, 'APPEND')
231  since = fcsr + 100
232  test.upload( inputTag, bfile0, tag, 'prompt', since, True, 'INSERT')
233  db.removeTag( tag )
234  # test with synch=pcl
235  tag = 'test_CondUpload_pcl'
236  test.upload( inputTag, bfile0, tag, 'pcl', 1, True, 'CREATE')
237  db.setSynchronizationType( tag, 'pcl' )
238  test.upload( inputTag, bfile0, tag, 'pcl', 200, False, 'FAIL')
239  if not fcsr is None:
240  since = fcsr + 200
241  test.upload( inputTag, bfile0, tag, 'pcl', since, True, 'APPEND')
242  since = fcsr + 100
243  test.upload( inputTag, bfile0, tag, 'pcl', since, True, 'INSERT')
244  db.removeTag( tag )
245  # test with synch=offline
246  tag = 'test_CondUpload_offline'
247  test.upload( inputTag, bfile0, tag, 'offline', 1, True, 'CREATE')
248  db.setSynchronizationType( tag, 'offline' )
249  test.upload( inputTag, bfile0, tag, 'offline', 1000, True, 'APPEND')
250  test.upload( inputTag, bfile0, tag, 'offline', 500, False, 'FAIL' )
251  test.upload( inputTag, bfile0, tag, 'offline', 1000, False, 'FAIL' )
252  test.upload( inputTag, bfile0, tag, 'offline', 2000, True, 'APPEND' )
253  db.removeTag( tag )
254  # test with synch=runmc
255  tag = 'test_CondUpload_runmc'
256  test.upload( inputTag, bfile0, tag, 'runmc', 1, True, 'CREATE')
257  db.setSynchronizationType( tag, 'runmc' )
258  test.upload( inputTag, bfile0, tag, 'runmc', 1000, True, 'APPEND')
259  test.upload( inputTag, bfile0, tag, 'runmc', 500, False, 'FAIL' )
260  test.upload( inputTag, bfile0, tag, 'runmc', 1000, False, 'FAIL' )
261  test.upload( inputTag, bfile0, tag, 'runmc', 2000, True, 'APPEND' )
262  db.removeTag( tag )
263  os.remove( bfile0 )
264  os.remove( bfile1 )
265  print 'Done. Errors: %s' %test.errors
266 
def makeBaseFile(inputTag, startingSince)
def conditionUploadTest.makeBaseFile (   inputTag,
  startingSince 
)

Definition at line 55 of file conditionUploadTest.py.

Referenced by main().

55 def makeBaseFile( inputTag, startingSince ):
56  cwd = os.getcwd()
57  baseFile = '%s_%s.db' %(inputTag,startingSince)
58  baseFilePath = os.path.join(cwd,baseFile)
59  if os.path.exists( baseFile ):
60  os.remove( baseFile )
61  command = "conddb_import -c sqlite_file:%s -f oracle://cms_orcon_adg/CMS_CONDITIONS -i %s -t %s -b %s" %(baseFile,inputTag,inputTag,startingSince)
62  pipe = subprocess.Popen( command, shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
63  out = pipe.communicate()[0]
64  if not os.path.exists( baseFile ):
65  msg = 'ERROR: base file has not been created: %s' %out
66  raise Exception( msg )
67  return baseFile
68 
69 
def makeBaseFile(inputTag, startingSince)
def conditionUploadTest.makeMetadataFile (   inputTag,
  destTag,
  since,
  description 
)

Definition at line 70 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

70 def makeMetadataFile( inputTag, destTag, since, description ):
71  cwd = os.getcwd()
72  metadataFile = os.path.join(cwd,'%s.txt') %destTag
73  if os.path.exists( metadataFile ):
74  os.remove( metadataFile )
75  metadata = {}
76  metadata[ "destinationDatabase" ] = "oracle://cms_orcoff_prep/CMS_CONDITIONS"
77  tagList = {}
78  tagList[ destTag ] = { "dependencies": {}, "synchronizeTo": "any" }
79  metadata[ "destinationTags" ] = tagList
80  metadata[ "inputTag" ] = inputTag
81  metadata[ "since" ] = since
82  metadata[ "userText" ] = description
83  fileName = destTag+".txt"
84  with open( fileName, "w" ) as file:
85  file.write(json.dumps(metadata,file,indent=4,sort_keys=True))
86 
def makeMetadataFile(inputTag, destTag, since, description)
def conditionUploadTest.uploadFile (   fileName,
  logFileName 
)

Definition at line 87 of file conditionUploadTest.py.

References digi_MixPreMix_cfi.strip.

Referenced by conditionUploadTest.UploadTest.upload().

87 def uploadFile( fileName, logFileName ):
88  command = "uploadConditions.py %s" %fileName
89  pipe = subprocess.Popen( command, shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
90  out = pipe.communicate()[0]
91  lines = out.split('\n')
92  ret = False
93  for line in lines:
94  if line.startswith('upload ended with code:'):
95  returnCode = line.split('upload ended with code:')[1].strip()
96  if returnCode == '0':
97  ret = True
98  break
99  with open(logFileName,'a') as logFile:
100  logFile.write(out)
101  return ret
102 
def uploadFile(fileName, logFileName)