[PATCH] [TEST] #3 Fix HostSystem-01_enum.py to work with sblim base provider installed and without

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222312954 25200 # Node ID 2321fefe8d19520613c3704ed511d8c3d43242e0 # Parent 375ae129b8e910fe42a5e4434b67ada5589bc72f [TEST] #3 Fix HostSystem-01_enum.py to work with sblim base provider installed and without Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 375ae129b8e9 -r 2321fefe8d19 suites/libvirt-cim/cimtest/HostSystem/01_enum.py --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Wed Sep 24 20:22:34 2008 -0700 @@ -27,6 +27,7 @@ import sys from XenKvmLib import enumclass +from XenKvmLib.common_util import check_sblim from XenKvmLib.classes import get_typed_class from VirtLib import live from VirtLib import utils @@ -43,27 +44,41 @@ def main(): status = FAIL keys = ['Name', 'CreationClassName'] + + ret, linux_cs = check_sblim(options.ip, options.virt) try: hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) - name = get_typed_class(options.virt, 'HostSystem') - - if len(hs) != 1: - logger.error("Expected 1 %s instance returned" % name) - return FAIL - - system = hs[0] - - if system.CreationClassName != name or system.Name != host: - logger.error("Exp %s, got %s" % (name, system.CreationClassName)) - logger.error("Exp %s, got %s" % (host, system.Name)) - status = FAIL - else: - logger.info("%s is %s" % (name, host)) - status = PASS - except Exception, details: logger.error("%s %s: %s" % (CIM_ERROR_ENUMERATE, name, details)) status = FAIL + hostname = get_typed_class(options.virt, 'HostSystem') + + if ret == PASS and len(hs) == 0: + name = 'Linux_ComputerSystem' + system = linux_cs + if ret == FAIL and len(hs) == 1: + name = hostname + system = hs[0] + if system.CreationClassName != name or system.Name != host: + logger.error("Exp %s, got %s" % (name, system.CreationClassName)) + logger.error("Exp %s, got %s" % (host, system.Name)) + status = FAIL + else: + logger.info("%s is %s" % (name, host)) + status = PASS + + if ret == PASS and len(hs) == 1: + if linux_cs.CreationClassName != 'Linux_ComputerSystem' \ + or linux_cs.Name != host \ + or hs[0].CreationClassName != hostname\ + or hs[0].Name != host: + logger.error("Exp Linux_ComputerSystem, got %s" % linux_cs.CreationClassName) + logger.error("Exp %s, got %s" % (host, linux_cs.Name)) + logger.error("Exp %s, got %s" % (hostname, hs[0].CreationClassName)) + logger.error("Exp %s, got %s" % (host, hs[0].Name)) + status = FAIL + else: + status = PASS return status

yunguol@cn.ibm.com wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222312954 25200 # Node ID 2321fefe8d19520613c3704ed511d8c3d43242e0 # Parent 375ae129b8e910fe42a5e4434b67ada5589bc72f [TEST] #3 Fix HostSystem-01_enum.py to work with sblim base provider installed and without
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r 375ae129b8e9 -r 2321fefe8d19 suites/libvirt-cim/cimtest/HostSystem/01_enum.py --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Wed Sep 24 20:22:34 2008 -0700 @@ -27,6 +27,7 @@
import sys from XenKvmLib import enumclass +from XenKvmLib.common_util import check_sblim from XenKvmLib.classes import get_typed_class from VirtLib import live from VirtLib import utils @@ -43,27 +44,41 @@ def main():
status = FAIL keys = ['Name', 'CreationClassName'] + + ret, linux_cs = check_sblim(options.ip, options.virt) try: hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) - name = get_typed_class(options.virt, 'HostSystem') - - if len(hs) != 1: - logger.error("Expected 1 %s instance returned" % name) - return FAIL - - system = hs[0] - - if system.CreationClassName != name or system.Name != host: - logger.error("Exp %s, got %s" % (name, system.CreationClassName)) - logger.error("Exp %s, got %s" % (host, system.Name)) - status = FAIL - else: - logger.info("%s is %s" % (name, host)) - status = PASS - except Exception, details: logger.error("%s %s: %s" % (CIM_ERROR_ENUMERATE, name, details)) status = FAIL + hostname = get_typed_class(options.virt, 'HostSystem') + + if ret == PASS and len(hs) == 0: + name = 'Linux_ComputerSystem' + system = linux_cs + if ret == FAIL and len(hs) == 1: + name = hostname + system = hs[0] + if system.CreationClassName != name or system.Name != host: + logger.error("Exp %s, got %s" % (name, system.CreationClassName)) + logger.error("Exp %s, got %s" % (host, system.Name)) + status = FAIL + else: + logger.info("%s is %s" % (name, host)) + status = PASS + + if ret == PASS and len(hs) == 1: + if linux_cs.CreationClassName != 'Linux_ComputerSystem' \ + or linux_cs.Name != host \ + or hs[0].CreationClassName != hostname\ + or hs[0].Name != host: + logger.error("Exp Linux_ComputerSystem, got %s" % linux_cs.CreationClassName) + logger.error("Exp %s, got %s" % (host, linux_cs.Name)) + logger.error("Exp %s, got %s" % (hostname, hs[0].CreationClassName)) + logger.error("Exp %s, got %s" % (host, hs[0].Name)) + status = FAIL
When sblim-base-provider is installed, I dont think we will have HostSystem and Linux_ComputerSystem both returning the info. If both of them return values, then in that case the above check should return a FAIL instead of verifying the values, thoughts ?? Also, if my understanding is not complete, atleast the above checks should be separated.
+ else: + status = PASS
return status
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

if ret == PASS and len(hs) == 0: + name = 'Linux_ComputerSystem' + system = linux_cs + if ret == FAIL and len(hs) == 1: + name = hostname + system = hs[0] + if system.CreationClassName != name or system.Name != host: + logger.error("Exp %s, got %s" % (name, system.CreationClassName)) + logger.error("Exp %s, got %s" % (host, system.Name)) + status = FAIL + else: + logger.info("%s is %s" % (name, host)) + status = PASS + + if ret == PASS and len(hs) == 1: + if linux_cs.CreationClassName != 'Linux_ComputerSystem' \ + or linux_cs.Name != host \ + or hs[0].CreationClassName != hostname\ + or hs[0].Name != host: + logger.error("Exp Linux_ComputerSystem, got %s" % linux_cs.CreationClassName) + logger.error("Exp %s, got %s" % (host, linux_cs.Name)) + logger.error("Exp %s, got %s" % (hostname, hs[0].CreationClassName)) + logger.error("Exp %s, got %s" % (host, hs[0].Name)) + status = FAIL
When sblim-base-provider is installed, I dont think we will have HostSystem and Linux_ComputerSystem both returning the info. If both of them return values, then in that case the above check should return a FAIL instead of verifying the values, thoughts ?? Also, if my understanding is not complete, atleast the above checks should be separated.
Agreed. If ret == PASS and len(hs) == 1, you'll need to return FAIL. Really, this should look like the following: 1) Call check_sblim() 2) Enum HostSystem 3) If check SBLIM returns PASS: a) If enum of HostSystem returned an instance, return FAIL b) Else, the test can return PASS 4) Else: a) Verify enum of HostSystem returned one instance. If len(hs) != 1, return FAIL b) Verify the HostSystem attributes - return FAIL if any of the attributes don't match. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-09-26 02:14:16:
if ret == PASS and len(hs) == 0: + name = 'Linux_ComputerSystem' + system = linux_cs + if ret == FAIL and len(hs) == 1: + name = hostname + system = hs[0] + if system.CreationClassName != name or system.Name != host: + logger.error("Exp %s, got %s" % (name, system.CreationClassName)) + logger.error("Exp %s, got %s" % (host, system.Name)) + status = FAIL + else: + logger.info("%s is %s" % (name, host)) + status = PASS + + if ret == PASS and len(hs) == 1: + if linux_cs.CreationClassName != 'Linux_ComputerSystem' \ + or linux_cs.Name != host \ + or hs[0].CreationClassName != hostname\ + or hs[0].Name != host: + logger.error("Exp Linux_ComputerSystem, got %s" % linux_cs.CreationClassName) + logger.error("Exp %s, got %s" % (host, linux_cs.Name)) + logger.error("Exp %s, got %s" % (hostname, hs[0].CreationClassName)) + logger.error("Exp %s, got %s" % (host, hs[0].Name)) + status = FAIL
When sblim-base-provider is installed, I dont think we will have HostSystem and Linux_ComputerSystem both returning the info. If both of them return values, then in that case the above check should return a FAIL instead of verifying the values, thoughts ?? Also, if my understanding is not complete, atleast the above checks should be separated.
Agreed. If ret == PASS and len(hs) == 1, you'll need to return FAIL. Really, this should look like the following:
1) Call check_sblim() 2) Enum HostSystem 3) If check SBLIM returns PASS: a) If enum of HostSystem returned an instance, return FAIL b) Else, the test can return PASS
4) Else: a) Verify enum of HostSystem returned one instance. If len(hs) != 1,
return FAIL b) Verify the HostSystem attributes - return FAIL if any of the attributes don't match.
That sounds good! #4 patch on the way. Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (4)
-
Deepti B Kalakeri
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com