[PATCH] [TEST] Fixing 02_reverse.py of RAPF

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1212413727 25200 # Node ID d478234fefe940f0ef738bbb83e6a3ab32736bec # Parent 4a5a44d7b857df543af24d59380cb8fdbbb753a4 [TEST] Fixing 02_reverse.py of RAPF. Added the following extra steps: 1) Defining a domain. 2) creating diskpool, netpool. Without the steps 1 and 2 the tc used to simply pass. The tc will fail on KVM with old libvirt-cim rpm as expected and will pass with the latest source. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 4a5a44d7b857 -r d478234fefe9 suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py --- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Fri May 30 14:26:38 2008 +0800 +++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Mon Jun 02 06:35:27 2008 -0700 @@ -6,6 +6,7 @@ # Guolian Yun <yunguol@cn.ibm.com> # Kaitlin Rupert <karupert@us.ibm.com> # Zhengang Li <lizg@cn.ibm.com> +# Deepti B. Kalakeri <deeptik@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 @@ -25,69 +26,164 @@ import sys import sys from VirtLib import utils from XenKvmLib import assoc -from XenKvmLib import devices +from XenKvmLib.test_doms import destroy_and_undefine_all +from XenKvmLib.vxml import get_class from XenKvmLib.classes import get_typed_class +from XenKvmLib.const import CIM_REV from CimTest import Globals from CimTest.Globals import logger, do_main -from CimTest.ReturnCodes import PASS, FAIL, XFAIL +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib import enumclass +from XenKvmLib.common_util import cleanup_restore, create_diskpool_conf, \ +create_netpool_conf + sup_types = ['Xen', 'XenFV', 'KVM'] +test_dom = "RAFP_dom" +test_vcpus = 1 +test_mem = 128 +test_mac = "00:11:22:33:44:aa" +proc_instid_rev = 590 + +def setup_env(server, virt): + destroy_and_undefine_all(server) + vsxml = None + if virt == "Xen": + test_disk = "xvda" + else: + test_disk = "hda" + + virtxml = get_class(virt) + vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus, + mac = test_mac, disk = test_disk) + try: + ret = vsxml.define(server) + if not ret: + logger.error("Failed to Define the domain: %s", test_dom) + return FAIL, vsxml, test_disk + + except Exception, details: + logger.error("Exception : %s", details) + return FAIL, vsxml, test_disk + + return PASS, vsxml, test_disk + +def init_list(test_disk, diskid, test_network): + + if CIM_REV < proc_instid_rev: + procid = '%s/%s' % (test_dom, 0) + else: + procid = '%s/%s' % (test_dom, 'proc') + + proc = { 'rasd_id' : procid, + 'pool_id' : 'ProcessorPool/0' + } + + mem = { 'rasd_id' : '%s/%s' % (test_dom,'mem'), + 'pool_id' : 'MemoryPool/0' + } + + net = { + 'rasd_id' : '%s/%s' % (test_dom, test_mac), + 'pool_id' : 'NetworkPool/%s' %test_network + } + + disk = { 'rasd_id' : '%s/%s' % (test_dom, test_disk), + 'pool_id' : diskid + } + + cn_id_list = { + 'MemResourceAllocationSettingData' : mem, + 'ProcResourceAllocationSettingData' : proc, + 'NetResourceAllocationSettingData' : net, + 'DiskResourceAllocationSettingData' : disk + } + + return cn_id_list + +def get_rasd_instance(server, virt, key_list, cn): + inst = None + try: + inst = enumclass.getInstance(server, cn, key_list, virt) + except Exception, details: + logger.error(Globals.CIM_ERROR_GETINSTANCE, cn) + logger.error("Exception details: %s", details) + return inst, FAIL + + return inst, PASS + +def verify_pool_from_RAFP(server, virt, inst, pool_id, cn): + pool = [] + try: + pool = assoc.AssociatorNames(server, "ResourceAllocationFromPool", + cn, virt, InstanceID = inst.InstanceID) + except Exception: + logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES, inst.InstanceID) + return FAIL + + if len(pool) != 1: + logger.error("No associated pool for %s", inst.InstanceID) + return FAIL + + if pool[0]['InstanceID'] != pool_id: + logger.error("InstanceID Mismatch") + logger.error("Returned %s instead of %s", pool[0]['InstanceID'] , + pool_id) + return FAIL + + return PASS + +def get_rasdinst_verify_pool_from_RAFP(server, virt, vsxml, cn, id_info): + try: + key_list = { 'InstanceID' : id_info['rasd_id'] } + rasd_cn = get_typed_class(virt, cn) + rasdinst, status = get_rasd_instance(server, virt, key_list, rasd_cn) + if status != PASS or rasdinst.InstanceID == None: + vsxml.undefine(server) + return status + + status = verify_pool_from_RAFP(server, virt, rasdinst, + id_info['pool_id'], cn) + except Exception, details: + logger.error("Exception in get_rasdinst_verify_pool_from_RAFP() fn") + logger.error("Exception Details %s", details) + status = FAIL + + if status != PASS: + vsxml.undefine(server) + + return status + @do_main(sup_types) def main(): options = main.options status = PASS + server = options.ip + virt = options.virt + + status, vsxml, test_disk = setup_env(server, virt) + if status != PASS: + return status - key_list = ["DeviceID", "CreationClassName", "SystemName", - "SystemCreationClassName"] - try: - mem = devices.enumerate(options.ip, 'Memory', key_list, options.virt) - except Exception: - logger.error(Globals.CIM_ERROR_ENUMERATE % 'Memory') - return FAIL + status, diskid = create_diskpool_conf(server, virt) + if status != PASS: + return status - try: - proc = devices.enumerate(options.ip, 'Processor', key_list, options.virt) - except Exception: - logger.error(Globals.CIM_ERROR_ENUMERATE % 'Processor') - return FAIL - - for i in range(len(mem)): - try: - mempool = assoc.AssociatorNames(options.ip, "ResourceAllocationFromPool", - "MemResourceAllocationSettingData", - options.virt, - InstanceID = mem[i].DeviceID) - except Exception: - logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % mem[i].DeviceID) - status = FAIL + status, test_network = create_netpool_conf(server, virt) + if status != PASS: + return status - if len(mempool) < 1: - logger.error("No associated pool for %s" % mem[i].DeviceID) - return FAIL + cn_id_list = init_list(test_disk, diskid, test_network) - if mempool[0].keybindings['InstanceID'] != "MemoryPool/0": - logger.error("MemResourceAllocationSettingData association error") - return FAIL - - for j in range(len(proc)): - try: - procpool = assoc.AssociatorNames(options.ip, "ResourceAllocationFromPool", - "ProcResourceAllocationSettingData", - options.virt, - InstanceID = proc[j].DeviceID) - except Exception: - logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % proc[j].DeviceID) - return FAIL - - if len(procpool) < 1: - logger.error("No associated pool for %s" % proc[j].DeviceID) - return FAIL + for rasd_cn, id_info in cn_id_list.iteritems(): + status = get_rasdinst_verify_pool_from_RAFP(server, virt, vsxml, + rasd_cn, id_info) + if status != PASS: + return status - if procpool[0].keybindings['InstanceID'] != "ProcessorPool/0": - logger.error("ProcResourceAllocationSettingData association failed") - status = FAIL - + cleanup_restore(server, virt) + vsxml.undefine(server) return status if __name__ == "__main__":

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1212413727 25200 # Node ID d478234fefe940f0ef738bbb83e6a3ab32736bec # Parent 4a5a44d7b857df543af24d59380cb8fdbbb753a4 [TEST] Fixing 02_reverse.py of RAPF.
Added the following extra steps: 1) Defining a domain. 2) creating diskpool, netpool.
Without the steps 1 and 2 the tc used to simply pass. The tc will fail on KVM with old libvirt-cim rpm as expected and will pass with the latest source.
I failed to notice this during the last review, but this will fail on Xen because the Xen XML is creating a guest with a ethernet interface. An ethernet type interface won't be bound to any kind of network pool. This doesn't happen with XenFV because the XenFV guest is created with a bridge guest. Since DefineSystem() creates guests Xen/XenFV/KVM guests with network interface types, the XML for Xen and XenFV should be changed as well. Also, when you send an updated patch, don't forget to put the revision number in the first line of the commit log. Also, be sure to list the changes between the previous revision and the new revision. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert