[test-API][PATCH v2 2/2] Add case for testing spice compression options

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

 



  * repos/domain/spice_options.py: add this test for BZ#682237
---
 repos/domain/spice_options.py |  113 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 repos/domain/spice_options.py

diff --git a/repos/domain/spice_options.py b/repos/domain/spice_options.py
new file mode 100644
index 0000000..5d0830a
--- /dev/null
+++ b/repos/domain/spice_options.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+"""For configuring spice compression options testing
+   domain:spice_options
+       guestname
+           xxx
+       image
+           auto_glz|auto_lz|quic|glz|lz|off
+       jpeg
+           auto|never|always
+       zlib
+           auto|never|always
+       playback
+           on|off
+"""
+
+__author__ = 'Nan Zhang: nzhang@xxxxxxxxxx'
+__date__ = 'Thu Sep 8, 2011'
+__version__ = '0.1.0'
+__credits__ = 'Copyright (C) 2011 Red Hat, Inc.'
+__all__ = ['usage', 'spice_config']
+
+import os
+import re
+import sys
+from xml.dom import minidom
+
+def append_path(path):
+    """Append root path of package"""
+    if path in sys.path:
+        pass
+    else:
+        sys.path.append(path)
+
+pwd = os.getcwd()
+result = re.search('(.*)libvirt-test-API', pwd)
+append_path(result.group(0))
+
+from lib import connectAPI
+from lib import domainAPI
+from utils.Python import utils
+
+
+def check_params(params):
+    """Verify inputing parameter dictionary"""
+    logger = params['logger']
+    keys = ['guestname', 'image', 'jpeg', 'zlib', 'playback']
+    for key in keys:
+        if key not in params:
+            logger.error("%s is required" %key)
+            return 1
+    return 0
+
+def spice_options(params):
+    """check spice options"""
+    # Initiate and check parameters
+    params_check_result = check_params(params)
+    if params_check_result:
+        return 1
+    logger = params['logger']
+    guestname = params['guestname']
+    image = params['image']
+    jpeg = params['jpeg']
+    zlib = params['zlib']
+    playback = params['playback']
+
+    # Connect to local hypervisor connection URI
+    util = utils.Utils()
+    uri = util.get_uri('127.0.0.1')
+    conn = connectAPI.ConnectAPI()
+    virconn = conn.open(uri)
+
+    caps = conn.get_caps()
+    logger.debug(caps)
+
+    # Get domain xml
+    domobj = domainAPI.DomainAPI(virconn)
+    xmlobj = domobj.get_xml_desc(guestname)
+    prexml = xmlobj.split('\n')
+    postxml = ''
+    for i in range(len(prexml)):
+        postxml = postxml + prexml[i].lstrip()
+    domxml = minidom.parseString(postxml)
+
+    # Check spice options in 'graphcis' tag
+    graphTag = domxml.getElementsByTagName("graphics")
+    try:
+        try:
+            for graphTag in domxml.getElementsByTagName("graphics"):
+                assert len(graphTag.childNodes) == 4
+                assert graphTag.childNodes[0].getAttribute("compression") \
+                                                 == params['image']
+                assert graphTag.childNodes[1].getAttribute("compression") \
+                                                 == params['jpeg']
+                assert graphTag.childNodes[2].getAttribute("compression") \
+                                                 == params['zlib']
+                assert graphTag.childNodes[3].getAttribute("compression") \
+                                                 == params['playback']
+        except AssertionError:
+            logger.error("Wrong checks happend on spice options.")
+            conn.close()
+            logger.info("closed hypervisor connection")
+            return 1
+    finally:
+        logger.info("spice options were checked successfully.")
+        conn.close()
+        logger.info("closed hypervisor connection")
+
+    return 0
+
+def spice_options_clean():
+    """Clean testing environment"""
+    pass
+
-- 
1.7.4.4

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