Commit 221b668c authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Change the db driver to be the same as test_Regression


git-svn-id: file:///git/lcgcool.svndb/cool/trunk@20085 4525493e-7705-40b1-a816-d608a930855b
parent 9a82511f
......@@ -69,12 +69,13 @@ if __name__ == '__main__':
'have different values: assume that',\
'the R/O and R/W tests will use different replicas'
else:
print 'DEBUG: Environment variables', envKey, 'and', envKeyR,\
'have the same value: check replicas for', connectString
print 'DEBUG: Environment variables', envKey,\
'and', envKeyR, 'have the same value:'\
'will check replicas for', connectString
else:
connectStringR = connectString
print 'DEBUG: Environment variable', envKeyR,\
'is not defined: check replicas for', connectString
print 'DEBUG: Environment variable', envKeyR, 'is not defined:',\
'will check replicas for', connectString
else:
print 'ERROR! You must set the environment variable %s'%(envKey)
print 'ERROR! Optionally you can set also %s'%(envKeyR)
......@@ -87,13 +88,21 @@ if __name__ == '__main__':
###if "LD_LIBRARY_PATH" in os.environ:
### print 'DEBUG: LD_LIBRARY_PATH =', os.environ["LD_LIBRARY_PATH"]
# Disable replica failover in CORAL to prevent silent test failures against
# CoralServer or Frontier when these are not available, otherwise the R/O
# test is executed succesfully against Oracle (CORALCOOL-2120). Disabling
# failover is a better fix than the older patch using CoolAuthentication,
# which was broken if COOLTESTDB_R is defined (CORALCOOL-2917).
app = cool.Application()
app.connectionSvc().configuration().disableReplicaFailOver()
# No need to check the R/W connection string (see below), use it as-is.
if 'ReferenceDbMgr' in dir():
###print 'Instantiate a', refSchemaVersion, 'reference database manager'
###print 'DEBUG: Instantiate a', refSchemaVersion, 'ref db manager'
mgr = ReferenceDbMgr( refSchemaVersion )
###print 'Drop database', connectString
###print 'DEBUG: Drop database', connectString
mgr.dropReferenceDb( connectString )
###print 'Create', refSchemaVersion, 'reference database', connectString
###print 'DEBUG: Create', refSchemaVersion, 'ref db', connectString
mgr.createReferenceDb( connectString )
# Stop here if there is nothing else to do
if 'TestReferenceDb1RO' not in dir() and 'TestReferenceDb1RW' not in dir() and 'TestReferenceDb2RO' not in dir():
......@@ -102,69 +111,63 @@ if __name__ == '__main__':
print "WARNING! No module was loaded, there is nothing to do"
sys.exit(0)
twoReplicas = False
# No need to check the R/W connection string. Check only the R/O connection
# string: if it is a Frontier or CoralServer connection, then grant Oracle
# reader privileges to public; in addition refresh the server cache if this
# is a Frontier server cache connection (i.e. port 8080, not port 8000).
import CoolAuthentication
propAny = CoolAuthentication.getDbIdProperties( connectString, False )
propRW = CoolAuthentication.getDbIdProperties( connectString, True )
replAny = CoolAuthentication.coralReplica( propAny )
replRW = CoolAuthentication.coralReplica( propRW )
connAny = CoolAuthentication.middleTier( propAny ) + CoolAuthentication.technology( propAny ) + '://' + CoolAuthentication.server( propAny ) + ";schema=" + CoolAuthentication.schema( propAny ) + ";dbname=" + CoolAuthentication.dbName( propAny )
connRW = CoolAuthentication.middleTier( propRW ) + CoolAuthentication.technology( propRW ) + '://' + CoolAuthentication.server( propRW ) + ";schema=" + CoolAuthentication.schema( propRW ) + ";dbname=" + CoolAuthentication.dbName( propRW )
print 'DEBUG: Lookup 1st replica (R/O test) and 1st RW replica (R/W test)'
print 'DEBUG: 1st replica:', replAny
print 'DEBUG: 1st R/W replica:', replRW
if replRW != replAny :
print 'DEBUG: 1st replica is not R/W:',\
'the R/O and R/W tests will use different replicas'
twoReplicas = True
if 'TestReferenceDb1RO' in dir() or 'TestReferenceDb2RO' in dir():
# Build the URL required by IWebCacheControl::refreshSchemaInfo
# - Determine the explicit frontier replica, and then either of:
# - Strip off the trailing schema
# - 1. 'frontier://(serverurl=)()/schema' => '(serverurl=)()'
# - 2. 'frontier://h:p/servlet/schema' => 'http://h:p/servlet'
webCacheUrl=replAny
if webCacheUrl.find('frontier') == 0 and \
webCacheUrl.find(':8000/') < 0:
print 'DEBUG: Frontier server replica: no cache to refresh'
elif webCacheUrl.find('frontier') == 0:
print 'DEBUG: Frontier cache replica: configure refresh'
# Strip off schema
if webCacheUrl.rfind('/') < 0:
print 'ERROR! Cannot strip schema off', webCacheUrl
sys.exit(-1)
webCacheUrl=webCacheUrl[:webCacheUrl.rfind('/')]
# 1: 'frontier://(serverurl=http://h:p/servlet)()/schema'
if webCacheUrl.find('frontier://(') == 0:
webCacheUrl=webCacheUrl[webCacheUrl.find('('):]
# 2: 'frontier://host:port/servlet/schema'
else:
webCacheUrl=webCacheUrl.replace('frontier','http',1)
if not noRefresh:
print 'DEBUG: Will refresh Frontier cache for', webCacheUrl
if 'TestReferenceDb1RO' in dir():
TestReferenceDb1RO.invalidateCacheUrl=webCacheUrl
if 'TestReferenceDb2RO' in dir():
TestReferenceDb2RO.invalidateCacheUrl=webCacheUrl
else:
print 'DEBUG: SKIP refresh Frontier cache for', webCacheUrl
else:
print 'DEBUG: Not a Frontier replica: no cache to refresh'
else :
print 'DEBUG: R/W replica is the 1st replica:',\
'the R/O and R/W tests will use the same replica'
propRO = CoolAuthentication.getDbIdProperties( connectStringR, False )
###print 'DEBUG: Properties of first replica (R/O test):', propRO # WARNING! THIS DUMPS PASSWORDS IN CLEAR TEXT!
replRO = CoolAuthentication.coralReplica( propRO )
print 'DEBUG: Looked up first replica (R/O test):', replRO
# Build the URL required by IWebCacheControl::refreshSchemaInfo
# - Determine the explicit frontier replica, and then either of:
# - Strip off the trailing schema
# - 1. 'frontier://(serverurl=)()/schema' => '(serverurl=)()'
# - 2. 'frontier://h:p/servlet/schema' => 'http://h:p/servlet'
if replRO.find('frontier') == 0 and replRO.find(':8000/') < 0:
print 'DEBUG: Frontier server replica: no cache to refresh'
elif replRO.find('frontier') == 0:
print 'DEBUG: Frontier cache replica: configure refresh'
webCacheUrl=replRO
# Strip off schema
if webCacheUrl.rfind('/') < 0:
print 'ERROR! Cannot strip schema off', webCacheUrl
sys.exit(-1)
webCacheUrl=webCacheUrl[:webCacheUrl.rfind('/')]
if webCacheUrl.find('frontier://(') == 0:
# 1: 'frontier://(serverurl=http://h:p/servlet)()/schema'
webCacheUrl=webCacheUrl[webCacheUrl.find('('):]
else:
# 2: 'frontier://host:port/servlet/schema'
webCacheUrl=webCacheUrl.replace('frontier','http',1)
print 'DEBUG: Will refresh Frontier cache for', webCacheUrl
TestReferenceDb1RO.invalidateCacheUrl=webCacheUrl
if 'TestReferenceDb2RO' in dir():
TestReferenceDb2RO.invalidateCacheUrl=webCacheUrl
else:
print 'DEBUG: Not a Frontier replica: no cache to refresh'
if twoReplicas:
print 'DEBUG: Grant READER privileges to public (needed by Frontier R/O tests)'
# If R/O replica is a Frontier or CoralServer connection,
# then grant Oracle reader privileges to public.
if replRO.find('frontier') == 0 or replRO.find('coral') == 0:
print 'DEBUG: Grant READER privs to public',\
'(for Frontier and CoralServer R/O tests)'
cmd = 'coolPrivileges "' # You may need to add .exe on Windows...
cmd = cmd + connectString + '" GRANT READER public'
print 'DEBUG: Execute:', cmd
f = os.popen( cmd )
line = f.readline()
if platform.system() == 'Darwin':
# Workaround for SIP on MacOSX (CORALCOOL-2884)
# Use own copy of /bin/bash instead of defult /bin/sh
f = Popen( cmd, stdout=PIPE, stderr=STDOUT, shell=True, executable="bash" )
else:
f = Popen( cmd, stdout=PIPE, stderr=STDOUT, shell=True )
line = f.stdout.readline()
while line :
if line.find("ERROR") == 0: print line.strip()
line = f.readline()
status = f.close()
line = f.stdout.readline()
status = f.wait()
if status : # Check coolPrivileges status (fix bug #83515)
print "ERROR! Command '" + cmd + "' failed! Status:", status
sys.exit(-1)
......@@ -172,15 +175,21 @@ if __name__ == '__main__':
TestReferenceDb1RW.grantPublicReader=True
if 'TestReferenceDb1RO' in dir():
TestReferenceDb1RO.connectString = connAny
print 'DEBUG: Execute 1RO tests against reference database'
print 'DEBUG: -> db ID:', connectStringR
TestReferenceDb1RO.connectString = connectStringR
TestReferenceDb1RO.refSchemaVersion = refSchemaVersion
if 'TestReferenceDb1RW' in dir():
TestReferenceDb1RW.connectString = connRW
print 'DEBUG: Execute 1RW tests against reference database'
print 'DEBUG: -> db ID:', connectString
TestReferenceDb1RW.connectString = connectString
TestReferenceDb1RW.refSchemaVersion = refSchemaVersion
if 'TestReferenceDb2RO' in dir():
TestReferenceDb2RO.connectString = connAny
print 'DEBUG: Execute 2RO tests against reference database'
print 'DEBUG: -> db ID:', connectStringR
TestReferenceDb2RO.connectString = connectStringR
TestReferenceDb2RO.refSchemaVersion = refSchemaVersion
###print 'DEBUG: Import unittest'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment