[test-API PATCH v2] improve testcases after cleanup work

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

 



install_linux_cdrom.py: use global variable with value
                        /var/cache/libvirt-test-API
                        copy custom.iso into it for qemu process

install_linux_check.py: use hddriver and nicdriver name

network/create.py: in the case of the network with 'isolate' type
                   we need to remove '<forward mode="NETMODE"/>'line,
                   The bug is caused by changes on using xml files

network/define.py: Same as network/create.py

snapshot/delete.py: The TESTCASE_check is reserved function name for
                    framework, so change the internal checking function
                    to check_xml()
---
 repos/domain/install_linux_cdrom.py |   20 ++++++++++++++------
 repos/domain/install_linux_check.py |    6 +++---
 repos/network/create.py             |    4 ++++
 repos/network/define.py             |    6 +++++-
 repos/snapshot/delete.py            |    6 +++---
 5 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py
index 60d12a7..e46491b 100644
--- a/repos/domain/install_linux_cdrom.py
+++ b/repos/domain/install_linux_cdrom.py
@@ -36,7 +36,7 @@ VM_STAT = "virsh --quiet list --all| grep \"\\b%s\\b\"|grep off"
 VM_DESTROY = "virsh destroy %s"
 VM_UNDEFINE = "virsh undefine %s"
 
-BOOT_DIR = "/var/lib/libvirt/boot/"
+BOOT_ISO_DIR = "/var/cache/libvirt-test-api"
 HOME_PATH = os.getcwd()
 
 def prepare_cdrom(*args):
@@ -47,13 +47,18 @@ def prepare_cdrom(*args):
     ks_name = os.path.basename(ks)
 
     new_dir = os.path.join(HOME_PATH, guestname)
+    customiso_dir = os.path.join(BOOT_ISO_DIR, guestname)
     logger.info("creating a new folder for customizing custom.iso file in it")
 
     if os.path.exists(new_dir):
         logger.info("the folder exists, remove it")
         shutil.rmtree(new_dir)
 
+    if os.path.exists(customiso_dir):
+        shutil.rmtree(customiso_dir)
+
     os.makedirs(new_dir)
+    os.makedirs(customiso_dir)
     logger.info("the directory is %s" % new_dir)
 
     boot_path = os.path.join(ostree, 'images/boot.iso')
@@ -65,10 +70,10 @@ def prepare_cdrom(*args):
     urllib.urlretrieve(ks, '%s/%s' % (new_dir, ks_name))[0]
     logger.info("the url of kickstart is %s" % ks)
 
-    shutil.copy('utils/ksiso.sh', new_dir)
+    shutil.debug('utils/ksiso.sh', new_dir)
     src_path = os.getcwd()
 
-    logger.info("enter into the workshop folder: %s" % new_dir)
+    logger.debug("enter into the workshop folder: %s" % new_dir)
     os.chdir(new_dir)
     shell_cmd = 'sh ksiso.sh %s' % ks_name
 
@@ -76,8 +81,11 @@ def prepare_cdrom(*args):
     (status, text) = commands.getstatusoutput(shell_cmd)
 
     logger.debug(text)
-    logger.info("make custom.iso file, change to original directory: %s" %
-                src_path)
+
+    logger.debug("copy custom.iso to %s" % customiso_dir)
+    shutil.copy('custom.iso', customiso_dir)
+
+    logger.debug("go back to original directory: %s" % src_path)
     os.chdir(src_path)
 
 def prepare_boot_guest(domobj, xmlstr, guestname, installtype, logger):
@@ -196,7 +204,7 @@ def install_linux_cdrom(params):
     logger.info('prepare installation...')
 
     bootcd = '%s/custom.iso' % \
-                       (os.path.join(HOME_PATH, guestname))
+                       (os.path.join(BOOT_ISO_DIR, guestname))
     logger.debug("the bootcd path is %s" % bootcd)
     logger.info("begin to customize the custom.iso file")
     prepare_cdrom(ostree, ks, guestname, logger)
diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py
index d034aba..ab1e7db 100644
--- a/repos/domain/install_linux_check.py
+++ b/repos/domain/install_linux_check.py
@@ -15,7 +15,7 @@ from src import sharedmod
 from src import env_parser
 from utils import utils
 
-required_params = ('guestname', 'virt_type', 'hdmodel', 'nicmodel',)
+required_params = ('guestname', 'virt_type', 'hddriver', 'nicdriver',)
 optional_params = {}
 
 HOME_PATH = os.getcwd()
@@ -71,8 +71,8 @@ def install_linux_check(params):
     logger.info("Now checking guest health after installation")
 
     domain_name=guestname
-    blk_type=params['hdmodel']
-    nic_type=params['nicmodel']
+    blk_type=params['hddriver']
+    nic_type=params['nicdriver']
     Test_Result = 0
 
     # Ping guest from host
diff --git a/repos/network/create.py b/repos/network/create.py
index 839e93b..399328c 100644
--- a/repos/network/create.py
+++ b/repos/network/create.py
@@ -39,6 +39,7 @@ def create(params):
     """Create a network from xml"""
     logger = params['logger']
     networkname = params['networkname']
+    netmode = params['netmode']
     xmlstr = params['xml']
 
     conn = sharedmod.libvirtobj['conn']
@@ -47,6 +48,9 @@ def create(params):
         logger.error("the %s network is running" % networkname)
         return 1
 
+    if netmode == 'isolate':
+        xmlstr = re.sub('<forward.*\n', '', xmlstr)
+
     logger.debug("%s network xml:\n%s" % (networkname, xmlstr))
 
     net_num1 = conn.numOfNetworks()
diff --git a/repos/network/define.py b/repos/network/define.py
index 923db29..dd054f7 100644
--- a/repos/network/define.py
+++ b/repos/network/define.py
@@ -42,14 +42,18 @@ def define(params):
     """Define a network from xml"""
     logger = params['logger']
     networkname = params['networkname']
+    netmode = params['netmode']
     xmlstr = params['xml']
 
     conn = sharedmod.libvirtobj['conn']
 
     if check_network_define(networkname, logger):
-        logger.error("%s network is defined" % networkname)
+        logger.error("%s network is already defined" % networkname)
         return 1
 
+    if netmode == 'isolate':
+        xmlstr = re.sub('<forward.*\n', '', xmlstr)
+
     logger.debug("network xml:\n%s" % xmlstr)
 
     net_num1 = conn.numOfDefinedNetworks()
diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py
index 19689b1..bab043e 100644
--- a/repos/snapshot/delete.py
+++ b/repos/snapshot/delete.py
@@ -24,7 +24,7 @@ def check_domain_state(conn, guestname, logger):
     else:
         return True
 
-def delete_check(guestname, snapshotname, expected_flag, logger):
+def check_xml(guestname, snapshotname, expected_flag, logger):
     """ after deleting, check if appropriate xml file exists or not"""
     guest_snapshot_dir = os.path.join(SNAPSHOT_DIR, guestname)
     snapshot_entries = os.listdir(guest_snapshot_dir)
@@ -54,7 +54,7 @@ def delete(params):
         logger.error("checking failed")
         return 1
 
-    if not delete_check(guestname, snapshotname, "exist", logger):
+    if not check_xml(guestname, snapshotname, "exist", logger):
         logger.error("no snapshot %s exists" % snapshotname)
         logger.debug("not corresponding xml file in %s" % SNAPSHOT_DIR)
         return 1
@@ -64,7 +64,7 @@ def delete(params):
         domobj = conn.lookupByName(guestname)
         snapobj = domobj.snapshotLookupByName(snapshotname, 0)
         snapobj.delete(0)
-        if not delete_check(guestname, snapshotname, "noexist", logger):
+        if not check_xml(guestname, snapshotname, "noexist", logger):
             logger.error("after deleting, the corresponding \
                          xmlfile still exists in %s" % SNAPSHOT_DIR)
             return 1
-- 
1.7.7.5

--
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]