[PATCH] [TEST] Updating VSMC 01_enum.py to verify the SynchronousMethodsSupported values

# HG changeset patch # User Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # Date 1220346904 -19800 # Node ID f956aa699a3e3ea6df8f2d6e423ed9cf032d61c5 # Parent 946fd46b96866adaab356876f9c8bbf937f0b3d6 [TEST] Updating VSMC 01_enum.py to verify the SynchronousMethodsSupported values. Changes ------- 1) Also modified the tc to use do_main from const.py instead of Globals.py. 2) Used print_field_error() to print the error messages. 3) Removed Globals.py. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 946fd46b9686 -r f956aa699a3e suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Thu Aug 28 14:07:25 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Tue Sep 02 14:45:04 2008 +0530 @@ -23,35 +23,58 @@ # import sys +from sets import Set from XenKvmLib import enumclass -from CimTest import Globals -from CimTest.Globals import do_main +from CimTest.Globals import logger, CIM_ERROR_ENUMERATE +from XenKvmLib.const import do_main from XenKvmLib.classes import get_typed_class +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import print_field_error sup_types=['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(sup_types) def main(): options = main.options + server = options.ip + virt = options.virt + cn = get_typed_class(virt, 'VirtualSystemManagementCapabilities') + + # Methods which are considered as synchronous + # where 1 = ADD_RESOURCES , 2 = DEFINE_SYSTEM , 3 = DESTROY_SYSTEM, + # 4 = DESTROY_SYS_CONFIG, 5 = MOD_RESOURCE_SETTINGS, + # 6 = MOD_SYS_SETTINGS, 7 = RM_RESOURCES + sync_method_val = Set([ 1L, 2L, 3L, 5L, 6L, 7L ]) try: key_list = ["InstanceID"] - vsmc = enumclass.enumerate(options.ip, + vsmc = enumclass.enumerate(server, "VirtualSystemManagementCapabilities", key_list, - options.virt) + virt) except Exception: - Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, - get_typed_class(options.virt, 'VirtualSystemManagementCapabilities')) - return 1 - - if len(vsmc) != 1: - Globals.logger.error("VirtualSystemManagementCapabilities return %i instance, excepted only 1" % len(vsmc)) - return 1 - if vsmc[0].InstanceID != "ManagementCapabilities": - Globals.logger.error( "error result of enum VirtualSystemManagementCapabilities") - return 1 + logger.error(CIM_ERROR_ENUMERATE, cn) + return FAIL + try: + if len(vsmc) != 1: + logger.error("'%s' returned '%d' instance, excepted only 1", cn, len(vsmc)) + return FAIL + + if vsmc[0].InstanceID != "ManagementCapabilities": + print_field_error('InstanceID', vsmc[0].InstanceID, 'ManagementCapabilities') + return FAIL + vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported) + if len(vsmc_sync_val - sync_method_val) != 0: + print_field_error('SynchronousMethodsSupported', vsmc_sync_val, + sync_method_val) + return FAIL + + except Exception, details: + logger.error("Exception: details %s", details) + return FAIL + + return PASS if __name__ == "__main__": sys.exit(main())

+ try: + if len(vsmc) != 1: + logger.error("'%s' returned '%d' instance, excepted only 1", cn, len(vsmc))
This line wraps.
+ return FAIL + + if vsmc[0].InstanceID != "ManagementCapabilities": + print_field_error('InstanceID', vsmc[0].InstanceID, 'ManagementCapabilities')
This line wraps as well.
+ return FAIL
+ vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported) + if len(vsmc_sync_val - sync_method_val) != 0: + print_field_error('SynchronousMethodsSupported', vsmc_sync_val, + sync_method_val) + return FAIL
In addition to also checking the len, you'll want to check to make sure the SynchronousMethodsSupported values match the values we're expecting. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
+ try: + if len(vsmc) != 1: + logger.error("'%s' returned '%d' instance, excepted only 1", cn, len(vsmc))
This line wraps. Can I get more details here ?
+ return FAIL + + if vsmc[0].InstanceID != "ManagementCapabilities": + print_field_error('InstanceID', vsmc[0].InstanceID, 'ManagementCapabilities')
This line wraps as well.
+ return FAIL
+ vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported) + if len(vsmc_sync_val - sync_method_val) != 0: + print_field_error('SynchronousMethodsSupported', vsmc_sync_val, + sync_method_val) + return FAIL
In addition to also checking the len, you'll want to check to make sure the SynchronousMethodsSupported values match the values we're expecting.
The above check len(vsmc_sync_val - sync_method_val) 1) Verifies the len 2) Also if the values in the list differ then difference will be greater than zero which means the list values does not match. Well, I had initially done 2 check one for verifying the len of the list and the other for verifying the values. But since the operation S1 - S2 did both of them I switched to the above option. Let me know if you still think separating the both is good then I can do so. Thanks and Regards, Deepti.

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
+ try: + if len(vsmc) != 1: + logger.error("'%s' returned '%d' instance, excepted only 1", cn, len(vsmc))
This line wraps. Can I get more details here ?
This line and the next line are both longer than 80 characters.
+ return FAIL + + if vsmc[0].InstanceID != "ManagementCapabilities": + print_field_error('InstanceID', vsmc[0].InstanceID, 'ManagementCapabilities')
This line wraps as well.
+ return FAIL
+ vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported) + if len(vsmc_sync_val - sync_method_val) != 0: + print_field_error('SynchronousMethodsSupported', vsmc_sync_val, + sync_method_val) + return FAIL
In addition to also checking the len, you'll want to check to make sure the SynchronousMethodsSupported values match the values we're expecting.
The above check len(vsmc_sync_val - sync_method_val) 1) Verifies the len 2) Also if the values in the list differ then difference will be greater than zero which means the list values does not match. Well, I had initially done 2 check one for verifying the len of the list and the other for verifying the values. But since the operation S1 - S2 did both of them I switched to the above option.
Let me know if you still think separating the both is good then I can do so.
You're correct. Sorry, I'd forgotten that you were using sets to compare the two values. No need to break this into 2 different checks. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
+ try: + if len(vsmc) != 1: + logger.error("'%s' returned '%d' instance, excepted only 1", cn, len(vsmc))
This line wraps. Can I get more details here ?
This line and the next line are both longer than 80 characters.
Yes, I missed aligning this to 80 columns, sent the changes for the above today.
+ return FAIL + + if vsmc[0].InstanceID != "ManagementCapabilities": + print_field_error('InstanceID', vsmc[0].InstanceID, 'ManagementCapabilities')
This line wraps as well.
+ return FAIL
+ vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported) + if len(vsmc_sync_val - sync_method_val) != 0: + print_field_error('SynchronousMethodsSupported', vsmc_sync_val, + sync_method_val) + return FAIL
In addition to also checking the len, you'll want to check to make sure the SynchronousMethodsSupported values match the values we're expecting.
The above check len(vsmc_sync_val - sync_method_val) 1) Verifies the len 2) Also if the values in the list differ then difference will be greater than zero which means the list values does not match. Well, I had initially done 2 check one for verifying the len of the list and the other for verifying the values. But since the operation S1 - S2 did both of them I switched to the above option.
Let me know if you still think separating the both is good then I can do so.
You're correct. Sorry, I'd forgotten that you were using sets to compare the two values. No need to break this into 2 different checks.
Thanks!
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert