Commit eef70a1b authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Drop COOL schema evolution tests (CORALCOOL-2935)


git-svn-id: file:///git/lcgcool.svndb/cool/trunk@20123 4525493e-7705-40b1-a816-d608a930855b
parent 46183bcc
......@@ -853,351 +853,3 @@ class SourceTargetTest(DatabaseTest):
result[result.CAUSE] = str(x)
self.DumpEnvironment(result)
class EvolutionTest(DatabaseTest):
""" This class extends COOLTest to use two databases instead of one.
"""
# extra arguments
arguments = [
qm.fields.EnumerationField( name = "original",
title = "Original version",
default_value = "1.3.0",
enumerals = ["1.3.0"],
description = """The version of the schema to start from""" )
]
_versions = { "1.3.0" : ("COOL_1_3_4","LCGCMT_49"),
"2.0.0" : ("COOL_2_1_1","LCGCMT_52a"),
}
def PrepareTmpPackage(self,destdir,env):
import stat
# copy relevant python modules to the temporary directory
cool_current_dir = env["COOLSYS"]
for f in ["CoolAuthentication","CoolDescribeTable","PyCoolReferenceDb","CoolQueryManager"]:
if os.path.isdir(os.path.join(cool_current_dir,'python',f)):
shutil.copytree(os.path.join(cool_current_dir,'python',f),os.path.join(destdir,f))
else:
shutil.copyfile(os.path.join(cool_current_dir,'python',f),os.path.join(destdir,f))
# produce more sensible error messages for bug #32362
if os.path.exists(os.path.join(destdir,f,"__init__.pyc")):
os.remove(os.path.join(destdir,f,"__init__.pyc"))
# prepare the requirements file
open(os.path.join(destdir,"requirements"),"w").write("""
# This is us
use COOL v* LCG_Interfaces
apply_tag NEEDS_COOL_FACTORY
apply_tag NEEDS_PYCOOL
# runtime-only dependencies
use Reflex v* LCG_Interfaces
use oracle v* LCG_Interfaces
use mysql v* LCG_Interfaces
use sqlite v* LCG_Interfaces
use Frontier_Client v* LCG_Interfaces
# special runtime dependencies
use Python v* LCG_Interfaces
use XercesC v* LCG_Interfaces
use CppUnit v* LCG_Interfaces
# remove the current version from the environment
path_remove PATH '%(COOLSYS)s'
path_remove LD_LIBRARY_PATH '%(COOLSYS)s' WIN32 ''
path_remove PYTHONPATH '%(COOLSYS)s'
# SEAL quiet assert (needed for COOL134 and COOL211)
set QUIET_ASSERT yes
# SEAL configuration file (needed for COOL134 and COOL211)
set SEAL_CONFIGURATION_FILE $(COOL_base)/src/RelationalCool/tests/seal.opts.error
# add the stand-alone package to pythonpath
path_prepend PYTHONPATH '.'
"""%env)
create_script = os.path.join(env["COOLSYS"],'tests','bin',
'Regression','createReferenceDb.py')
# prepare the wrapper script(s)
# [NB disable rmtree(tempdir) if you want to look at the files!]
if sys.platform.startswith("win"):
open(os.path.join(destdir,"create.bat"),"w").write("""
@echo off
cd
set CMTSITE=CERN
echo CMTSITE = %%CMTSITE%%
set SITEROOT=%%AFS%%\cern.ch
echo SITEROOT = %%SITEROOT%%
echo CMTPROJECTPATH = %%CMTPROJECTPATH%%
echo CMTPATH = %%CMTPATH%%
echo CMTCONFIG = %%CMTCONFIG%%
echo CMTROOT = %%CMTROOT%%
cmt show tags
cmt show set PYTHONPATH
cmt show macro COOL_home
cmt show macro_value COOL_home
cmt show macro ROOT_home
cmt show macro_value ROOT_home
cmt show macro COOL_base
cmt show macro_value COOL_base
cmt show macro ROOT_base
cmt show macro_value ROOT_base
cmt show macro LCG_releases
cmt show macro_value LCG_releases
cmt show macro LCG_external
cmt show macro_value LCG_external
cmt show macro LCG_home
cmt show macro_value LCG_home
cmt show macro LCG_platform
cmt show macro_value LCG_platform
cmt show macro LCG_system
cmt show macro_value LCG_system
cmt -tag_add=debug show macro LCG_platform
cmt -tag_add=debug show macro_value LCG_platform
cmt -tag_add=debug show macro LCG_system
cmt -tag_add=debug show macro_value LCG_system
cmt -tag_add=debug run set
set
cmt -tag_add=debug run python %s %%COOLTESTDB%% %%SCHEMA_VERSION%%
"""%create_script)
open(os.path.join(destdir,"evolve.bat"),"w").write("""
@echo off
echo CMTPATH = %CMTPATH%
echo CMTCONFIG = %CMTCONFIG%
cmt run coolEvolveSchema %COOLTESTDB%
""")
else:
open(os.path.join(destdir,"create.sh"),"w").write("""
pwd
echo CMTPROJECTPATH = $CMTPROJECTPATH
echo CMTPATH = $CMTPATH
echo CMTCONFIG = $CMTCONFIG
echo CMTUSERCONTEXT = $CMTUSERCONTEXT
cmt show tags
cmt show set PYTHONPATH
cmt show macro COOL_home
cmt show macro_value COOL_home
cmt show macro ROOT_home
cmt show macro_value ROOT_home
cmt show macro COOL_base
cmt show macro_value COOL_base
cmt show macro ROOT_base
cmt show macro_value ROOT_base
cmt show macro LCG_releases
cmt show macro_value LCG_releases
cmt show macro LCG_external
cmt show macro_value LCG_external
cmt show macro LCG_home
cmt show macro_value LCG_home
cmt show macro LCG_platform
cmt show macro_value LCG_platform
cmt show macro LCG_system
cmt show macro_value LCG_system
echo SITEROOT = $SITEROOT
cmt run "python %s '${COOLTESTDB}' '${SCHEMA_VERSION}'"
"""%create_script)
open(os.path.join(destdir,"evolve.sh"),"w").write("""
echo CMTPATH = $CMTPATH
echo CMTCONFIG = $CMTCONFIG
cmt run "coolEvolveSchema '${COOLTESTDB}'"
""")
os.chmod(os.path.join(destdir,"create.sh"),stat.S_IRWXU)
os.chmod(os.path.join(destdir,"evolve.sh"),stat.S_IRWXU)
def PrepareCOOLEnvironment(self,schema_version,env):
# copy the environment in a new dictionary
newEnv = {}
for k,v in env.items():
if type(v) is str:
# avoid the copy of the value if it is a string
newEnv[k] = v
else:
# sometimes, on win32, the environment variables are unicode
# and Popen does not like them.
newEnv[k] = str(v)
# [TODO: set LCGRELEASES $(LCG_releases) if you enable evolution tests?]
# in the nightlies, the LCGRELEASES env variable is pointing to the
# nightly directory, so we cannot find the old version of COOL
pos = newEnv["LCGRELEASES"].find("nightlies")
if pos >= 0 :
# If we are in the nightlies, use the "official" releases
newEnv["LCGRELEASES"] = newEnv["LCGRELEASES"][0:pos] + "releases"
# get COOL reference version and LCGCMT version for a given
# schema version
cool_version, lcgcmt_version = self._versions[schema_version]
lcgcmt_dir = os.path.join(env["LCGRELEASES"],"LCGCMT",lcgcmt_version)
if not os.path.isdir(lcgcmt_dir):
# Non-portable work-around, needed to test schema evolution in the
# nightlies, where LCGRELEASES points to the build directory.
if not sys.platform.startswith("win"):
lcgcmt_dir = "/afs/cern.ch/sw/lcg/app/releases/LCGCMT/"+lcgcmt_version
else:
# Fix for bug #32362 - will this work even without backslashes?
lcgcmt_dir = str(newEnv["AFS"])+"cern.ch/sw/lcg/app/releases/LCGCMT/"+lcgcmt_version
# modify the environment
newEnv["CMTPATH"] = str(lcgcmt_dir)
newEnv["SCHEMA_VERSION"] = str(schema_version)
newEnv["CMTCONFIG"] = str(self.GetPlatform())
# the script to generate the reference DB cannot be run with
# old COOL on AMD64
# @todo: The check on the version should be more "precise"
if schema_version < "2.0.0" and "amd64" in newEnv["CMTCONFIG"]:
newEnv["CMTCONFIG"] = newEnv["CMTCONFIG"].replace("amd64","ia32")
if "CMTPROJECTPATH" in newEnv: del newEnv["CMTPROJECTPATH"]
# Ignore PYTHONPATH to avoid version mismatches (bug #32406)
if "PYTHONPATH" in newEnv:
del newEnv["PYTHONPATH"]
# Ignore CMTUSERCONTEXT if set (bug #28554)
if "CMTUSERCONTEXT" in newEnv:
del newEnv["CMTUSERCONTEXT"]
# Disable the ROOT signal handler during evolution tests (bug #54926)
if "LD_PRELOAD" in newEnv:
del newEnv["LD_PRELOAD"]
# Fix SITEROOT for the nightlies on Windows (bug #32362)
# NO! (1) - Only do this inside the create.bat script
# NO! (2) - Inside create.bat, use "E:/cern.ch"
# (but be careful that it works outside the nightlies too!)
#siteroot = newEnv["SITEROOT"]
#if siteroot.startswith("C:") or siteroot.startswith("c:"):
# siteroot = "E:/cern.ch/sw"
# newEnv["SITEROOT"] = str(siteroot)
return newEnv
def CreateReferenceDB(self,env):
if sys.platform.startswith("win"):
create_cmd = ["create.bat"]
evolve_cmd = ["evolve.bat"]
else:
create_cmd = ["./create.sh"]
evolve_cmd = ["./evolve.sh"]
tempdir = tempfile.mkdtemp()
output = ""
try:
self.PrepareTmpPackage(tempdir,env)
# create original DB
output += ('*** POPEN START ' + create_cmd[0] + ' ***\n')
localEnv = self.PrepareCOOLEnvironment(self.original,env)
p = Popen(create_cmd,env=localEnv,cwd=tempdir,shell=True,
stdout=PIPE,stderr=STDOUT)
output += p.stdout.read()
retcode = p.wait()
output += ('*** POPEN DONE: ' + create_cmd[0] + ' ***\n')
doEvolve = True
if "COOL_QMTEST_SKIPEVOLVE" in env :
output += ('*** POPEN SKIP coolEvolveSchema ***\n')
doEvolve = False
if doEvolve :
# @todo: intermediate evolution steps
#output += ('*** POPEN START ' + evolve_cmd + ' ***\n')
#p = Popen(evolve_cmd,env=localEnv,stdout=PIPE,stderr=STDOUT)
#output += p.stdout.read()
#retcode = p.wait()
#output += ('*** POPEN DONE: ' + evolve_cmd + ' ***\n')
output += ('*** POPEN START coolEvolveSchema ***\n')
p = Popen(["coolEvolveSchema",env["COOLTESTDB"]],
stdout=PIPE,stderr=STDOUT)
output += p.stdout.read()
retcode = p.wait()
output += ('*** POPEN DONE: coolEvolveSchema ***\n')
finally:
# clean up the temporary working directory
shutil.rmtree(tempdir,ignore_errors=True)
pass # Strictly needed only if you comment out rmtree...
return output
def Run(self, context, result):
"""Prepare the environment for the test and run it."""
# check if the test can be run on the current platform
if not self.SupportedPlatform(context, result):
return
env = TemporaryEnvironment()
try:
self.PrepareEnv(env)
db = DBPreparer(self.package_name,self.db_type,self.DBName(),env,"COOLTESTDB")
result['ExecTest.stdout'] = db.DropDB()
except CoolTestError,x:
result.SetOutcome(result.ERROR)
result[result.CAUSE] = str(x)
self.DumpEnvironment(result)
return
result['COOLTest.initial_version'] = self.original
try:
creation_output = self.CreateReferenceDB(env)
except Exception,x:
result.SetOutcome(result.ERROR)
result[result.CAUSE] = str(x)
self.DumpEnvironment(result)
return
result['COOLTest.reference_stdout'] = '<pre>' + creation_output + '\n</pre>\n'
result['COOLTest.connection_string'] = db.ConnectionString()
if "COOL_QMTEST_SKIPEVOLVE" in env :
return
# check that the database is created with the right version of COOL
m = re.search('Database service loaded from software release ([0-9]*\.[0-9]*\.[0-9])',
creation_output)
if m :
if ( 'COOL_' + m.group(1).replace('.','_') ) != self._versions[self.original][0] :
result.SetOutcome(result.ERROR)
result[result.CAUSE] = 'Bad reference DB.'
self.DumpEnvironment(result)
return
else:
result.SetOutcome(result.ERROR)
result[result.CAUSE] = 'Bad reference DB.'
self.DumpEnvironment(result)
return
# check that the evolution was successful
if creation_output.find("ERROR") >= 0:
result.SetOutcome(result.ERROR)
result[result.CAUSE] = 'Evolution step failed.'
self.DumpEnvironment(result)
return
# Ignore the command, which is not meaningful
orig_cmd = self.command
script = os.path.join(env["COOLSYS"],'tests','bin',
'Regression','testReferenceDbAll.py')
cmd_variable = "${COOLTESTDB}"
if sys.platform.startswith("win"):
cmd_variable = "%COOLTESTDB%"
## Not needed any more (task #3442)
##if self.db_type == "Frontier":
## cmd_variable = cmd_variable.replace("COOLTESTDB","COOLTESTDB_R")
self.command = 'python %s %s %s' % ( script, cmd_variable, self.original )
StandardTest.Run(self,context,result)
self.command = orig_cmd
result['ExecTest.stdout'] += db.DropDB()
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>600</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.mysql.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>MySQL</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>1.3.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>600</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.mysql.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>MySQL</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>2.0.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>1860</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.oracle.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>Oracle</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>1.3.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>1860</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.oracle.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>Oracle</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>2.0.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>180</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.sqlite.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>SQLite</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>1.3.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="COOLTests.EvolutionTest" kind="test">
<argument name="stdin"><text/></argument>
<argument name="timeout"><integer>180</integer></argument>
<argument name="stdout"><text/></argument>
<argument name="prerequisites"><set>
<tuple><text>pycool.import_pycool</text><enumeral>PASS</enumeral></tuple>
<!-- <tuple><text>pycoolutilities.sqlite.regression</text><enumeral>PASS</enumeral></tuple> -->
</set></argument>
<argument name="target_group"><text>.*</text></argument>
<argument name="exit_code"><integer>0</integer></argument>
<argument name="environment"><set/></argument>
<argument name="command"><text/></argument>
<argument name="stderr"><text/></argument>
<argument name="resources"><set/></argument>
<argument name="db_type"><enumeral>SQLite</enumeral></argument>
<argument name="package_name"><enumeral>PyCoolUtilities</enumeral></argument>
<argument name="original"><enumeral>2.0.0</enumeral></argument>
<!--argument name="unsupported_platforms"><text>gcc43,slc5,slc6,cc7,centos7,osx,mac,win</text></argument-->
<argument name="unsupported_platforms"><text>.*</text></argument>
</extension>
......@@ -39,7 +39,7 @@ if [ "$1" = "" ]; then
###theTests=relationalcool.mysql.raldatabasesvc
###theTests=relationalcool.sqlite.raldatabasesvc
###theTests=pycool.import_pycool
###theTests=pycoolutilities.sqlite.evolution_130
###theTests=pycoolutilities.sqlite.regression
###theTests=pycoolutilities.frontier
else
theTests=""
......
<?xml version="1.0" ?>
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="explicit_suite.ExplicitSuite" kind="suite">
<argument name="suite_ids"><set>
<text>regression</text>
</set></argument>
<argument name="test_ids"><set>
<text>pycoolutilities.mysql.evolution_130</text>
<text>pycoolutilities.mysql.evolution_200</text>
<text>pycoolutilities.oracle.evolution_130</text>
<text>pycoolutilities.oracle.evolution_200</text>
<text>pycoolutilities.sqlite.evolution_130</text>
<text>pycoolutilities.sqlite.evolution_200</text>
</set></argument>
</extension>
Markdown is supported
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