Re: [test-API][PATCH] Update clean part for cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+def delete_clean(params):
+    """ clean testing environment """
+    return 0
diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py
index a1479cc..5c5b2c7 100644
--- a/repos/snapshot/file_flag.py
+++ b/repos/snapshot/file_flag.py
@@ -126,27 +126,9 @@ def file_flag(params):

      return return_close(conn, logger, 0)

+def file_flag_clean(params):
+    """ clean testing environment """
+    util = utils.Utils()

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+    util.clean_ssh()
+    return 0
diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py
index 2e9cb4d..70fb506 100644
--- a/repos/snapshot/flag_check.py
+++ b/repos/snapshot/flag_check.py
@@ -127,4 +127,6 @@ def flag_check(params):

      return return_close(conn, logger, 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 123e38a..7ec1d30 100644
--- a/repos/snapshot/internal_create.py
+++ b/repos/snapshot/internal_create.py
@@ -125,7 +125,9 @@ def internal_create(params):

      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 f70e5dc..dafcf44 100644
--- a/repos/snapshot/revert.py
+++ b/repos/snapshot/revert.py
@@ -95,4 +95,7 @@ def revert(params):

      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 2622d1f..e8ec686 100644
--- a/repos/snapshot/snapshot_list.py
+++ b/repos/snapshot/snapshot_list.py
@@ -93,17 +93,7 @@ def snapshot_list(params):
                  return 1
      return 0

-
-
-
-
-
-
-
-
-
-
-
-
-
+def snapshot_list_clean(params):
+    """ clean testing environment """
+    return 0


     ACK and pushed

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]