[PATCH] [TEST] Fixing 01_forward.py tc of HostedDependency, accomdating sblim-base-provider changes

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1222369936 25200 # Node ID cdf9d7ee99cac967eb9ec0935709b02db6c9dabd # Parent 375ae129b8e910fe42a5e4434b67ada5589bc72f [TEST] Fixing 01_forward.py tc of HostedDependency, accomdating sblim-base-provider changes. This tc changes requires the check_sblim() fn changes. Tested with Xen, XenFV, KVM on current sources and witjh/without sblim-base-provider installed. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 375ae129b8e9 -r cdf9d7ee99ca suites/libvirt-cim/cimtest/HostedDependency/01_forward.py --- a/suites/libvirt-cim/cimtest/HostedDependency/01_forward.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedDependency/01_forward.py Thu Sep 25 12:12:16 2008 -0700 @@ -31,7 +31,7 @@ # # The output should be a single record and it will look something like this: # localhost:5988/root/virt:Xen_HostSystem.CreationClassName="Xen_HostSystem", -# Name="mx3650b.in.ibm.com" +# Name="x3650" # ...... # -CommunicationStatus # -CreationClassName="Xen_HostSystem" @@ -51,8 +51,10 @@ from XenKvmLib import enumclass from XenKvmLib import enumclass from XenKvmLib.classes import get_class_basename from CimTest import Globals +from CimTest.Globals import logger from XenKvmLib.const import do_main from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import check_sblim sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -71,25 +73,41 @@ def main(): cxml = virtxml(test_dom, mac = test_mac) ret = cxml.define(options.ip) if not ret: - Globals.logger.error("Failed to Create the dom: %s", test_dom) + logger.error("Failed to Create the dom: %s", test_dom) status = FAIL return status + keys = ['Name', 'CreationClassName'] + try: - host = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] + ret, linux_cs = check_sblim(options.ip) + host_info = enumclass.enumerate(options.ip, 'HostSystem', keys, + options.virt) except Exception,detail: - Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, 'Hostsystem') - Globals.logger.error("Exception: %s", detail) + logger.error(Globals.CIM_ERROR_ENUMERATE, 'Hostsystem') + logger.error("Exception: %s", detail) status = FAIL cxml.undefine(options.ip) return status - - keys = ['Name', 'CreationClassName'] + + # This below modification is req to accomadate the + # sblim-base-provider provider related changes + if ret == PASS and len(host_info) == 0: + host = linux_cs + elif ret == FAIL and len(host_info) == 1: + host = host_info[0] + elif (ret == FAIL and len(host_info) == 0) or \ + (ret == PASS and len(host_info) == 1): + logger.error("Error in getting HostSystem information, Exiting...") + cxml.undefine(options.ip) + return FAIL + try: - cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys, options.virt) + cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys, + options.virt) except Exception,detail: - Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, 'ComputerSystem') - Globals.logger.error("Exception: %s", detail) + logger.error(Globals.CIM_ERROR_ENUMERATE, 'ComputerSystem') + logger.error("Exception: %s", detail) status = FAIL cxml.undefine(options.ip) return status @@ -104,14 +122,15 @@ def main(): if not hs: cxml.undefine(options.ip) - Globals.logger.error("HostName seems to be empty") + logger.error("HostName seems to be empty") status = FAIL break if len(hs) != 1: test = "(len(hs), system.name)" - Globals.logger.error("HostedDependency returned %i HostSystem \ -objects for domain '%s'", len(hs), system.name) + logger.error("'%s' returned %i HostSystem " + "objects for domain '%s'", + hs_cn, len(hs), system.name) status = FAIL break @@ -119,19 +138,19 @@ objects for domain '%s'", len(hs), syste sn = hs[0]["Name"] if cn != host.CreationClassName: - Globals.logger.error("CreationClassName does not match") + logger.error("CreationClassName does not match") status = FAIL if sn != host.Name: - Globals.logger.error("Name does not match") + logger.error("Name does not match") status = FAIL - if status != 0: + if status != PASS: break except Exception,detail: - Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, hs_cn) - Globals.logger.error("Exception: %s", detail) + logger.error(Globals.CIM_ERROR_ASSOCIATORS, hs_cn) + logger.error("Exception: %s", detail) status = FAIL cxml.undefine(options.ip) return status

+ + # This below modification is req to accomadate the + # sblim-base-provider provider related changes + if ret == PASS and len(host_info) == 0: + host = linux_cs + elif ret == FAIL and len(host_info) == 1: + host = host_info[0] + elif (ret == FAIL and len(host_info) == 0) or \ + (ret == PASS and len(host_info) == 1): + logger.error("Error in getting HostSystem information, Exiting...") + cxml.undefine(options.ip) + return FAIL
This kind of checking isn't needed. If sblim_check() returns PASS, use the instance returned by it. Otherwise, verify len(host_info) > 1. If it's not, return FAIL. Continue with the test if it is greater than 1. So, you have: if ret == PASS: host = linux_cs elif len(host_info) > 1: host = host_info[0] else: return FAIL The reason HostSystem enum_01.py needs to make this check is that it is the test we use to very the enumeration of the HostSystem class. If both a SBLIM provider and a HostSystem instance are returned, the HostSystem/enum_01.py test will fail. This test is about verifying the HostedDependency association - so, all we need is the instance. HostSystem instance verification can take place in enum_01.py. And I didn't think of it when I was reviewing Daisy's tests, but we could roll the sblim_check() call and the above if/elif/else statement info get_host_info(). That way, you only need to call get_host_info() - no need to worry about other checks. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
+ + # This below modification is req to accomadate the + # sblim-base-provider provider related changes + if ret == PASS and len(host_info) == 0: + host = linux_cs + elif ret == FAIL and len(host_info) == 1: + host = host_info[0] + elif (ret == FAIL and len(host_info) == 0) or \ + (ret == PASS and len(host_info) == 1): + logger.error("Error in getting HostSystem information, Exiting...") + cxml.undefine(options.ip) + return FAIL
This kind of checking isn't needed. If sblim_check() returns PASS, use the instance returned by it. Otherwise, verify len(host_info) > 1. If it's not, return FAIL. Continue with the test if it is greater than 1. So, you have:
if ret == PASS: host = linux_cs elif len(host_info) > 1: host = host_info[0] else: return FAIL
The reason HostSystem enum_01.py needs to make this check is that it is the test we use to very the enumeration of the HostSystem class. If both a SBLIM provider and a HostSystem instance are returned, the HostSystem/enum_01.py test will fail.
This test is about verifying the HostedDependency association - so, all we need is the instance. HostSystem instance verification can take place in enum_01.py.
And I didn't think of it when I was reviewing Daisy's tests, but we could roll the sblim_check() call and the above if/elif/else statement info get_host_info(). That way, you only need to call get_host_info() - no need to worry about other checks.
Yes, moving to these verifications to get_host_info() will avoid lot of repetations and will make the tc's look more cleaner. I have submitted the changes. Thanks and Regards, Deepti.
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert