Commit 7a0a8183 authored by Vincent Pelletier's avatar Vincent Pelletier

Add support for simultaneously providing --save and --load to runUnitTest.py.

Add --update_business_templates support. This, used in conjunction of --load will force all business templates to be updated with filesystem-available versions. Also invoking with --save will cause updated site to be saved for future use.
Do not use objectIds to get the list of installed business template, but getInstalledBusinessTemplateList.
This allows to not specify the business template id at installation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19331 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 99f3e6bb
......@@ -301,8 +301,16 @@ class ERP5TypeTestCase(PortalTestCase):
INSTANCE_HOME = os.environ['INSTANCE_HOME']
bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(INSTANCE_HOME, 'bt5'))
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path',
os.path.join(INSTANCE_HOME, 'Products/ERP5/bootstrap'))
template_list = self.getBusinessTemplateList()
erp5_catalog_storage = os.environ.get('erp5_catalog_storage',
'erp5_mysql_innodb_catalog')
update_business_templates = os.environ.get('update_business_templates') is not None
erp5_load_data_fs = os.environ.get('erp5_load_data_fs') is not None
if update_business_templates and erp5_load_data_fs:
template_list = ('erp5_core', 'erp5_xhtml_style', erp5_catalog_storage) + tuple(template_list)
new_template_list = []
for template in template_list:
id = template.split('/')[-1]
......@@ -311,8 +319,11 @@ class ERP5TypeTestCase(PortalTestCase):
except IOError :
# First, try the bt5 directory itself.
path = os.path.join(bt5_path, template)
alternate_path = os.path.join(bootstrap_path, template)
if os.path.exists(path):
template = path
elif os.path.exists(alternate_path):
template = alternate_path
else:
path = '%s.bt5' % path
if os.path.exists(path):
......@@ -340,8 +351,6 @@ class ERP5TypeTestCase(PortalTestCase):
light_install = self.enableLightInstall()
create_activities = self.enableActivityTool()
hot_reindexing = self.enableHotReindexing()
erp5_catalog_storage = os.environ.get('erp5_catalog_storage',
'erp5_mysql_innodb_catalog')
setupERP5Site(business_template_list=new_template_list,
light_install=light_install,
portal_name=self.getPortalName(),
......@@ -635,16 +644,23 @@ def setupERP5Site( business_template_list=(),
for id_ in getLocalConstraintList():
removeLocalConstraint(id_)
update_business_templates = os.environ.get('update_business_templates') is not None
# Disable reindexing before adding templates
# VERY IMPORTANT: Add some business templates
for url, id_ in business_template_list:
for url, title in business_template_list:
start = time.time()
if id_ in portal.portal_templates.objectIds():
if title in [x.getTitle() for x in portal.portal_templates.getInstalledBusinessTemplateList()]:
if update_business_templates:
if not quiet:
ZopeTestCase._print('Updating %s business template ... ' % title)
else:
continue
else:
if not quiet:
ZopeTestCase._print('Adding %s business template ... ' % id_)
portal.portal_templates.download(url, id=id_)
portal.portal_templates[id_].install(light_install=light_install)
ZopeTestCase._print('Adding %s business template ... ' % title)
bt = portal.portal_templates.download(url)
bt.install(light_install=light_install)
# Release locks
get_transaction().commit()
if not quiet:
......
......@@ -8,11 +8,7 @@ instance_home = os.environ.get('INSTANCE_HOME')
data_fs_path = os.environ.get('erp5_tests_data_fs_path')
new_data_fs_path = os.path.join(instance_home, 'Data.fs')
if os.environ.get('erp5_save_data_fs'):
if os.path.exists(new_data_fs_path):
os.remove(new_data_fs_path)
Storage = FileStorage(new_data_fs_path)
elif os.environ.get('erp5_load_data_fs'):
if os.environ.get('erp5_load_data_fs'):
if os.environ.get('erp5_force_data_fs'):
Storage = FileStorage(new_data_fs_path)
else:
......@@ -24,6 +20,10 @@ elif os.environ.get('erp5_load_data_fs'):
if os.path.exists('%s/%s.bak' % (instance_home, dir)):
os.system('rm -rf %s/%s' % (instance_home, dir))
os.system('cp -ar %s/%s.bak %s/%s' % (instance_home, dir, instance_home, dir))
elif os.environ.get('erp5_save_data_fs'):
if os.path.exists(new_data_fs_path):
os.remove(new_data_fs_path)
Storage = FileStorage(new_data_fs_path)
elif data_fs_path:
Storage = DemoStorage(base=FileStorage(data_fs_path), quota=(1<<20))
else:
......
......@@ -60,6 +60,10 @@ Options:
expressions.
-D
Invoke debugger on errors / failures.
--update_business_templates
Update all business templates prior to runing
tests. This only has a meaning when doing
upgratability checks, in conjunction with --load.
"""
def getUnitTestFile():
......@@ -129,6 +133,8 @@ elif os.path.isdir('/usr/lib/erp5/lib/python'):
else:
software_home = '/usr/lib/zope/lib/python'
zope_home = '/usr/lib/zope'
zope_home = '/home/vincent/bin/zope2.8'
software_home = '%s/lib/python' % (zope_home, )
# handle 'system global' instance and windows
if WIN:
real_instance_home = os.path.join(erp5_home, 'ERP5Instance')
......@@ -337,7 +343,8 @@ def main():
"save",
"load",
"email_from_address=",
"run_only="] )
"run_only=",
"update_business_templates"] )
except getopt.GetoptError, msg:
usage(sys.stderr, msg)
sys.exit(2)
......@@ -348,6 +355,8 @@ def main():
os.environ["erp5_tests_recreate_catalog"] = "0"
verbosity = 1
debug = 0
load = False
save = False
for opt, arg in opts:
if opt in ("-v", "--verbose"):
......@@ -385,12 +394,19 @@ def main():
os.environ["email_from_address"] = arg
elif opt == "--save":
os.environ["erp5_save_data_fs"] = "1"
save = True
elif opt == "--load":
os.environ["erp5_load_data_fs"] = "1"
load = True
elif opt == "--erp5_catalog_storage":
os.environ["erp5_catalog_storage"] = arg
elif opt == "--run_only":
os.environ["run_only"] = arg
elif opt == "--update_business_templates":
os.environ["update_business_templates"] = "1"
if load and save:
os.environ["erp5_force_data_fs"] = "1"
test_list = args
if not test_list:
......
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