[PATCH 0 of 3] [TEST] IPv6 testcase

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1259799202 28800 # Node ID 75243e330ed72b9d57516019ef9b185960503f17 # Parent 45c6da8ca664a61a727b0c0d1811c4337efb53b0 [TEST] Changes to vxml for IPv6 Support Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 45c6da8ca664 -r 75243e330ed7 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Dec 01 16:08:15 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Dec 02 16:13:22 2009 -0800 @@ -569,7 +569,7 @@ def __init__(self, virt, dom_name, uuid, pae, acpi, apic, disk_dev, disk_source, net_type, net_name, net_mac, vcpus, mem, mem_allocunits, emu_type, grstype, ip, - port_num, kmap, irstype, btype, vnc_passwd): + IsIPv6Only, port_num, kmap, irstype, btype, vnc_passwd): self.virt = virt self.domain_name = dom_name self.err_rc = None @@ -591,6 +591,7 @@ dom_name, emu_type) self.gasd = vsms.get_gasd_class(virt)(name=dom_name, res_sub_type=grstype, ip=ip, + ipv6=IsIPv6Only, lport=port_num, keymap=kmap, vnc_passwd=vnc_passwd) self.masd = vsms.get_masd_class(virt)(megabytes=mem, @@ -813,7 +814,8 @@ disk=const.Xen_default_disk_dev, ntype=const.default_net_type, net_name=const.default_network_name, - emu_type=None, grstype="vnc", address="127.0.0.1", + emu_type=None, grstype="vnc", address=None, + IsIPv6Only=True, port_num='-1', keymap="en-us", irstype="mouse", btype="xen", vnc_passwd=None): if not (os.path.exists(const.Xen_kernel_path) \ @@ -828,7 +830,8 @@ VirtCIM.__init__(self, 'Xen', test_dom, uuid, pae, acpi, apic, disk, disk_file_path, ntype, net_name, mac, vcpus, mem, mem_allocunits, emu_type, grstype, address, - port_num, keymap, irstype, btype, vnc_passwd) + IsIPv6Only, port_num, keymap, irstype, btype, + vnc_passwd) def _os(self, os_kernel, os_initrd): os = self.get_node('/domain/os') @@ -882,7 +885,8 @@ disk=const.KVM_default_disk_dev, ntype=const.default_net_type, net_name=const.default_network_name, - emu_type=None, grstype="vnc", address="127.0.0.1", + emu_type=None, grstype="vnc", address=None, + IsIPv6Only=True, port_num='-1', keymap="en-us", irstype="mouse", btype="ps2", vnc_passwd=None): if not os.path.exists(disk_file_path): @@ -892,7 +896,8 @@ VirtCIM.__init__(self, 'KVM', test_dom, uuid, pae, acpi, apic, disk, disk_file_path, ntype, net_name, mac, vcpus, mem, mem_allocunits, emu_type, grstype, address, - port_num, keymap, irstype, btype, vnc_passwd) + IsIPv6Only, port_num, keymap, irstype, btype, + vnc_passwd) self._os() self._devices(const.KVM_default_emulator, ntype, disk_file_path, disk, mac, net_name) @@ -942,7 +947,8 @@ ntype=const.default_net_type, net_name=const.default_network_name, emu_type=None, grstype="vnc", - address="127.0.0.1", port_num='-1', keymap="en-us", + address=None, IsIPv6Only=True, port_num='-1', + keymap="en-us", irstype="mouse", btype="ps2", vnc_passwd=None): if not os.path.exists(disk_file_path): logger.error('Error: Disk image does not exist') @@ -950,7 +956,8 @@ VirtXML.__init__(self, 'xenfv', test_dom, set_uuid(), mem, vcpus) VirtCIM.__init__(self, 'XenFV', test_dom, disk, uuid, pae, acpi, apic, disk_file_path, ntype, net_name, mac, vcpus, mem, - mem_allocunits, emu_type, grstype, address, port_num, + mem_allocunits, emu_type, grstype, address, + IsIPv6Only, port_num, keymap, irstype, btype, vnc_passwd) self._os(const.XenFV_default_loader) self._devices(const.XenFV_default_emulator, @@ -993,13 +1000,15 @@ ntype=const.default_net_type, net_name=const.default_network_name, tty=const.LXC_default_tty, grstype="vnc", - address="127.0.0.1", port_num='-1', keymap="en-us", + address=None, IsIPv6Only=True, port_num='-1', + keymap="en-us", irstype="mouse", btype="usb", vnc_passwd=None): VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus) VirtCIM.__init__(self, 'LXC', test_dom, uuid, const.LXC_default_mp, const.LXC_default_source, ntype, net_name, mac, vcpus, mem, const.default_mallocunits, None, grstype, - address, port_num, keymap, irstype, btype, vnc_passwd) + address, IsIPv6Only, port_num, keymap, irstype, + btype, vnc_passwd) self._os(const.LXC_init_path) self._devices(const.LXC_default_emulator, mac, ntype, net_name, const.LXC_default_tty) self.create_lxc_file(CIM_IP, const.LXC_init_path)

Sharad Mishra wrote:
# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1259799202 28800 # Node ID 75243e330ed72b9d57516019ef9b185960503f17 # Parent 45c6da8ca664a61a727b0c0d1811c4337efb53b0 [TEST] Changes to vxml for IPv6 Support
Signed-off-by: Sharad Mishra <snmishra@us.ibm.com>
diff -r 45c6da8ca664 -r 75243e330ed7 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Dec 01 16:08:15 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Dec 02 16:13:22 2009 -0800 @@ -569,7 +569,7 @@ def __init__(self, virt, dom_name, uuid, pae, acpi, apic, disk_dev, disk_source, net_type, net_name, net_mac, vcpus, mem, mem_allocunits, emu_type, grstype, ip, - port_num, kmap, irstype, btype, vnc_passwd): + IsIPv6Only, port_num, kmap, irstype, btype, vnc_passwd):
Can you change this from camel case to lower case? The other parameters use lower case, so might as well have them match. I wouldn't normally point it out, but there's one other change needed for this patch.
self.virt = virt self.domain_name = dom_name self.err_rc = None @@ -591,6 +591,7 @@ dom_name, emu_type) self.gasd = vsms.get_gasd_class(virt)(name=dom_name, res_sub_type=grstype, ip=ip, + ipv6=IsIPv6Only, lport=port_num, keymap=kmap, vnc_passwd=vnc_passwd) self.masd = vsms.get_masd_class(virt)(megabytes=mem,

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1259799211 28800 # Node ID 8a1871391e3757b54e3ad3992236f14da9d9b564 # Parent 75243e330ed72b9d57516019ef9b185960503f17 [TEST] Changes to vsms for IPv6 testcase. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 75243e330ed7 -r 8a1871391e37 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Dec 02 16:13:22 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Dec 02 16:13:31 2009 -0800 @@ -255,7 +255,7 @@ class CIM_GraphicsResourceAllocationSettingData(CIMClassMOF): - def __init__(self, name, res_sub_type="vnc", ip="127.0.0.1", + def __init__(self, name, res_sub_type="vnc", ip="", ipv6="", lport='-1', keymap="en-us", vnc_passwd=None): self.InstanceID = '%s/graphics' %name self.ResourceType = RASD_TYPE_GRAPHICS @@ -266,6 +266,9 @@ if ip != None and lport != None: self.Address = '%s:%s' % (ip, lport) + if ipv6 != None: + self.IsIPv6Only = ipv6 + if keymap != None: self.KeyMap = keymap

Sharad Mishra wrote:
# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1259799211 28800 # Node ID 8a1871391e3757b54e3ad3992236f14da9d9b564 # Parent 75243e330ed72b9d57516019ef9b185960503f17 [TEST] Changes to vsms for IPv6 testcase.
Signed-off-by: Sharad Mishra <snmishra@us.ibm.com>
diff -r 75243e330ed7 -r 8a1871391e37 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Dec 02 16:13:22 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Dec 02 16:13:31 2009 -0800 @@ -255,7 +255,7 @@
class CIM_GraphicsResourceAllocationSettingData(CIMClassMOF): - def __init__(self, name, res_sub_type="vnc", ip="127.0.0.1", + def __init__(self, name, res_sub_type="vnc", ip="", ipv6="",
I would change ip="" to ip=None and ipv6="" to ipv6=None. Also, ip and ipv6 is a little ambiguous. Just looking at the input parameters, I'm not sure what the difference is between the two. I'd change ipv6 to something like "set_ipv6". Something similar that indicates its a boolean flag that indicates what type of IP is being passed in for the ip param.
lport='-1', keymap="en-us", vnc_passwd=None): self.InstanceID = '%s/graphics' %name self.ResourceType = RASD_TYPE_GRAPHICS @@ -266,6 +266,9 @@ if ip != None and lport != None: self.Address = '%s:%s' % (ip, lport)
+ if ipv6 != None: + self.IsIPv6Only = ipv6 + if keymap != None: self.KeyMap = keymap
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1259799625 28800 # Node ID 8926b390373385cbe7f984d2c861fb7e76022558 # Parent 8a1871391e3757b54e3ad3992236f14da9d9b564 [TEST] IPv6 Support test. This test checks support for IPv6 in libvirt-cim. Signed-off-by: Sharad Mishra<snmishra@us.ibm.com> diff -r 8a1871391e37 -r 8926b3903733 suites/libvirt-cim/cimtest/KVMRedirectionSAP/02_ipv6_support.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/02_ipv6_support.py Wed Dec 02 16:20:25 2009 -0800 @@ -0,0 +1,132 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Sharad Mishra <snmishra@us.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# This test case is used to verify IPv6 support. It verifies that if an IP +# address is supplied, that address gets used for VNC. If an address is not +# supplied then the new IsIPv6Only flag is read. If the flag is set, then +# default ipv6 address is used. Else default ipv4 address gets used. +# This test case: +# +# Defines a guest in a loop with different settings of IP +# address and IsIPv6Only flag. +# +# Once the guest is defined, gets the instance of DisplayController +# and GRASD. +# Checks to make sure expected vnc address is set for both. +# +# Date : Nov. 11, 2009 +# + +import sys +from XenKvmLib.enumclass import GetInstance +from XenKvmLib.vxml import get_class +from XenKvmLib.classes import get_typed_class +from XenKvmLib.const import do_main, get_provider_version +from CimTest.Globals import logger +from CimTest.ReturnCodes import PASS, FAIL, SKIP + +sup_types = ['Xen', 'KVM', 'XenFV'] +libvirtcim_redSAP_changes = 1017 +test_dom = 'test_ipv6_dom' + +address_dict = {('127.0.0.1', None) : '127.0.0.1:-1', + ('[::1]', None) : '[::1]:-1', + ('127.0.0.1', True) : '127.0.0.1:-1', + ('[::1]', False) : '[::1]:-1', + ('127.0.0.1', False) : '127.0.0.1:-1', + ('[::1]', True) : '[::1]:-1', + (None, True) : '[::1]:-1', + (None, False) : '127.0.0.1:-1', + (None, None) : '127.0.0.1:-1' + } + +@do_main(sup_types) +def main(): + status = PASS + virt = main.options.virt + server = main.options.ip + + cname = 'KVMRedirectionSAP' + classname = get_typed_class(virt, cname) + + # This check is required for libvirt-cim providers which do not have + # REDSAP changes in it and the REDSAP provider is available with + # revision >= 1017. + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev < libvirtcim_redSAP_changes: + logger.info("'%s' provider not supported, hence skipping the tc ....", + classname) + return SKIP + + vsxml = None + + try: + virt_xml = get_class(virt) + for key, value in address_dict.iteritems(): + add = key[0] + flg = key[1] + if add == None: + vsxml = virt_xml(test_dom, IsIPv6Only=flg) + else: + vsxml = virt_xml(test_dom, address=add, IsIPv6Only=flg) + # Define the VS + ret = vsxml.cim_define(server) + if not ret: + raise Exception("Failed to define the dom: %s" % test_dom) + + devid = "%s/%s" % (test_dom, 'graphics') + vnc = get_typed_class(virt, "DisplayController") + key_list = { 'DeviceID' : devid, + 'CreationClassName' : vnc, + 'SystemName' : test_dom, + 'SystemCreationClassName' : + get_typed_class(virt, "ComputerSystem") + } + dev = GetInstance(server, vnc, key_list) + vp = "vnc/%s" % value + + if vp != dev.VideoProcessor: + vsmxl.undefine(server) + raise Exception("Unxpected VNC server address") + + vnc = get_typed_class(virt, "GraphicsResourceAllocationSettingData") + key_list = { 'InstanceID' : devid, + 'CreationClassName' : vnc, + 'SystemName' : test_dom, + 'SystemCreationClassName' : + get_typed_class(virt, "ComputerSystem") + } + dev = GetInstance(server, vnc, key_list) + + if value != dev.Address: + vsmxl.undefine(server) + raise Exception("Unxpected VNC server address") + + vsxml.undefine(server) + + except Exception, detail: + logger.error("Exception: %s", detail) + status = FAIL + + return status + +if __name__ == "__main__": + sys.exit(main())

+ + if vp != dev.VideoProcessor: + vsmxl.undefine(server) + raise Exception("Unxpected VNC server address") + + vnc = get_typed_class(virt, "GraphicsResourceAllocationSettingData") + key_list = { 'InstanceID' : devid, + 'CreationClassName' : vnc, + 'SystemName' : test_dom, + 'SystemCreationClassName' : + get_typed_class(virt, "ComputerSystem") + } + dev = GetInstance(server, vnc, key_list) + + if value != dev.Address: + vsmxl.undefine(server) + raise Exception("Unxpected VNC server address") + + vsxml.undefine(server) + + except Exception, detail: + logger.error("Exception: %s", detail) + status = FAIL
Instead of calling undefine before each call to raise Exception(), why not put the undefine call in the except block? This means you'll only need to call undefine() once for any exception. And if this test case is extended in the future, it'll safe guard against an accidental exclusion of the undefine() call when an exception occurs.
+ + return status + +if __name__ == "__main__": + sys.exit(main())
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+ + except Exception, detail: + logger.error("Exception: %s", detail) + status = FAIL
Instead of calling undefine before each call to raise Exception(), why not put the undefine call in the except block? This means you'll only need to call undefine() once for any exception. And if this test case is extended in the future, it'll safe guard against an accidental exclusion of the undefine() call when an exception occurs.
There is an exception raised if define fails. We don't want to call undefine if the VM wasn't defined. -Sharad

Sharad Mishra wrote:
+ + except Exception, detail: + logger.error("Exception: %s", detail) + status = FAIL
Instead of calling undefine before each call to raise Exception(), why not put the undefine call in the except block? This means you'll only need to call undefine() once for any exception. And if this test case is extended in the future, it'll safe guard against an accidental exclusion of the undefine() call when an exception occurs.
There is an exception raised if define fails. We don't want to call undefine if the VM wasn't defined.
Ah, agreed. Although, many of test cases do this anyway. Because we don't check the output of undefine() (except for certain occasions). So the worst thing that happens is that the undefine() call returns an error. And we get some additional negative testing in... Generally, I prefer to make sure the cleanup happens in one place - that way it is easy to tell whether the test is cleaning up properly. But this is a good point. It's fine to leave it as is.
participants (2)
-
Kaitlin Rupert
-
Sharad Mishra