Commit 24045dd6 authored by Julien Muchembled's avatar Julien Muchembled

runUnitTest: add --dump_sql option and fix --live_instance

This splits --live_instance option so that it is possible to only disable
load/save SQL dumps: --live_instance automatically set --dump_sql=0

Also fix saving static files when --live_instance is used.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36452 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f250fc3f
......@@ -32,10 +32,9 @@ data_fs_path = os.environ.get('erp5_tests_data_fs_path',
os.path.join(instance_home, 'Data.fs'))
load = int(os.environ.get('erp5_load_data_fs', 0))
save = int(os.environ.get('erp5_save_data_fs', 0))
live_instance_path = os.environ.get('live_instance_path', None)
save_mysql = int(os.environ.get('erp5_dump_sql') or not zeo_client) or None
save_mysql = None
if not zeo_client and live_instance_path is None:
if save_mysql:
def save_mysql(verbosity=1):
# The output of mysqldump needs to merge many lines at a time
# for performance reasons (merging lines is at most 10 times
......@@ -61,9 +60,10 @@ if load:
_print("Could not find MySQL dump, will recreate catalog ... ")
os.environ['erp5_tests_recreate_catalog'] = '1'
_print("Restoring static files ... ")
live_instance_path = os.environ.get('live_instance_path')
for dir in static_dir_list:
full_path = os.path.join(instance_home, dir)
if live_instance_path is not None:
if live_instance_path:
backup_path = os.path.join(live_instance_path, dir)
else:
backup_path = full_path + '.bak'
......
......@@ -28,16 +28,15 @@ Options:
--data_fs_path to run tests on an existing
Data.fs
--data_fs_path=STRING Use the given path for the Data.fs
--live_instance=[STRING]
Use Data.fs, Document, PropertySheet, Constraint
from a live instance. This is very usefull in order
--live_instance=[STRING] Use Data.fs, Document, PropertySheet, Constraint
from a live instance. This is very useful in order
to try quickly a test without having to rebuild
testing data. This could be totally unsafe for you
testing data. This could be totally unsafe for your
instance, this depends if the test destroy existing
data or not.
STRING could be used to define the path of real
instance
It enable --save --load --data_fs_path
instance. It automatically enables:
--save --load --dump_sql=0 --data_fs_path=...
--bt5_path Search for Business Templates in the given list of
paths (or any HTTP url supported by template tool),
delimited with commas. In particular, BT can be
......@@ -45,7 +44,7 @@ Options:
using a url like:
http://.../erp5/portal_templates/asRepository
Default is INSTANCE_HOME/bt5 and its subfolders.
--recreate_catalog=0 or 1 recreate the content of the sql catalog. Default
--recreate_catalog={0|1} Recreate the content of the SQL catalog. Default
is to recreate, unless using --data_fs_path
--save Run unit tests in persistent mode (if unset,
existing Data.fs, dump.sql and *.bak static
......@@ -53,6 +52,9 @@ Options:
if business templates are updated
or if --load is unset.
--load Reuse existing instance (created with --save).
--dump_sql=[0|1] Force enabling/disabling SQL dumps.
By default, databases are loaded/saved except
when running ZEO clients.
--erp5_sql_connection_string=STRING
ZSQL Connection string for erp5_sql_connection, by
default, it will use "test test"
......@@ -561,13 +563,18 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
# be done manually.
if verbosity:
_print('Dumping static files...\n')
live_instance_path = os.environ.get('live_instance_path')
for static_dir in static_dir_list:
try:
shutil.rmtree(static_dir + '.bak')
except OSError, e:
if e.errno != errno.ENOENT:
raise
shutil.copytree(static_dir, static_dir + '.bak', symlinks=True)
if live_instance_path:
backup_path = os.path.join(live_instance_path, static_dir)
else:
backup_path = static_dir + '.bak'
shutil.copytree(static_dir, backup_path, symlinks=True)
elif zeo_client_pid_list is not None:
_print('WARNING: No static files saved. You will have to do it manually.')
......@@ -593,6 +600,7 @@ def main():
"erp5_catalog_storage=",
"save",
"load",
"dump_sql=",
"email_from_address=",
"enable_full_indexing=",
"run_only=",
......@@ -656,6 +664,8 @@ def main():
os.environ["erp5_save_data_fs"] = "1"
elif opt == "--load":
os.environ["erp5_load_data_fs"] = "1"
elif opt == "--dump_sql":
os.environ["erp5_dump_sql"] = arg
elif opt == "--erp5_catalog_storage":
os.environ["erp5_catalog_storage"] = arg
elif opt == "--run_only":
......@@ -672,9 +682,11 @@ def main():
os.environ["conversion_server_port"] = arg
elif opt == "--live_instance":
live_instance_path = arg or real_instance_home
# following line is only for static files
os.environ["live_instance_path"] = live_instance_path
os.environ["erp5_load_data_fs"] = "1"
os.environ["erp5_save_data_fs"] = "1"
os.environ["erp5_dump_sql"] = "0"
os.environ["erp5_tests_data_fs_path"] = os.path.join(
live_instance_path, 'var', 'Data.fs')
elif opt == "--use_dummy_mail_host":
......
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