10 fileName =
'copy_test.db' 17 db = sqlite3.connect(fileName)
19 cursor.execute(
'UPDATE TAG SET SYNCHRONIZATION =? WHERE NAME =?',(synchType,tag,))
23 db = sqlite3.connect(fileName)
25 cursor.execute(
'SELECT SINCE, INSERTION_TIME FROM IOV WHERE TAG_NAME =? AND INSERTION_TIME >? ORDER BY INSERTION_TIME DESC',(tag,snapshot))
26 row = cursor.fetchone()
30 command =
"conddb --yes copy %s %s --destdb %s -f %s" %(inputTag,sourceTag,fileName,startingSince)
31 pipe = subprocess.Popen( command, shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
32 out = pipe.communicate()[0]
34 def copy( sourceTag, destTag, since, logFileName ):
35 command =
"conddb --yes --db %s copy %s %s -f %s --synchronize" %(fileName,sourceTag,destTag,since)
36 pipe = subprocess.Popen( command, shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
37 out = pipe.communicate()[0]
38 lines = out.split(
'\n')
42 with open(logFileName,
'a')
as logFile:
58 def execute( self, sourceTag, baseFile, destTag, synchro, destSince, success, expectedAction ):
60 metaDestFile =
'%s.txt' %destTag
62 self.
log(
'# ---------------------------------------------------------------------------')
63 self.
log(
'# Testing tag %s with synch=%s, destSince=%s - expecting ret=%s action=%s' %(destTag,synchro,destSince,success,expectedAction))
65 descr =
'Testing conditionsUpload with synch:%s - expected action: %s' %(synchro,expectedAction)
66 beforeUpload = datetime.datetime.utcnow()
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))
72 row = self.db.getLastInsertedSince( destTag, beforeUpload )
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))
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))
86 self.
log(
'# OK: Found synchronized value for the last since inserted: %s timestamp: %s' %(row[0],row[1]))
87 insertedSince = row[0]
89 self.
log(
'ERROR: found an appended since %s - expected action: %s' %(row[0],expectedAction))
93 self.
log(
'ERROR: found new insered since: %s timestamp: %s' %(row[0],row[1]))
95 if expectedAction !=
'FAIL':
96 self.
log(
'ERROR: Upload failed. Expected value: %s' %(destSince))
99 self.
log(
'# OK: Upload failed as expected.')
108 inputTag =
'runinfo_31X_mc' 109 inputTag0 =
'runinfo_0' 110 inputTag1 =
'runinfo_1' 115 tag =
'test_CondUpload_any' 116 test.execute( inputTag0, bfile0, tag,
'any', 1,
True,
'CREATE' )
117 test.execute( inputTag0, bfile0, tag,
'any', 200,
True,
'APPEND' )
118 test.execute( inputTag0, bfile0, tag,
'any', 100,
True,
'INSERT')
119 test.execute( inputTag0, bfile0, tag,
'any', 200,
True,
'INSERT')
121 tag =
'test_CondUpload_validation' 122 test.execute( inputTag0, bfile0, tag,
'validation', 1,
True,
'CREATE')
123 db.setSynchronizationType( tag,
'validation' )
124 test.execute( inputTag0, bfile0, tag,
'validation', 1,
True,
'INSERT')
125 test.execute( inputTag0, bfile0, tag,
'validation', 200,
True,
'APPEND')
126 test.execute( inputTag0, bfile0, tag,
'validation', 100,
True,
'INSERT')
128 tag =
'test_CondUpload_mc' 129 test.execute( inputTag0, bfile0, tag,
'mc', 1,
True,
'CREATE')
130 db.setSynchronizationType( tag,
'mc' )
131 test.execute( inputTag1, bfile1, tag,
'mc', 1,
False,
'FAIL')
132 test.execute( inputTag0, bfile0, tag,
'mc', 1,
False,
'FAIL')
133 test.execute( inputTag0, bfile0, tag,
'mc', 200,
False,
'FAIL')
135 tag =
'test_CondUpload_hlt' 136 test.execute( inputTag0, bfile0, tag,
'hlt', 1,
True,
'CREATE')
137 db.setSynchronizationType( tag,
'hlt' )
138 test.execute( inputTag0, bfile0, tag,
'hlt', 200,
True,
'SYNCHRONIZE')
139 fcsr = test.execute( inputTag0, bfile0, tag,
'hlt', 100,
True,
'SYNCHRONIZE')
142 test.execute( inputTag0, bfile0, tag,
'hlt', since,
True,
'APPEND')
144 test.execute( inputTag0, bfile0, tag,
'hlt', since,
True,
'INSERT')
146 tag =
'test_CondUpload_express' 147 test.execute( inputTag0, bfile0, tag,
'express', 1,
True,
'CREATE')
148 db.setSynchronizationType( tag,
'express' )
149 test.execute( inputTag0, bfile0, tag,
'express', 200,
True,
'SYNCHRONIZE')
150 fcsr = test.execute( inputTag0, bfile0, tag,
'express', 100,
True,
'SYNCHRONIZE')
153 test.execute( inputTag0, bfile0, tag,
'express', since,
True,
'APPEND')
155 test.execute( inputTag0, bfile0, tag,
'express', since,
True,
'INSERT')
157 tag =
'test_CondUpload_prompt' 158 test.execute( inputTag0, bfile0, tag,
'prompt', 1,
True,
'CREATE')
159 db.setSynchronizationType( tag,
'prompt' )
160 test.execute( inputTag0, bfile0, tag,
'prompt', 200,
True,
'SYNCHRONIZE')
161 fcsr = test.execute( inputTag0, bfile0, tag,
'prompt', 100,
True,
'SYNCHRONIZE')
164 test.execute( inputTag0, bfile0, tag,
'prompt', since,
True,
'APPEND')
166 test.execute( inputTag0, bfile0, tag,
'prompt', since,
True,
'INSERT')
168 tag =
'test_CondUpload_pcl' 169 test.execute( inputTag0, bfile0, tag,
'pcl', 1,
True,
'CREATE')
170 db.setSynchronizationType( tag,
'pcl' )
171 test.execute( inputTag0, bfile0, tag,
'pcl', 200,
False,
'FAIL')
174 test.execute( inputTag0, bfile0, tag,
'pcl', since,
True,
'APPEND')
176 test.execute( inputTag0, bfile0, tag,
'pcl', since,
True,
'INSERT')
178 tag =
'test_CondUpload_offline' 179 test.execute( inputTag0, bfile0, tag,
'offline', 1,
True,
'CREATE')
180 db.setSynchronizationType( tag,
'offline' )
181 test.execute( inputTag0, bfile0, tag,
'offline', 1000,
True,
'APPEND')
182 test.execute( inputTag0, bfile0, tag,
'offline', 500,
False,
'FAIL' )
183 test.execute( inputTag0, bfile0, tag,
'offline', 1000,
False,
'FAIL' )
184 test.execute( inputTag0, bfile0, tag,
'offline', 2000,
True,
'APPEND' )
186 tag =
'test_CondUpload_runmc' 187 test.execute( inputTag0, bfile0, tag,
'runmc', 1,
True,
'CREATE')
188 db.setSynchronizationType( tag,
'runmc' )
189 test.execute( inputTag0, bfile0, tag,
'runmc', 1000,
True,
'APPEND')
190 test.execute( inputTag0, bfile0, tag,
'runmc', 500,
False,
'FAIL' )
191 test.execute( inputTag0, bfile0, tag,
'runmc', 1000,
False,
'FAIL' )
192 test.execute( inputTag0, bfile0, tag,
'runmc', 2000,
True,
'APPEND' )
193 os.remove( fileName )
194 print 'Done. Errors: %s' %test.errors
197 if __name__ ==
'__main__':
def prepareFile(inputTag, sourceTag, startingSince)
def copy(sourceTag, destTag, since, logFileName)
def setSynchronizationType(self, tag, synchType)
def execute(self, sourceTag, baseFile, destTag, synchro, destSince, success, expectedAction)
def getLastInsertedSince(self, tag, snapshot)