[PATCH] [TEST] Fixing and updating 01_forward.py of HostedService to work with/without sblim-base-provider

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1224152067 25200 # Node ID 385c3d0a59afd7283a3ef8d26a49b690e601a19c # Parent dd9065d32ce97c688cf09ce6ed4df1a477fd136b [TEST] Fixing and updating 01_forward.py of HostedService to work with/without sblim-base-provider. Fixed the debug stmt. Updated to with/without sblim-base-provider. Tested with Xen, XenFV, KVM with current sources, with/without sblim-base-provider. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r dd9065d32ce9 -r 385c3d0a59af suites/libvirt-cim/cimtest/HostedService/01_forward.py --- a/suites/libvirt-cim/cimtest/HostedService/01_forward.py Thu Oct 16 01:38:18 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedService/01_forward.py Thu Oct 16 03:14:27 2008 -0700 @@ -22,6 +22,7 @@ # import sys +from sets import Set from VirtLib import utils from XenKvmLib import assoc from XenKvmLib import enumclass @@ -29,23 +30,25 @@ from CimTest import Globals from XenKvmLib.const import do_main from CimTest.Globals import logger -from CimTest.ReturnCodes import PASS, FAIL, XFAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from XenKvmLib.common_util import get_host_info sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +bug_sblim = '00007' @do_main(sup_types) def main(): options = main.options virt = options.virt + server = options.ip try: - status, host_name, host_ccn = get_host_info(options.ip, virt) + status, host_name, host_ccn = get_host_info(server, virt) if status != PASS: logger.error("Failed to get host info.") return status an = get_typed_class(virt, "HostedService") - service = assoc.AssociatorNames(options.ip, + service = assoc.AssociatorNames(server, an, host_ccn, CreationClassName = host_ccn, Name = host_name) @@ -58,26 +61,27 @@ logger.error("No association return") return FAIL - valid_services = [get_typed_class(virt, "ResourcePoolConfigurationService"), - get_typed_class(virt, "VirtualSystemManagementService"), - get_typed_class(virt, "VirtualSystemMigrationService"), - get_typed_class(virt, "ConsoleRedirectionService")] + val_serv = Set([get_typed_class(virt, "ResourcePoolConfigurationService"), + get_typed_class(virt, "VirtualSystemManagementService"), + get_typed_class(virt, "VirtualSystemMigrationService"), + get_typed_class(virt, "ConsoleRedirectionService")]) ccn_list = [] for item in service: ccn_list.append(item.keybindings["CreationClassName"]) - - if len(ccn_list) != len(valid_services): - logger.error("'%s' returned %d, expected %d", - an, len(valid_services), len(ccn_list)) + + ccn_list = Set(ccn_list) + + if (len(val_serv) - len(ccn_list)) != 0: + if host_ccn == 'Linux_ComputerSystem': + return XFAIL_RC(bug_sblim) + else: + + logger.error("Mismatching services values") + logger.error("'%s' returned %d, expected %d", + an, len(ccn_list), len(val_serv)) return FAIL - for ccn in ccn_list: - if ccn not in valid_services: - logger.error("Invalid Value '%s' returned for association '%s'", - ccn, an) - return FAIL - - + return PASS if __name__ == "__main__": sys.exit(main())

- - if len(ccn_list) != len(valid_services): - logger.error("'%s' returned %d, expected %d", - an, len(valid_services), len(ccn_list)) + + ccn_list = Set(ccn_list) + + if (len(val_serv) - len(ccn_list)) != 0: + if host_ccn == 'Linux_ComputerSystem': + return XFAIL_RC(bug_sblim)
I'm not sure I understand the usage of Sets here.. if len(ccn_list) != len(valid_services): Seems like the above would accomplish the same thing. The usage of Sets isn't wrong.. but I'm not sure I see the need to use them in this case. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote: >> - - if len(ccn_list) != len(valid_services): >> - logger.error("'%s' returned %d, expected %d", >> - an, len(valid_services), len(ccn_list)) >> + >> + ccn_list = Set(ccn_list) + + if (len(val_serv) - >> len(ccn_list)) != 0: >> + if host_ccn == 'Linux_ComputerSystem': >> + return XFAIL_RC(bug_sblim) > > I'm not sure I understand the usage of Sets here.. > > if len(ccn_list) != len(valid_services): > > Seems like the above would accomplish the same thing. The usage of > Sets isn't wrong.. but I'm not sure I see the need to use them in this > case. Oops! sorry this should have been if len((val_serv) - (ccn_list)) !=0. I am trying to achieve 2 things 1) Compare the len 2) Verify if the values are all similar. We can use if len(ccn_list) != len(valid_services), but this will only verify the length but will not compare the elements of the list. I hope its ok to use if len((val_serv) - (ccn_list)) !=0, if you have any better solutions, let me know. Thanks and Regards, Deepti.

Deepti B Kalakeri wrote: > > > Kaitlin Rupert wrote: >>> - - if len(ccn_list) != len(valid_services): >>> - logger.error("'%s' returned %d, expected %d", >>> - an, len(valid_services), len(ccn_list)) >>> + >>> + ccn_list = Set(ccn_list) + + if (len(val_serv) - >>> len(ccn_list)) != 0: >>> + if host_ccn == 'Linux_ComputerSystem': >>> + return XFAIL_RC(bug_sblim) >> >> I'm not sure I understand the usage of Sets here.. >> >> if len(ccn_list) != len(valid_services): >> >> Seems like the above would accomplish the same thing. The usage of >> Sets isn't wrong.. but I'm not sure I see the need to use them in this >> case. > Oops! sorry this should have been if len((val_serv) - (ccn_list)) !=0. > I am trying to achieve 2 things > 1) Compare the len > 2) Verify if the values are all similar. Ah, good point here. I always forget that Sets will check the elements as well as the length. Definitely a good point here. I had no other comments, so I'll apply this. Thanks! > > We can use if len(ccn_list) != len(valid_services), but this will only > verify the length but will not compare the elements of the list. > I hope its ok to use if len((val_serv) - (ccn_list)) !=0, if you have > any better solutions, let me know. > -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert