[libvirt] [test-API PATCH 0/3] make clean function optional

The set of patches is to make the writing of clean function optional. If a testcase which doesn't dirty the testing environment, then the TESTCASE_clean function could be optional or omitted. Because loggers in python are static objects managed by the module itself. When you create one, it won't be removed until the shell quit. In test-API there are two loggers which are configured with two handlers for each. we need to find a way to destruct these two loggers in order no to affect other application. The idea is to clear the handlers of each logger in destructor of CaseLog and EnvLog. def __del__(self): self.logger.handlers = [] rename some unclear function and variables. for example: repos/domain/start.py domain -> mod start.py -> case start() -> func

The patch make the writing of clean function optional If a testcase makes testing environment dirty after running, it must write a CASENAME_clean function to restore back the testing environment, otherwise, the clean function could be omitted --- env_clear.py | 9 ++++----- proxy.py | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/env_clear.py b/env_clear.py index 3efc9be..2e5bcf5 100644 --- a/env_clear.py +++ b/env_clear.py @@ -30,7 +30,7 @@ class EnvClear(object): self.loglevel = loglevel mapper_obj = mapper.Mapper(activity) - clean_pkg_casename_func = mapper_obj.clean_package_casename_func_map() + clean_pkg_casename_func = mapper_obj.module_casename_cleanfunc_map() self.cases_ref_names = [] for case in clean_pkg_casename_func: @@ -47,7 +47,7 @@ class EnvClear(object): return retflag def env_clear(self): - """ Run each clearing function with the corresponding arguments """ + """ Run each clean function with the corresponding arguments """ envlog = log.EnvLog(self.logfile, self.loglevel) logger = envlog.env_log() @@ -60,8 +60,7 @@ class EnvClear(object): case_params = self.cases_params_list[i] case_params['logger'] = logger - self.cases_clearfunc_ref_dict[case_ref_name](case_params) - - del envlog + if self.cases_clearfunc_ref_dict.has_key(case_ref_name): + self.cases_clearfunc_ref_dict[case_ref_name](case_params) return 0 diff --git a/proxy.py b/proxy.py index 3c4cd63..fdbffd9 100644 --- a/proxy.py +++ b/proxy.py @@ -85,12 +85,13 @@ class Proxy(object): var_func_names = dir(casemod_ref) key = module + ':' + casename + ':' + func + + # the clean function is optional, we get its reference + # only if it exists in testcases if func in var_func_names: func_ref = getattr(casemod_ref, func) func_dict[key] = func_ref - else: - raise exception.TestCaseError("clean function not found in %s" % \ - (func, testcase_name)) + return func_dict def get_params_variables(self): -- 1.7.7.5

s/cleanup:make/cleanup: Make/ On 2012年04月16日 14:11, Guannan Ren wrote:
The patch make the writing of clean function optional If a testcase makes testing environment dirty after running, it
If a case dirties the testing environment,
must write a CASENAME_clean function to restore back the
Could the $CASENAME_ be omitted? IIRC, the scripts under repos are imported by framework when executing. And thus we can invoke the cleanup functions by $script_name.cleanup.
testing environment, otherwise, the clean function could be omitted --- env_clear.py | 9 ++++----- proxy.py | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/env_clear.py b/env_clear.py index 3efc9be..2e5bcf5 100644 --- a/env_clear.py +++ b/env_clear.py @@ -30,7 +30,7 @@ class EnvClear(object): self.loglevel = loglevel
mapper_obj = mapper.Mapper(activity) - clean_pkg_casename_func = mapper_obj.clean_package_casename_func_map() + clean_pkg_casename_func = mapper_obj.module_casename_cleanfunc_map()
self.cases_ref_names = [] for case in clean_pkg_casename_func: @@ -47,7 +47,7 @@ class EnvClear(object): return retflag
def env_clear(self): - """ Run each clearing function with the corresponding arguments """ + """ Run each clean function with the corresponding arguments """
envlog = log.EnvLog(self.logfile, self.loglevel) logger = envlog.env_log() @@ -60,8 +60,7 @@ class EnvClear(object): case_params = self.cases_params_list[i]
case_params['logger'] = logger - self.cases_clearfunc_ref_dict[case_ref_name](case_params) - - del envlog + if self.cases_clearfunc_ref_dict.has_key(case_ref_name):
To be consistent, "clear" should be "clean".
+ self.cases_clearfunc_ref_dict[case_ref_name](case_params)
return 0 diff --git a/proxy.py b/proxy.py index 3c4cd63..fdbffd9 100644 --- a/proxy.py +++ b/proxy.py @@ -85,12 +85,13 @@ class Proxy(object): var_func_names = dir(casemod_ref)
key = module + ':' + casename + ':' + func + + # the clean function is optional, we get its reference + # only if it exists in testcases
s/testcases/test cases/, or "cases" is enough, we should have a consistent term across the project, but not different from here and there.
if func in var_func_names: func_ref = getattr(casemod_ref, func) func_dict[key] = func_ref - else: - raise exception.TestCaseError("clean function not found in %s" % \ - (func, testcase_name)) + return func_dict
def get_params_variables(self):

On 04/16/2012 02:34 PM, Osier Yang wrote:
s/cleanup:make/cleanup: Make/
On 2012年04月16日 14:11, Guannan Ren wrote:
The patch make the writing of clean function optional If a testcase makes testing environment dirty after running, it
If a case dirties the testing environment,
must write a CASENAME_clean function to restore back the
Could the $CASENAME_ be omitted? IIRC, the scripts under repos are imported by framework when executing. And thus we can invoke the cleanup functions by $script_name.cleanup.
If we add clean flag after testcase in config file like this, the framework will invoke the testa_clean() after running the testa() in testa.py Note: we only add the clean for testcase which has _clean function in it. ... test:testa options value1 clean ...
testing environment, otherwise, the clean function could be omitted --- env_clear.py | 9 ++++----- proxy.py | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/env_clear.py b/env_clear.py index 3efc9be..2e5bcf5 100644 --- a/env_clear.py +++ b/env_clear.py @@ -30,7 +30,7 @@ class EnvClear(object): self.loglevel = loglevel
mapper_obj = mapper.Mapper(activity) - clean_pkg_casename_func = mapper_obj.clean_package_casename_func_map() + clean_pkg_casename_func = mapper_obj.module_casename_cleanfunc_map()
self.cases_ref_names = [] for case in clean_pkg_casename_func: @@ -47,7 +47,7 @@ class EnvClear(object): return retflag
def env_clear(self): - """ Run each clearing function with the corresponding arguments """ + """ Run each clean function with the corresponding arguments """
envlog = log.EnvLog(self.logfile, self.loglevel) logger = envlog.env_log() @@ -60,8 +60,7 @@ class EnvClear(object): case_params = self.cases_params_list[i]
case_params['logger'] = logger - self.cases_clearfunc_ref_dict[case_ref_name](case_params) - - del envlog + if self.cases_clearfunc_ref_dict.has_key(case_ref_name):
To be consistent, "clear" should be "clean".
+ self.cases_clearfunc_ref_dict[case_ref_name](case_params)
return 0 diff --git a/proxy.py b/proxy.py index 3c4cd63..fdbffd9 100644 --- a/proxy.py +++ b/proxy.py @@ -85,12 +85,13 @@ class Proxy(object): var_func_names = dir(casemod_ref)
key = module + ':' + casename + ':' + func + + # the clean function is optional, we get its reference + # only if it exists in testcases
s/testcases/test cases/, or "cases" is enough, we should have a consistent term across the project, but not different from here and there.
if func in var_func_names: func_ref = getattr(casemod_ref, func) func_dict[key] = func_ref - else: - raise exception.TestCaseError("clean function not found in %s" % \ - (func, testcase_name)) + return func_dict
def get_params_variables(self):
Thanks for the review. I will push it after these problems fixed. Guannan Ren

generator.py libvirt-test-api.py mapper.py utils/log.py: add __del__() to destruct logger handlers when it go out of context --- generator.py | 2 +- libvirt-test-api.py | 1 + mapper.py | 14 +++++++++----- utils/log.py | 6 ++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/generator.py b/generator.py index 0c3aec4..62b0d66 100644 --- a/generator.py +++ b/generator.py @@ -61,7 +61,7 @@ class FuncGen(object): self.env = env_parser.Envparser("env.cfg") mapper_obj = mapper.Mapper(activity) - pkg_casename_func = mapper_obj.package_casename_func_map() + pkg_casename_func = mapper_obj.module_casename_func_map() for test_procedure in pkg_casename_func: log_xml_parser.add_testprocedure_xml(testrunid, diff --git a/libvirt-test-api.py b/libvirt-test-api.py index 877104c..c171276 100644 --- a/libvirt-test-api.py +++ b/libvirt-test-api.py @@ -205,6 +205,7 @@ class Main(object): logname = log.Log.get_log_name() logfile = os.path.join('log/%s' % testrunid, logname) env_clear.EnvClear(cases_clearfunc_ref_dict, activity, logfile, self.loglevel)() + print "Done" elif options_list[0]['options']["cleanup"] == "disable": pass else: diff --git a/mapper.py b/mapper.py index f0b675a..c2c44da 100644 --- a/mapper.py +++ b/mapper.py @@ -22,10 +22,12 @@ import copy class Mapper(object): def __init__(self, testcases_list): - self.testcases_list = copy.deepcopy(testcases_list) + self.testcases_list = testcases_list - def package_casename_func_map(self): - """ Remove the package information to form a new dictionary """ + def module_casename_func_map(self): + """ generate a new list of dictionary + change key from module:casename to module:casename:func + """ tripped_cases_list = [] prev_testcasename = '' prev_testcases_params = '' @@ -56,8 +58,10 @@ class Mapper(object): return tripped_cases_list - def clean_package_casename_func_map(self): - """get testcase function maping without cleaning ones """ + def module_casename_cleanfunc_map(self): + """generate a new data format + keys of dictionay are of module:casename:casename_clean + """ tripped_cases_list = [] for testcase in self.testcases_list: tripped_case = {} diff --git a/utils/log.py b/utils/log.py index bd6f816..b146956 100644 --- a/utils/log.py +++ b/utils/log.py @@ -56,6 +56,9 @@ class CaseLog(Log): self.logger.setLevel(logging.DEBUG) super(CaseLog, self).__init__(logname, loglevel) + def __del__(self): + self.logger.handlers = [] + def case_log(self): """Initialize log file""" fmt = {'file_formatter': @@ -94,6 +97,9 @@ class EnvLog(Log): self.logger.setLevel(logging.DEBUG) super(EnvLog, self).__init__(logname, loglevel) + def __del__(self): + self.logger.handlers = [] + def env_log(self): """Initialize log file""" fmt = {'file_formatter':'%(message)s', -- 1.7.7.5

--- repos/domain/attach_disk.py | 4 ---- repos/domain/autostart.py | 4 ---- repos/domain/balloon_memory.py | 4 ---- repos/domain/blkstats.py | 4 ---- repos/domain/console_mutex.py | 4 ---- repos/domain/cpu_affinity.py | 4 ---- repos/domain/cpu_topology.py | 5 ----- repos/domain/define.py | 4 ---- repos/domain/destroy.py | 4 ---- repos/domain/detach_disk.py | 4 ---- repos/domain/eventhandler.py | 4 ---- repos/domain/ifstats.py | 4 ---- repos/domain/install_linux_check.py | 5 ----- repos/domain/restore.py | 4 ---- repos/domain/resume.py | 4 ---- repos/domain/shutdown.py | 4 ---- repos/domain/start.py | 4 ---- repos/domain/suspend.py | 4 ---- repos/domain/undefine.py | 4 ---- repos/libvirtd/restart.py | 5 ----- .../multiple_thread_block_on_domain_create.py | 14 -------------- repos/snapshot/delete.py | 4 ---- repos/snapshot/file_flag.py | 4 ---- repos/snapshot/flag_check.py | 4 ---- repos/snapshot/internal_create.py | 4 ---- repos/snapshot/revert.py | 5 ----- repos/snapshot/snapshot_list.py | 5 ----- repos/storage/build_dir_pool.py | 3 --- 28 files changed, 0 insertions(+), 126 deletions(-) diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index 4385df7..9d8426d 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -99,7 +99,3 @@ def attach_disk(params): return 1 return 0 - -def attach_disk_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index 930a04b..1906706 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -73,7 +73,3 @@ def autostart(params): return 1 return 0 - -def autostart_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 7cef074..25b8318 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -259,7 +259,3 @@ def balloon_memory(params): if count: return 1 return 0 - -def balloon_memory_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index 1500a1a..a208887 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -66,7 +66,3 @@ def blkstats(params): return 1 return 0 - -def blkstats_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/console_mutex.py b/repos/domain/console_mutex.py index 409861b..c67aec6 100644 --- a/repos/domain/console_mutex.py +++ b/repos/domain/console_mutex.py @@ -87,7 +87,3 @@ def console_mutex(params): logger.info("Done") return ret - -def console_mutex_clean(params): - """clean testing environment""" - pass diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index 833cfd2..1332c7e 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -280,7 +280,3 @@ def cpu_affinity(params): if retflag: return 1 return 0 - -def cpu_affinity_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 2caf919..af41f62 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -199,8 +199,3 @@ def cpu_topology(params): return 1 return 0 - -def cpu_topology_clean(params): - """clean testing enviorment""" - return 0 - diff --git a/repos/domain/define.py b/repos/domain/define.py index 29d2c15..9d3b2eb 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -92,7 +92,3 @@ def define(params): return 1 return 0 - -def define_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 9d71835..c41f0f8 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -91,7 +91,3 @@ def destroy(params): return 1 return 0 - -def destroy_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index ddba2ca..1b0b7f9 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -75,7 +75,3 @@ def detach_disk(params): return 1 return 0 - -def detach_disk_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index 1c029eb..4eec6e9 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -241,7 +241,3 @@ def eventhandler(params): loop_stop(conn) return 0 - -def eventhandler_clean(params): - """cleanup the testing environment""" - pass diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index c809809..dd6c193 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -81,7 +81,3 @@ def ifstats(params): return 1 return 0 - -def ifstats_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index 11f4086..1c27fc1 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -180,8 +180,3 @@ def install_linux_check(params): return Test_Result return Test_Result - -def install_linux_check_clean(params): - """ clean testing environment """ - pass - diff --git a/repos/domain/restore.py b/repos/domain/restore.py index acc0b9f..ab0900f 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -85,7 +85,3 @@ def restore(params): return 1 return 0 - -def restore_clean(params): - """ clean the testing environment """ - pass diff --git a/repos/domain/resume.py b/repos/domain/resume.py index 6110f28..85237f7 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -57,7 +57,3 @@ def resume(params): logger.info("PASS") return 0 - -def resume_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index 33a6153..3b97abc 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -69,7 +69,3 @@ def shutdown(params): logger.info("domain %s shutdown successfully" % domname) return 0 - -def shutdown_clean(params): - """ clean the testing environment """ - pass diff --git a/repos/domain/start.py b/repos/domain/start.py index 3bddfe5..f319c2e 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -96,7 +96,3 @@ def start(params): logger.info("PASS") return 0 - -def start_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 32295ea..1941b1c 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -61,7 +61,3 @@ def suspend(params): logger.info('PASS') return 0 - -def suspend_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index 465b5d1..4b1bc20 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -43,7 +43,3 @@ def undefine(params): return 1 return 0 - -def undefine_clean(params): - """ clean testing environment """ - pass diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 40f5a01..04efa8a 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -142,8 +142,3 @@ def restart(params): libvirtd restart" % guestname) return 0 - -def restart_clean(params): - """ clean testing environment """ - pass - diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index 2672ff7..38030c2 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -147,17 +147,3 @@ def multiple_thread_block_on_domain_create(params): conn.close() return 0 - - - - - - - - - - - - - - diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 8942db8..c018cdb 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -76,7 +76,3 @@ def delete(params): return 1 return 0 - -def delete_clean(params): - """ clean testing environment """ - return 0 diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py index c209b79..4d88416 100644 --- a/repos/snapshot/file_flag.py +++ b/repos/snapshot/file_flag.py @@ -88,7 +88,3 @@ def file_flag(params): logger.info("making flag in guest %s succeeded" % guestname) return 0 - -def file_flag_clean(params): - """ clean testing environment """ - return 0 diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py index af4c16b..7bdc14c 100644 --- a/repos/snapshot/flag_check.py +++ b/repos/snapshot/flag_check.py @@ -88,7 +88,3 @@ def flag_check(params): return 0 return 0 - -def flag_check_clean(params): - """ clean testing environment """ - return 0 diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py index a83be57..20f9bbb 100644 --- a/repos/snapshot/internal_create.py +++ b/repos/snapshot/internal_create.py @@ -77,7 +77,3 @@ def internal_create(params): return 1 return 0 - -def internal_create_clean(params): - """ clean testing environment """ - return 0 diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py index 6c8a3e1..d1820bf 100644 --- a/repos/snapshot/revert.py +++ b/repos/snapshot/revert.py @@ -50,8 +50,3 @@ def revert(params): return 1 return 0 - -def revert_clean(params): - """ clean testing environment """ - return 0 - diff --git a/repos/snapshot/snapshot_list.py b/repos/snapshot/snapshot_list.py index d9628c0..cbd68a8 100644 --- a/repos/snapshot/snapshot_list.py +++ b/repos/snapshot/snapshot_list.py @@ -60,8 +60,3 @@ def snapshot_list(params): virsh snapshot_list" % snapshot_name) return 1 return 0 - -def snapshot_list_clean(params): - """ clean testing environment """ - return 0 - diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py index f6adaca..79ae026 100644 --- a/repos/storage/build_dir_pool.py +++ b/repos/storage/build_dir_pool.py @@ -84,6 +84,3 @@ def build_dir_pool(params): return 1 return 0 - -def build_dir_pool_clean(params): - pass -- 1.7.7.5

On 2012年04月16日 14:11, Guannan Ren wrote:
--- repos/domain/attach_disk.py | 4 ---- repos/domain/autostart.py | 4 ---- repos/domain/balloon_memory.py | 4 ---- repos/domain/blkstats.py | 4 ---- repos/domain/console_mutex.py | 4 ---- repos/domain/cpu_affinity.py | 4 ---- repos/domain/cpu_topology.py | 5 ----- repos/domain/define.py | 4 ---- repos/domain/destroy.py | 4 ---- repos/domain/detach_disk.py | 4 ---- repos/domain/eventhandler.py | 4 ---- repos/domain/ifstats.py | 4 ---- repos/domain/install_linux_check.py | 5 ----- repos/domain/restore.py | 4 ---- repos/domain/resume.py | 4 ---- repos/domain/shutdown.py | 4 ---- repos/domain/start.py | 4 ---- repos/domain/suspend.py | 4 ---- repos/domain/undefine.py | 4 ---- repos/libvirtd/restart.py | 5 ----- .../multiple_thread_block_on_domain_create.py | 14 -------------- repos/snapshot/delete.py | 4 ---- repos/snapshot/file_flag.py | 4 ---- repos/snapshot/flag_check.py | 4 ---- repos/snapshot/internal_create.py | 4 ---- repos/snapshot/revert.py | 5 ----- repos/snapshot/snapshot_list.py | 5 ----- repos/storage/build_dir_pool.py | 3 --- 28 files changed, 0 insertions(+), 126 deletions(-)
diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index 4385df7..9d8426d 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -99,7 +99,3 @@ def attach_disk(params): return 1
return 0 - -def attach_disk_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index 930a04b..1906706 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -73,7 +73,3 @@ def autostart(params): return 1
return 0 - -def autostart_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 7cef074..25b8318 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -259,7 +259,3 @@ def balloon_memory(params): if count: return 1 return 0 - -def balloon_memory_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index 1500a1a..a208887 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -66,7 +66,3 @@ def blkstats(params): return 1
return 0 - -def blkstats_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/console_mutex.py b/repos/domain/console_mutex.py index 409861b..c67aec6 100644 --- a/repos/domain/console_mutex.py +++ b/repos/domain/console_mutex.py @@ -87,7 +87,3 @@ def console_mutex(params): logger.info("Done")
return ret - -def console_mutex_clean(params): - """clean testing environment""" - pass diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index 833cfd2..1332c7e 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -280,7 +280,3 @@ def cpu_affinity(params): if retflag: return 1 return 0 - -def cpu_affinity_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 2caf919..af41f62 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -199,8 +199,3 @@ def cpu_topology(params): return 1
return 0 - -def cpu_topology_clean(params): - """clean testing enviorment""" - return 0 - diff --git a/repos/domain/define.py b/repos/domain/define.py index 29d2c15..9d3b2eb 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -92,7 +92,3 @@ def define(params): return 1
return 0 - -def define_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 9d71835..c41f0f8 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -91,7 +91,3 @@ def destroy(params): return 1
return 0 - -def destroy_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index ddba2ca..1b0b7f9 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -75,7 +75,3 @@ def detach_disk(params): return 1
return 0 - -def detach_disk_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index 1c029eb..4eec6e9 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -241,7 +241,3 @@ def eventhandler(params):
loop_stop(conn) return 0 - -def eventhandler_clean(params): - """cleanup the testing environment""" - pass diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index c809809..dd6c193 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -81,7 +81,3 @@ def ifstats(params): return 1
return 0 - -def ifstats_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index 11f4086..1c27fc1 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -180,8 +180,3 @@ def install_linux_check(params): return Test_Result
return Test_Result - -def install_linux_check_clean(params): - """ clean testing environment """ - pass - diff --git a/repos/domain/restore.py b/repos/domain/restore.py index acc0b9f..ab0900f 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -85,7 +85,3 @@ def restore(params): return 1
return 0 - -def restore_clean(params): - """ clean the testing environment """ - pass diff --git a/repos/domain/resume.py b/repos/domain/resume.py index 6110f28..85237f7 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -57,7 +57,3 @@ def resume(params):
logger.info("PASS") return 0 - -def resume_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index 33a6153..3b97abc 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -69,7 +69,3 @@ def shutdown(params): logger.info("domain %s shutdown successfully" % domname)
return 0 - -def shutdown_clean(params): - """ clean the testing environment """ - pass diff --git a/repos/domain/start.py b/repos/domain/start.py index 3bddfe5..f319c2e 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -96,7 +96,3 @@ def start(params):
logger.info("PASS") return 0 - -def start_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 32295ea..1941b1c 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -61,7 +61,3 @@ def suspend(params):
logger.info('PASS') return 0 - -def suspend_clean(params): - """ clean testing environment """ - pass diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index 465b5d1..4b1bc20 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -43,7 +43,3 @@ def undefine(params): return 1
return 0 - -def undefine_clean(params): - """ clean testing environment """ - pass diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 40f5a01..04efa8a 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -142,8 +142,3 @@ def restart(params): libvirtd restart" % guestname)
return 0 - -def restart_clean(params): - """ clean testing environment """ - pass - diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index 2672ff7..38030c2 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -147,17 +147,3 @@ def multiple_thread_block_on_domain_create(params):
conn.close() return 0 - - - - - - - - - - - - - -
Please create a separate patch for this. It's of different purpose. Need a v2. Osier

On 04/16/2012 02:26 PM, Osier Yang wrote:
On 2012年04月16日 14:11, Guannan Ren wrote:
--- repos/domain/attach_disk.py | 4 ---- repos/domain/autostart.py | 4 ---- repos/domain/balloon_memory.py | 4 ---- repos/domain/blkstats.py | 4 ---- repos/domain/console_mutex.py | 4 ---- repos/domain/cpu_affinity.py | 4 ---- repos/domain/cpu_topology.py | 5 ----- repos/domain/define.py | 4 ---- repos/domain/destroy.py | 4 ---- repos/domain/detach_disk.py | 4 ---- repos/domain/eventhandler.py | 4 ---- repos/domain/ifstats.py | 4 ---- repos/domain/install_linux_check.py | 5 ----- repos/domain/restore.py | 4 ---- repos/domain/resume.py | 4 ---- repos/domain/shutdown.py | 4 ---- repos/domain/start.py | 4 ---- repos/domain/suspend.py | 4 ---- repos/domain/undefine.py | 4 ---- repos/libvirtd/restart.py | 5 ----- .../multiple_thread_block_on_domain_create.py | 14 -------------- repos/snapshot/delete.py | 4 ---- repos/snapshot/file_flag.py | 4 ---- repos/snapshot/flag_check.py | 4 ---- repos/snapshot/internal_create.py | 4 ---- repos/snapshot/revert.py | 5 ----- repos/snapshot/snapshot_list.py | 5 ----- repos/storage/build_dir_pool.py | 3 --- 28 files changed, 0 insertions(+), 126 deletions(-)
Please create a separate patch for this. It's of different purpose. Need a v2.
Osier
Hi Osier It is for the same purpose. After we make the clean function optional, so I cleanup these testcases where the clean function is not used. like the following. -def restart_clean(params): - """ clean testing environment """ - pass Guannan Ren

On 2012年04月16日 14:11, Guannan Ren wrote:
The set of patches is to make the writing of clean function optional. If a testcase which doesn't dirty the testing environment, then the TESTCASE_clean function could be optional or omitted.
Good, this was one of the TODO thing in my mind.
Because loggers in python are static objects managed by the module itself. When you create one, it won't be removed until the shell quit. In test-API there are two loggers which are configured with two handlers for each. we need to find a way to destruct these two loggers in order no to affect other application. The idea is to clear the handlers of each logger in destructor of CaseLog and EnvLog.
def __del__(self): self.logger.handlers = []
rename some unclear function and variables. for example: repos/domain/start.py
IIUC, you do 3 different things in these 3 patches, it will be good to document them separately here for easy reviewing.
domain -> mod start.py -> case start() -> func
What does these mean?
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 04/16/2012 02:20 PM, Osier Yang wrote:
On 2012年04月16日 14:11, Guannan Ren wrote:
The set of patches is to make the writing of clean function optional. If a testcase which doesn't dirty the testing environment, then the TESTCASE_clean function could be optional or omitted.
Good, this was one of the TODO thing in my mind.
Because loggers in python are static objects managed by the module itself. When you create one, it won't be removed until the shell quit. In test-API there are two loggers which are configured with two handlers for each. we need to find a way to destruct these two loggers in order no to affect other application. The idea is to clear the handlers of each logger in destructor of CaseLog and EnvLog.
def __del__(self): self.logger.handlers = []
rename some unclear function and variables. for example: repos/domain/start.py
IIUC, you do 3 different things in these 3 patches, it will be good to document them separately here for easy reviewing.
get it, thanks.
domain -> mod start.py -> case start() -> func
What does these mean?
just a naming convention If you see a variable like "mod_case_func", that refers to "damain:start:start" The second start is the function in start.py variable mod_case means "domain:start" that is the testcase file all of code will use the same naming convention. Guannan Ren
participants (2)
-
Guannan Ren
-
Osier Yang