[PATCH 0 of 2] [Test] Tests to verify multiple bridge interface and duplicate mac

Hello everyone, I like to submit a set of tests to verify adding multiple bridge type interface and defining network interface with duplicate mac. The first patch, creates a test called 22_addmulti_brg_interface.py to VirtualSystemManagementService The second patch, creates a test called 23_verify_duplicate_mac_err.py to VirtualSystemManagementService Thanks and Regards Yogi

# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1248260644 25200 # Node ID f50cabfd259e6f31cf01bf6e7a39bd4b8f03d1c8 # Parent 69398bff34dec41bd773fd7d8be550109d41913f [Test] Test adding multiple bridge type interface to domain This testcase verifies adding a bridge type interface using AddRS Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com> diff -r 69398bff34de -r f50cabfd259e suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py Wed Jul 22 04:04:04 2009 -0700 @@ -0,0 +1,122 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 +# +# The testcase verifies adding multiple bridge type interface to domain +# +import sys +from XenKvmLib.enumclass import GetInstance, EnumNames +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.vxml import XenXML, KVMXML, get_class +from CimTest.Globals import logger +from XenKvmLib.const import do_main, get_provider_version, sles11_changeset +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from XenKvmLib.common_util import create_netpool_conf,destroy_netpool +from pywbem.cim_obj import CIMInstanceName +from XenKvmLib.vsms import get_vsms_class, get_nasd_class +from XenKvmLib.vsms_util import add_net_res + +sup_types = ['Xen', 'KVM', 'XenFV'] +test_dom = "my_domain1" +default_net = "my_network0" +test_net = "my_network1" +test_mac = '99:aa:bb:cc:ee:ff' +default_mac = "00:11:33:33:44:55" +ntype = 'bridge' +default_brg = 'mybr0' +test_brg = 'mybr1' +bug_libvirt = "00015" + +def cleanup_env(ip, virt, net_name, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip) + destroy_netpool(ip, virt, net_name) + +@do_main(sup_types) +def main(): + options = main.options + + status, net_name = create_netpool_conf(options.ip, options.virt, + net_name=default_net, + bridge_name=default_brg) + if status != PASS: + logger.error('Unable to create network pool %s', + default_net) + return FAIL + + service = get_vsms_class(options.virt)(options.ip) + classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg) + try: + ret = vsxml.cim_define(options.ip) + if not ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + ret = vsxml.cim_start(options.ip) + if ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + inst_id = '%s:%s' % (options.virt, test_dom) + netpool = EnumNames(options.ip, classname) + vssd_ref = None + for i in range(0, len(netpool)): + ret_pool = netpool[i].keybindings['InstanceID'] + if ret_pool == inst_id: + vssd_ref = netpool[i] + break + + if vssd_ref == None: + raise Exception("Failed to get vssd_ref for '%s'"% test_dom) + + status, net_name = create_netpool_conf(options.ip, options.virt, + net_name=test_net, + bridge_name=test_brg) + if status != PASS: + raise Exception('Unable to create network pool %s'% + test_net) + + except Exception, details: + logger.error(details) + cleanup_env(options.ip, options.virt, default_net, vsxml) + return FAIL + + nasd = get_nasd_class(options.virt)(type=ntype, mac=test_mac, + name=test_dom, virt_net=test_brg) + + net_attr = { 'ntype' : ntype, + 'net_name' : net_name, + 'nmac' : test_mac, + 'virt_net' : test_brg + } + + status = add_net_res(options.ip, service, options.virt, vsxml, + vssd_ref, nasd, net_attr) + cleanup_env(options.ip, options.virt, default_net, vsxml) + destroy_netpool(options.ip, options.virt, net_name=test_net) + + if status != PASS: + return XFAIL_RC(bug_libvirt) + else: + return status + +if __name__ == "__main__": + sys.exit(main())

Thanks for the patch yogi... except for few comments the patch looks good... Yogananth Subramanian wrote:
# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1248260644 25200 # Node ID f50cabfd259e6f31cf01bf6e7a39bd4b8f03d1c8 # Parent 69398bff34dec41bd773fd7d8be550109d41913f [Test] Test adding multiple bridge type interface to domain
This testcase verifies adding a bridge type interface using AddRS
Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com>
diff -r 69398bff34de -r f50cabfd259e suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py Wed Jul 22 04:04:04 2009 -0700 @@ -0,0 +1,122 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 +# +# The testcase verifies adding multiple bridge type interface to domain +# +import sys +from XenKvmLib.enumclass import GetInstance, EnumNames +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.vxml import XenXML, KVMXML, get_class +from CimTest.Globals import logger +from XenKvmLib.const import do_main, get_provider_version, sles11_changeset +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from XenKvmLib.common_util import create_netpool_conf,destroy_netpool +from pywbem.cim_obj import CIMInstanceName
No need to import CIMInstanceName as it not used in the test.
+from XenKvmLib.vsms import get_vsms_class, get_nasd_class +from XenKvmLib.vsms_util import add_net_res + +sup_types = ['Xen', 'KVM', 'XenFV'] +test_dom = "my_domain1" +default_net = "my_network0" +test_net = "my_network1" +test_mac = '99:aa:bb:cc:ee:ff' +default_mac = "00:11:33:33:44:55" +ntype = 'bridge' +default_brg = 'mybr0' +test_brg = 'mybr1' +bug_libvirt = "00015" + +def cleanup_env(ip, virt, net_name, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip) + destroy_netpool(ip, virt, net_name) + +@do_main(sup_types) +def main(): + options = main.options + + status, net_name = create_netpool_conf(options.ip, options.virt, + net_name=default_net, + bridge_name=default_brg) + if status != PASS: + logger.error('Unable to create network pool %s', + default_net) + return FAIL + + service = get_vsms_class(options.virt)(options.ip) + classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg) + try: + ret = vsxml.cim_define(options.ip) + if not ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + ret = vsxml.cim_start(options.ip) + if ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + inst_id = '%s:%s' % (options.virt, test_dom) + netpool = EnumNames(options.ip, classname) + vssd_ref = None + for i in range(0, len(netpool)): + ret_pool = netpool[i].keybindings['InstanceID'] + if ret_pool == inst_id: + vssd_ref = netpool[i] + break + + if vssd_ref == None: + raise Exception("Failed to get vssd_ref for '%s'"% test_dom) + + status, net_name = create_netpool_conf(options.ip, options.virt, + net_name=test_net, + bridge_name=test_brg) + if status != PASS: + raise Exception('Unable to create network pool %s'% + test_net) + + except Exception, details: + logger.error(details) + cleanup_env(options.ip, options.virt, default_net, vsxml) + return FAIL + + nasd = get_nasd_class(options.virt)(type=ntype, mac=test_mac, + name=test_dom, virt_net=test_brg) + + net_attr = { 'ntype' : ntype, + 'net_name' : net_name, + 'nmac' : test_mac, + 'virt_net' : test_brg + } + + status = add_net_res(options.ip, service, options.virt, vsxml, + vssd_ref, nasd, net_attr) + cleanup_env(options.ip, options.virt, default_net, vsxml) + destroy_netpool(options.ip, options.virt, net_name=test_net) + + if status != PASS: + return XFAIL_RC(bug_libvirt) + else: + return status
Include the add_net_res() and the rest of the statements in the above try..except block.. like below or something better you know of: try: ........ ........ nasd = get_nasd_class(options.virt)(type=ntype, mac=test_mac, name=test_dom, virt_net=test_brg) net_attr = { 'ntype' : ntype, 'net_name' : net_name, 'nmac' : test_mac, 'virt_net' : test_brg } status = add_net_res(options.ip, service, options.virt, vsxml, vssd_ref, nasd, net_attr) if status != PASS: status = XFAIL_RC(bug_libvirt) except Exception, details: logger.error(details) status = FAIL cleanup_env(options.ip, options.virt, default_net, vsxml) destroy_netpool(options.ip, options.virt, net_name=test_net) return status This will avoid redundant call to cleanup_env and return statements.
+ +if __name__ == "__main__": + sys.exit(main())
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1248261117 25200 # Node ID d475296d3dec59c3ed90898e43be2465b846f294 # Parent f50cabfd259e6f31cf01bf6e7a39bd4b8f03d1c8 [Test]This testcase verifies definig network interface with conflicting MAC This testcase tests 2 scenarios 1)First case: Try to create 2 diff domains with 'network' type interface with same mac 2)Second case: Try to add a second 'network' type interface with same mac as first interface to tht same domain. Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com> diff -r f50cabfd259e -r d475296d3dec suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py Wed Jul 22 04:11:57 2009 -0700 @@ -0,0 +1,141 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 testcase verifies definig network interface with conflicting MAC +# + +from sys import exit +from random import randint +from pywbem import CIM_ERR_FAILED +from XenKvmLib.vsms_util import add_net_res +from XenKvmLib.vsms import get_vsms_class, get_nasd_class +from XenKvmLib.vxml import get_class +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import default_network_name, do_main +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool +from XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, EnumNames + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'net_domain1' +test_dom = 'brgtest_domain2' +nmac = '99:aa:bb:cc:ee:ff' +ntype = 'network' +npool_name = default_network_name + str(randint(1, 100)) +exp_rc = CIM_ERR_FAILED +exp_desc = "Conflicting MAC Addresses" + + +def cleanup_env(ip, virt, npool_name, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip) + destroy_netpool(ip, virt, npool_name) + +def start_dom(cxml,ip,dom): + ret = cxml.cim_define(ip) + if not ret: + status = cxml.verify_error_msg(exp_rc, exp_desc) + if status != PASS: + raise Exception("Got unexpected rc code %s and description %s" + % (cxml.err_rc, cxml.err_desc)) + return FAIL + ret = cxml.cim_start(ip) + if ret: + status = cxml.verify_error_msg(exp_rc, exp_desc) + cxml.undefine(ip) + if status != PASS: + raise Exception("Got unexpected rc code %s and description %s" + % (cxml.err_rc, cxml.err_desc)) + return FAIL + return PASS + +@do_main(sup_types) +def main(): + options = main.options + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False, + net_name=npool_name) + if status != PASS: + logger.error('Unable to create network pool') + return FAIL + cxml = get_class(options.virt)(default_dom, mac=nmac, + ntype=ntype, net_name=npool_name) + try: + start_dom(cxml, options.ip, default_dom) + + except Exception, details: + logger.error(details) + destroy_netpool(options.ip, options.virt, net_name) + return FAIL + + sxml = get_class(options.virt)(test_dom, mac=nmac, + ntype=ntype, net_name=npool_name) + try: + status = start_dom(sxml, options.ip, test_dom) + + if status == PASS: + sxml.cim_destroy(options.ip) + sxml.undefine(options.ip) + raise Exception("Was able to create two domains with" + "Conflicting MAC Addresses") + else: + status = PASS + + service = get_vsms_class(options.virt)(options.ip) + classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + netpool = EnumNames(options.ip, classname) + inst_id = '%s:%s' % (options.virt, default_dom) + vssd_ref = None + for i in range(0, len(netpool)): + ret_pool = netpool[i].keybindings['InstanceID'] + if ret_pool == inst_id: + vssd_ref = netpool[i] + break + if vssd_ref == None: + raise Exception("Failed to get vssd_ref for '%s'"% default_dom) + + nasd = get_nasd_class(options.virt)(type=ntype, mac=nmac, + name=default_dom, + virt_net=npool_name) + net_attr = { 'ntype' : ntype, + 'net_name' : npool_name, + 'nmac' : nmac + } + + ret = add_net_res(options.ip, service, options.virt, cxml, + vssd_ref, nasd, net_attr) + if ret == PASS: + raise Exception("AddRS should NOT return OK with duplicat MAC") + else: + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + cleanup_env(options.ip, options.virt, npool_name, cxml) + return status + +if __name__ == "__main__": + exit(main()) +

Yogananth Subramanian wrote:
# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1248261117 25200 # Node ID d475296d3dec59c3ed90898e43be2465b846f294 # Parent f50cabfd259e6f31cf01bf6e7a39bd4b8f03d1c8 [Test]This testcase verifies definig network interface with conflicting MAC
This testcase tests 2 scenarios 1)First case: Try to create 2 diff domains with 'network' type interface with same mac 2)Second case: Try to add a second 'network' type interface with same mac as first interface to tht same domain.
Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com>
diff -r f50cabfd259e -r d475296d3dec suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py Wed Jul 22 04:11:57 2009 -0700 @@ -0,0 +1,141 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 testcase verifies definig network interface with conflicting MAC +# + +from sys import exit +from random import randint +from pywbem import CIM_ERR_FAILED +from XenKvmLib.vsms_util import add_net_res +from XenKvmLib.vsms import get_vsms_class, get_nasd_class +from XenKvmLib.vxml import get_class +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import default_network_name, do_main +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool +from XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, EnumNames + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'net_domain1' +test_dom = 'brgtest_domain2' +nmac = '99:aa:bb:cc:ee:ff' +ntype = 'network' +npool_name = default_network_name + str(randint(1, 100)) +exp_rc = CIM_ERR_FAILED +exp_desc = "Conflicting MAC Addresses" + + +def cleanup_env(ip, virt, npool_name, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip) + destroy_netpool(ip, virt, npool_name) + +def start_dom(cxml,ip,dom): + ret = cxml.cim_define(ip) + if not ret: + status = cxml.verify_error_msg(exp_rc, exp_desc) + if status != PASS: + raise Exception("Got unexpected rc code %s and description %s" + % (cxml.err_rc, cxml.err_desc)) + return FAIL + ret = cxml.cim_start(ip) + if ret: + status = cxml.verify_error_msg(exp_rc, exp_desc) + cxml.undefine(ip) + if status != PASS: + raise Exception("Got unexpected rc code %s and description %s" + % (cxml.err_rc, cxml.err_desc)) + return FAIL
Since you are raising an exception please include the above statements in the try.. except block.. Like that you can one return statement from the when the desired exception is received ... For ex something like below: def start_dom(cxml,ip,dom): try: ret = cxml.cim_define(ip) if not ret: status = cxml.verify_error_msg(exp_rc, exp_desc) if status != PASS: raise Exception("Got unexpected rc code %s and description %s" % (cxml.err_rc, cxml.err_desc)) return PASS ret = cxml.cim_start(ip) if ret: status = cxml.verify_error_msg(exp_rc, exp_desc) cxml.undefine(ip) if status != PASS: raise Exception("Got unexpected rc code %s and description %s" % (cxml.err_rc, cxml.err_desc)) return PASS except Exception, details: logger.error("Exception details: %s", details) return FAIL
+ return PASS + +@do_main(sup_types) +def main(): + options = main.options + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False, + net_name=npool_name) + if status != PASS: + logger.error('Unable to create network pool') + return FAIL + cxml = get_class(options.virt)(default_dom, mac=nmac, + ntype=ntype, net_name=npool_name) + try: + start_dom(cxml, options.ip, default_dom)
Its better you capture the return value of start_dom() and return from the tc if status == FAIL..
+ + except Exception, details: + logger.error(details) + destroy_netpool(options.ip, options.virt, net_name) + return FAIL + + sxml = get_class(options.virt)(test_dom, mac=nmac, + ntype=ntype, net_name=npool_name) + try: + status = start_dom(sxml, options.ip, test_dom) + + if status == PASS: + sxml.cim_destroy(options.ip) + sxml.undefine(options.ip) + raise Exception("Was able to create two domains with" + "Conflicting MAC Addresses") + else: + status = PASS
Its better to leave the status to FAIL .. so that we can assign the status = PASS only when the desired condition is met down in the test case.
+ + service = get_vsms_class(options.virt)(options.ip) + classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + netpool = EnumNames(options.ip, classname) + inst_id = '%s:%s' % (options.virt, default_dom) + vssd_ref = None + for i in range(0, len(netpool)): + ret_pool = netpool[i].keybindings['InstanceID'] + if ret_pool == inst_id: + vssd_ref = netpool[i] + break + if vssd_ref == None: + raise Exception("Failed to get vssd_ref for '%s'"% default_dom) + + nasd = get_nasd_class(options.virt)(type=ntype, mac=nmac, + name=default_dom, + virt_net=npool_name) + net_attr = { 'ntype' : ntype, + 'net_name' : npool_name, + 'nmac' : nmac + } + + ret = add_net_res(options.ip, service, options.virt, cxml, + vssd_ref, nasd, net_attr) + if ret == PASS: + raise Exception("AddRS should NOT return OK with duplicat MAC") + else: + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + cleanup_env(options.ip, options.virt, npool_name, cxml) + return status + +if __name__ == "__main__": + exit(main()) +
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Yogananth Subramanian