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

References makeBaseFile(), and edm.print().

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

Definition at line 56 of file conditionUploadTest.py.

Referenced by main().

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

Definition at line 71 of file conditionUploadTest.py.

Referenced by conditionUploadTest.UploadTest.upload().

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

Definition at line 88 of file conditionUploadTest.py.

References digitizers_cfi.strip.

Referenced by conditionUploadTest.UploadTest.upload().

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