Re: [libvirt] [test-API][PATCH] Update clean part for cases
On 11/21/2011 03:23 PM, Wayne Sun wrote: * add clean function for missing ones * clean the system configuration files which been touched --- repos/domain/balloon_memory.py |2 ++ repos/domain/cpu_topology.py |5 + repos/domain/ownership_test.py | 10 ++ repos/libvirtd/qemu_hang.py | 12 ++-- repos/remoteAccess/unix_perm_sasl.py | 10 ++ repos/sVirt/domain_nfs_start.py | 10 ++ repos/snapshot/delete.py | 18 +++--- repos/snapshot/file_flag.py | 28 +--- repos/snapshot/flag_check.py |4 +++- repos/snapshot/internal_create.py|4 +++- repos/snapshot/revert.py |3 +++ repos/snapshot/snapshot_list.py | 16 +++- 12 files changed, 67 insertions(+), 55 deletions(-) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 30f5edb..0a40591 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -299,6 +299,8 @@ def balloon_memory(params): logger.info(the actual size of memory is \ rounded to the value %s we expected % maxmem) +util.clean_ssh() + if count: return return_close(conn, logger, 1) else: diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 7202559..adf238c 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -246,3 +246,8 @@ def cpu_topology(params): conn.close() return 0 + +def cpu_topology_clean(params): +clean testing enviorment +return 0 + diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 74620f4..1eacbcf 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -307,6 +307,9 @@ def ownership_test_clean(params): for i in range(len(out)): logger.error(out[i]) +clean_nfs_conf = sed -i '$d' /etc/exports +util.exec_cmd(clean_nfs_conf, shell=True) + filepath = TEMP_FILE elif use_nfs == 'disable': filepath = SAVE_FILE @@ -314,3 +317,10 @@ def ownership_test_clean(params): if os.path.exists(filepath): os.remove(filepath) +clean_qemu_conf = sed -i '$d' %s % QEMU_CONF +util.exec_cmd(clean_qemu_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index c97e0b7..8b1ffda 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -135,8 +135,16 @@ def qemu_hang(params): return 0 -def qemu_hang_cleanup(params): +def qemu_hang_clean(params): clean testing environment -pass +logger = params['logger'] +guestname = params['guestname'] +util = utils.Utils() +ret = get_domain_pid(util, logger, guestname) +cmd = kill -CONT %s % ret[1] +ret = util.exec_cmd(cmd, shell=True) +if ret[0]: +logger.error(failed to resume qemu process of %s % guestname) +return 0 diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py index 54fa108..5db758c 100644 --- a/repos/remoteAccess/unix_perm_sasl.py +++ b/repos/remoteAccess/unix_perm_sasl.py @@ -22,6 +22,7 @@ import sys import commands from pwd import getpwnam +from utils.Python import utils def append_path(path): Append root path of package @@ -214,6 +215,7 @@ def unix_perm_sasl(params): def unix_perm_sasl_clean(params): clean testing environment logger = params['logger'] +util = utils.Utils() auth_unix_ro = params['auth_unix_ro'] auth_unix_rw = params['auth_unix_rw'] @@ -241,3 +243,11 @@ def unix_perm_sasl_clean(params): if status: logger.error(failed to delete sasl user %s % TESTING_USER) +clean_libvirtd_conf = sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' %s % \ + LIBVIRTD_CONF +util.exec_cmd(clean_libvirtd_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index 2479366..edaf2f2 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -483,3 +483,13 @@ def domain_nfs_start_clean(params): conn.close() +clean_nfs_conf = sed -i '$d' /etc/exports +util.exec_cmd(clean_nfs_conf, shell=True) + +clean_qemu_conf = sed -i '$d' %s % QEMU_CONF +util.exec_cmd(clean_qemu_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 8a7eef6..98f82a5 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -124,18 +124,6 @@ def delete(params): return 0 - - - - - - - - - - - - - -
[libvirt] [test-API][PATCH] Update clean part for cases
* add clean function for missing ones * clean the system configuration files which been touched --- repos/domain/balloon_memory.py |2 ++ repos/domain/cpu_topology.py |5 + repos/domain/ownership_test.py | 10 ++ repos/libvirtd/qemu_hang.py | 12 ++-- repos/remoteAccess/unix_perm_sasl.py | 10 ++ repos/sVirt/domain_nfs_start.py | 10 ++ repos/snapshot/delete.py | 18 +++--- repos/snapshot/file_flag.py | 28 +--- repos/snapshot/flag_check.py |4 +++- repos/snapshot/internal_create.py|4 +++- repos/snapshot/revert.py |3 +++ repos/snapshot/snapshot_list.py | 16 +++- 12 files changed, 67 insertions(+), 55 deletions(-) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index 30f5edb..0a40591 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -299,6 +299,8 @@ def balloon_memory(params): logger.info(the actual size of memory is \ rounded to the value %s we expected % maxmem) +util.clean_ssh() + if count: return return_close(conn, logger, 1) else: diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 7202559..adf238c 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -246,3 +246,8 @@ def cpu_topology(params): conn.close() return 0 + +def cpu_topology_clean(params): +clean testing enviorment +return 0 + diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 74620f4..1eacbcf 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -307,6 +307,9 @@ def ownership_test_clean(params): for i in range(len(out)): logger.error(out[i]) +clean_nfs_conf = sed -i '$d' /etc/exports +util.exec_cmd(clean_nfs_conf, shell=True) + filepath = TEMP_FILE elif use_nfs == 'disable': filepath = SAVE_FILE @@ -314,3 +317,10 @@ def ownership_test_clean(params): if os.path.exists(filepath): os.remove(filepath) +clean_qemu_conf = sed -i '$d' %s % QEMU_CONF +util.exec_cmd(clean_qemu_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index c97e0b7..8b1ffda 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -135,8 +135,16 @@ def qemu_hang(params): return 0 -def qemu_hang_cleanup(params): +def qemu_hang_clean(params): clean testing environment -pass +logger = params['logger'] +guestname = params['guestname'] +util = utils.Utils() +ret = get_domain_pid(util, logger, guestname) +cmd = kill -CONT %s % ret[1] +ret = util.exec_cmd(cmd, shell=True) +if ret[0]: +logger.error(failed to resume qemu process of %s % guestname) +return 0 diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py index 54fa108..5db758c 100644 --- a/repos/remoteAccess/unix_perm_sasl.py +++ b/repos/remoteAccess/unix_perm_sasl.py @@ -22,6 +22,7 @@ import sys import commands from pwd import getpwnam +from utils.Python import utils def append_path(path): Append root path of package @@ -214,6 +215,7 @@ def unix_perm_sasl(params): def unix_perm_sasl_clean(params): clean testing environment logger = params['logger'] +util = utils.Utils() auth_unix_ro = params['auth_unix_ro'] auth_unix_rw = params['auth_unix_rw'] @@ -241,3 +243,11 @@ def unix_perm_sasl_clean(params): if status: logger.error(failed to delete sasl user %s % TESTING_USER) +clean_libvirtd_conf = sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' %s % \ + LIBVIRTD_CONF +util.exec_cmd(clean_libvirtd_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index 2479366..edaf2f2 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -483,3 +483,13 @@ def domain_nfs_start_clean(params): conn.close() +clean_nfs_conf = sed -i '$d' /etc/exports +util.exec_cmd(clean_nfs_conf, shell=True) + +clean_qemu_conf = sed -i '$d' %s % QEMU_CONF +util.exec_cmd(clean_qemu_conf, shell=True) + +cmd = service libvirtd restart +util.exec_cmd(cmd, shell=True) + +return 0 diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 8a7eef6..98f82a5 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -124,18 +124,6 @@ def delete(params): return 0 - - - - - - - - - - - - - - - +def delete_clean(params): + clean testing environment +