CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
conddbCopyTest Namespace Reference

Classes

class  CopyTest
 
class  DB
 

Functions

def copy
 
def main
 
def prepareFile
 

Variables

string fileName = 'copy_test.db'
 

Function Documentation

def conddbCopyTest.copy (   sourceTag,
  destTag,
  since,
  logFileName 
)

Definition at line 35 of file conddbCopyTest.py.

References print().

Referenced by conddbCopyTest.CopyTest.execute().

35 
36 def copy( sourceTag, destTag, since, logFileName ):
37  command = "conddb --yes --db %s copy %s %s -f %s --synchronize" %(fileName,sourceTag,destTag,since)
38  pipe = subprocess.Popen( command, shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
39  out = pipe.communicate()[0]
40  lines = out.split('\n')
41  ret = pipe.returncode
42  for line in lines:
43  print(line)
44  with open(logFileName,'a') as logFile:
45  logFile.write(out)
46  return ret==0
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def conddbCopyTest.main ( )

Definition at line 104 of file conddbCopyTest.py.

References prepareFile(), and print().

105 def main():
106  print('Testing...')
107  bfile0 = fileName
108  bfile1 = fileName
109  db = DB()
110  inputTag = 'runinfo_31X_mc'
111  inputTag0 ='runinfo_0'
112  inputTag1 = 'runinfo_1'
113  prepareFile( inputTag,inputTag0,1)
114  prepareFile( inputTag,inputTag1,100)
115  test = CopyTest( db )
116  # test with synch=any
117  tag = 'test_CondUpload_any'
118  test.execute( inputTag0, bfile0, tag, 'any', 1, True, 'CREATE' )
119  test.execute( inputTag0, bfile0, tag, 'any', 200, True, 'APPEND' )
120  test.execute( inputTag0, bfile0, tag, 'any', 100, True, 'INSERT')
121  test.execute( inputTag0, bfile0, tag, 'any', 200, True, 'INSERT')
122  # test with synch=validation
123  tag = 'test_CondUpload_validation'
124  test.execute( inputTag0, bfile0, tag, 'validation', 1, True, 'CREATE')
125  db.setSynchronizationType( tag, 'validation' )
126  test.execute( inputTag0, bfile0, tag, 'validation', 1, True, 'INSERT')
127  test.execute( inputTag0, bfile0, tag, 'validation', 200, True, 'APPEND')
128  test.execute( inputTag0, bfile0, tag, 'validation', 100, True, 'INSERT')
129  # test with synch=mc
130  tag = 'test_CondUpload_mc'
131  test.execute( inputTag0, bfile0, tag, 'mc', 1, True, 'CREATE')
132  db.setSynchronizationType( tag, 'mc' )
133  test.execute( inputTag1, bfile1, tag, 'mc', 1, False, 'FAIL')
134  test.execute( inputTag0, bfile0, tag, 'mc', 1, False, 'FAIL')
135  test.execute( inputTag0, bfile0, tag, 'mc', 200, False, 'FAIL')
136  # test with synch=hlt
137  tag = 'test_CondUpload_hlt'
138  test.execute( inputTag0, bfile0, tag, 'hlt', 1, True, 'CREATE')
139  db.setSynchronizationType( tag, 'hlt' )
140  test.execute( inputTag0, bfile0, tag, 'hlt', 200, True, 'SYNCHRONIZE')
141  fcsr = test.execute( inputTag0, bfile0, tag, 'hlt', 100, True, 'SYNCHRONIZE')
142  if not fcsr is None:
143  since = fcsr + 200
144  test.execute( inputTag0, bfile0, tag, 'hlt', since, True, 'APPEND')
145  since = fcsr + 100
146  test.execute( inputTag0, bfile0, tag, 'hlt', since, True, 'INSERT')
147  # test with synch=express
148  tag = 'test_CondUpload_express'
149  test.execute( inputTag0, bfile0, tag, 'express', 1, True, 'CREATE')
150  db.setSynchronizationType( tag, 'express' )
151  test.execute( inputTag0, bfile0, tag, 'express', 200, True, 'SYNCHRONIZE')
152  fcsr = test.execute( inputTag0, bfile0, tag, 'express', 100, True, 'SYNCHRONIZE')
153  if not fcsr is None:
154  since = fcsr + 200
155  test.execute( inputTag0, bfile0, tag, 'express', since, True, 'APPEND')
156  since = fcsr + 100
157  test.execute( inputTag0, bfile0, tag, 'express', since, True, 'INSERT')
158  # test with synch=prompt
159  tag = 'test_CondUpload_prompt'
160  test.execute( inputTag0, bfile0, tag, 'prompt', 1, True, 'CREATE')
161  db.setSynchronizationType( tag, 'prompt' )
162  test.execute( inputTag0, bfile0, tag, 'prompt', 200, True, 'SYNCHRONIZE')
163  fcsr = test.execute( inputTag0, bfile0, tag, 'prompt', 100, True, 'SYNCHRONIZE')
164  if not fcsr is None:
165  since = fcsr + 200
166  test.execute( inputTag0, bfile0, tag, 'prompt', since, True, 'APPEND')
167  since = fcsr + 100
168  test.execute( inputTag0, bfile0, tag, 'prompt', since, True, 'INSERT')
169  # test with synch=pcl
170  tag = 'test_CondUpload_pcl'
171  test.execute( inputTag0, bfile0, tag, 'pcl', 1, True, 'CREATE')
172  db.setSynchronizationType( tag, 'pcl' )
173  test.execute( inputTag0, bfile0, tag, 'pcl', 200, False, 'FAIL')
174  if not fcsr is None:
175  since = fcsr + 200
176  test.execute( inputTag0, bfile0, tag, 'pcl', since, True, 'APPEND')
177  since = fcsr + 100
178  test.execute( inputTag0, bfile0, tag, 'pcl', since, True, 'INSERT')
179  # test with synch=offline
180  tag = 'test_CondUpload_offline'
181  test.execute( inputTag0, bfile0, tag, 'offline', 1, True, 'CREATE')
182  db.setSynchronizationType( tag, 'offline' )
183  test.execute( inputTag0, bfile0, tag, 'offline', 1000, True, 'APPEND')
184  test.execute( inputTag0, bfile0, tag, 'offline', 500, False, 'FAIL' )
185  test.execute( inputTag0, bfile0, tag, 'offline', 1000, False, 'FAIL' )
186  test.execute( inputTag0, bfile0, tag, 'offline', 2000, True, 'APPEND' )
187  # test with synch=runmc
188  tag = 'test_CondUpload_runmc'
189  test.execute( inputTag0, bfile0, tag, 'runmc', 1, True, 'CREATE')
190  db.setSynchronizationType( tag, 'runmc' )
191  test.execute( inputTag0, bfile0, tag, 'runmc', 1000, True, 'APPEND')
192  test.execute( inputTag0, bfile0, tag, 'runmc', 500, False, 'FAIL' )
193  test.execute( inputTag0, bfile0, tag, 'runmc', 1000, False, 'FAIL' )
194  test.execute( inputTag0, bfile0, tag, 'runmc', 2000, True, 'APPEND' )
195  os.remove( fileName )
196  print('Done. Errors: %s' %test.errors)
197 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def conddbCopyTest.prepareFile (   inputTag,
  sourceTag,
  startingSince 
)

Definition at line 30 of file conddbCopyTest.py.

Referenced by main().

30 
31 def prepareFile( inputTag, sourceTag, startingSince ):
32  command = "conddb --yes copy %s %s --destdb %s -f %s" %(inputTag,sourceTag,fileName,startingSince)
33  pipe = subprocess.Popen( command, shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
34  out = pipe.communicate()[0]

Variable Documentation

string conddbCopyTest.fileName = 'copy_test.db'

Definition at line 11 of file conddbCopyTest.py.