[PATCH 0 of 6] CS related tc changes.

1) Fixed 40_RSC_start.py 2) Supported KVM in 23_suspend_suspend.py, 33_suspend_reboot.py, 35_start_reset.py. 3) Updated 32_start_reboot.py.

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217330632 25200 # Node ID f2f1c1899247df3a68d885a73bbfbb989a6e7941 # Parent 32d78f23f6e73f5443022179410128767896465d 1) Fixed get_cs_instance() debug statement. 2) Moved the common code which tried to match the error to a new fn verify_err_desc(). 3) Added try_request_state_change() to verify the error conditions of RequestStateChange(). 4) Added check_reqstate_value() that verifies the RequestState value. The changes are verified with KVM Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 32d78f23f6e7 -r f2f1c1899247 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Jul 23 00:32:36 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Jul 29 04:23:52 2008 -0700 @@ -33,7 +33,8 @@ from pywbem.cim_obj import CIMInstanceName from XenKvmLib.devices import CIM_Instance from XenKvmLib.classes import get_typed_class -from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE +from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE, \ +CIM_ERROR_GETINSTANCE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from VirtLib.live import diskpool_list, virsh_version, net_list from XenKvmLib.vxml import PoolXML, NetXML @@ -57,7 +58,7 @@ return (1, cs) except Exception, detail: - logger.error(Globals.CIM_ERROR_GETINSTANCE, + logger.error(CIM_ERROR_GETINSTANCE, get_typed_class(virt, 'ComputerSystem')) logger.error("Exception: %s", detail) return (1, cs) @@ -122,10 +123,21 @@ return PASS +def verify_err_desc(exp_rc, exp_desc, err_no, err_desc): + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception where ") + logger.info("Errno is '%s' ", exp_rc) + logger.info("Error string is '%s'", exp_desc) + return PASS + else: + logger.error("Unexpected rc code %s and description %s\n", + (err_no, err_desc)) + return FAIL + def call_request_state_change(domain_name, ip, rs, time, virt='Xen'): rc, cs = get_cs_instance(domain_name, ip, virt) if rc != 0: - return 1 + return FAIL try: cs.RequestStateChange(RequestedState=pywbem.cim_types.Uint16(rs), @@ -133,9 +145,24 @@ except Exception, detail: logger.error("Exception: %s" % detail) - return 1 + return FAIL - return 0 + return PASS + +def try_request_state_change(domain_name, ip, rs, time, exp_rc, + exp_desc, virt='Xen'): + rc, cs = get_cs_instance(domain_name, ip, virt) + if rc != 0: + return FAIL + + try: + cs.RequestStateChange(RequestedState=pywbem.cim_types.Uint16(rs), + TimeoutPeriod=pywbem.cim_types.CIMDateTime(time)) + + except Exception, (err_no, err_desc) : + return verify_err_desc(exp_rc, exp_desc, err_no, err_desc) + logger.error("RequestStateChange failed to generate an exception") + return FAIL def poll_for_state_change(server, virt, dom, exp_state, timeout=30): cs = computersystem.get_cs_class(virt) @@ -162,6 +189,20 @@ return FAIL return PASS + + +def check_reqstate_value(domain_name, server, rq_state, virt): + rc, cs = get_cs_instance(domain_name, server, virt) + if rc != 0: + return FAIL + + if cs.RequestedState != rq_state: + logger.error("RequestedState should be %d not %d", + rq_state, cs.RequestedState) + return FAIL + + return PASS + def get_host_info(server, virt="Xen"): status = PASS @@ -191,20 +232,12 @@ try: assoc_info = conn.AssociatorNames(instanceref, \ AssocClass=assoc_classname) - except pywbem.CIMError, (err_no, desc): + except pywbem.CIMError, (err_no, err_desc): exp_rc = expr_values['rc'] exp_desc = expr_values['desc'] - if err_no == exp_rc and desc.find(exp_desc) >= 0: - logger.info("Got expected exception where ") - logger.info("Errno is '%s' ", exp_rc) - logger.info("Error string is '%s'", exp_desc) - return PASS - else: - logger.error("Unexpected rc code %s and description %s\n" \ - %(err_no, desc)) - return FAIL - logger.error("'%s' association failed to generate an exception and \ -'%s' passed.", assoc_classname, field_name) + return verify_err_desc(exp_rc, exp_desc, err_no, err_desc) + logger.error("'%s' association failed to generate an exception and" + " '%s' passed.", assoc_classname, field_name) return XFAIL_RC(bug_no) def try_getinstance(conn, classname, keys, field_name, expr_values, bug_no): @@ -213,20 +246,12 @@ instanceref = CIMInstanceName(classname, keybindings=keys) logger.info ("Instanceref is '%s'", instanceref) inst = conn.GetInstance(instanceref) - except pywbem.CIMError, (err_no, desc): + except pywbem.CIMError, (err_no, err_desc): exp_rc = expr_values['rc'] exp_desc = expr_values['desc'] - if err_no == exp_rc and desc.find(exp_desc) >= 0: - logger.info("Got expected exception where ") - logger.info("Errno is '%s' ", exp_rc) - logger.info("Error string is '%s'", exp_desc) - return PASS - else: - logger.error("Unexpected rc code %s and description %s\n" \ - %(err_no, desc)) - return FAIL - logger.error("'%s' GetInstance failed to generate an exception and \ -'%s' passed.", classname, field_name) + return verify_err_desc(exp_rc, exp_desc, err_no, err_desc) + logger.error("'%s' GetInstance failed to generate an exception and" + " '%s' passed.", classname, field_name) return XFAIL_RC(bug_no) def profile_init_list():

+def verify_err_desc(exp_rc, exp_desc, err_no, err_desc): + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception where ") + logger.info("Errno is '%s' ", exp_rc) + logger.info("Error string is '%s'", exp_desc) + return PASS + else: + logger.error("Unexpected rc code %s and description %s\n", + (err_no, err_desc)) + return FAIL +\
I don't think we need to add this to a common library. The libraries are becoming cluttered, and it's often difficult to tell what library a function comes from. Checking an error description is fairly trivial and something that each test case can handle as needed. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
+def verify_err_desc(exp_rc, exp_desc, err_no, err_desc): + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception where ") + logger.info("Errno is '%s' ", exp_rc) + logger.info("Error string is '%s'", exp_desc) + return PASS + else: + logger.error("Unexpected rc code %s and description %s\n", + (err_no, err_desc)) + return FAIL +\
I don't think we need to add this to a common library. The libraries are becoming cluttered, and it's often difficult to tell what library a function comes from.
Checking an error description is fairly trivial and something that each test case can handle as needed.
The above statements which were moved are not used in the test cases, these were part of try_assoc() and try_getinstance() function in the library common_util.py. Also, something similar was needed by the try_request_state_change() function that I added to the common_util.py. I have just moved the repeating code to verify_err_desc(). Thanks and Regards, Deepti.

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
+def verify_err_desc(exp_rc, exp_desc, err_no, err_desc): + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception where ") + logger.info("Errno is '%s' ", exp_rc) + logger.info("Error string is '%s'", exp_desc) + return PASS + else: + logger.error("Unexpected rc code %s and description %s\n", + (err_no, err_desc)) + return FAIL +\
I don't think we need to add this to a common library. The libraries are becoming cluttered, and it's often difficult to tell what library a function comes from.
Checking an error description is fairly trivial and something that each test case can handle as needed.
The above statements which were moved are not used in the test cases, these were part of try_assoc() and try_getinstance() function in the library common_util.py. Also, something similar was needed by the try_request_state_change() function that I added to the common_util.py. I have just moved the repeating code to verify_err_desc().
Ah, oops. My mistake. That's fine then. Ignore my original comment. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217331585 25200 # Node ID ec303feee0e302ddf29b8dad81d0d4416e0fb48a # Parent f2f1c1899247df3a68d885a73bbfbb989a6e7941 changes in vsms.py ------------------ 1) Added mvirtquantity to be passed for MemRASD. 2) Set the default mvirtquantity to 1024 units since this is the mininmum value that is req for KVM. 3) Added mem_allocunit param to default_vssd_rasd_str() to pass the AllocationUnits. The above changes are required to be able to start KVM guest using DefineSystem(). changes in 40_RSC_start.py -------------------------- 1) Used poll_for_state_change() to verify the poll and verify the EnabledState value. 2) Removed the invalid bug nos. 3) Removed check_attributes() and used check_reqstate_value() library function instead. 4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool. 5) Used destroy_and_undefine_domain() to undefine and destroy the VS. The changes are verified with KVM Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r f2f1c1899247 -r ec303feee0e3 suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py Tue Jul 29 04:23:52 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py Tue Jul 29 04:39:45 2008 -0700 @@ -36,60 +36,49 @@ import sys import pywbem from VirtLib import utils -from XenKvmLib.test_doms import undefine_test_domain +from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.common_util import * from CimTest.Globals import logger from CimTest.Globals import do_main -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from CimTest.ReturnCodes import PASS, FAIL sup_types = ['Xen', 'KVM', 'XenFV'] -bug = "00001" -bug_req_state = "00002" -default_dom = 'test_domain' +default_dom = 'cs_test_domain' REQUESTED_STATE = 2 TIME = "00000000000000.000000:000" - -def check_attributes(domain_name, ip, virt): - rc, cs = get_cs_instance(domain_name, ip, virt) - if rc != 0: - return rc - - if cs.RequestedState != REQUESTED_STATE: - logger.error("RequestedState should be %d not %d", - REQUESTED_STATE, cs.RequestedState) - return FAIL - - if cs.EnabledState != REQUESTED_STATE: - logger.error("EnabledState should be %d not %d", - REQUESTED_STATE, cs.EnabledState) - return FAIL - - return PASS @do_main(sup_types) def main(): options = main.options + server = options.ip + virt = options.virt status = FAIL + status, test_network = create_netpool_conf(server, virt, False) + if status != PASS: + return FAIL + try: - rc = create_using_definesystem(default_dom, options.ip, - virt=options.virt) + rc = create_using_definesystem(default_dom, server, + virt=virt) if rc != 0: - raise Exception("DefineSystem() failed to create domain: %s" % + raise Exception("DefineSystem() failed to create domain: '%s'" % default_dom) - rc = call_request_state_change(default_dom, options.ip, - REQUESTED_STATE, TIME, options.virt) + rc = call_request_state_change(default_dom, server, + REQUESTED_STATE, TIME, virt) if rc != 0: - status = XFAIL_RC(bug) + status = FAIL raise Exception("RequestedStateChange() could not be used to start" " domain: '%s'" % default_dom) + status = poll_for_state_change(server, virt, default_dom, + REQUESTED_STATE, timeout=10) - rc = check_attributes(default_dom, options.ip, options.virt) - if rc != 0: - status = XFAIL_RC(bug_req_state) + rc = check_reqstate_value(default_dom, server, REQUESTED_STATE, virt) + if rc != PASS or status != PASS: + status = FAIL raise Exception("Attributes were not set as expected for " "domain: '%s'" % default_dom) else: @@ -98,8 +87,8 @@ except Exception, detail: logger.error("Exception: %s", detail) - undefine_test_domain(default_dom, options.ip, options.virt) - + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) return status if __name__ == "__main__": diff -r f2f1c1899247 -r ec303feee0e3 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jul 29 04:23:52 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jul 29 04:39:45 2008 -0700 @@ -203,11 +203,14 @@ pass class CIM_MemResourceAllocationSettingData(CIMClassMOF): - def __init__(self, megabytes, name): + def __init__(self, mvirtquantity, mallocunits, name): self.ResourceType = RASD_TYPE_MEM - if megabytes != None: - self.VirtualQuantity = megabytes + if mvirtquantity != None: + self.VirtualQuantity = mvirtquantity + + if mallocunits != None: + self.AllocationUnits = mallocunits if name != None: self.InstanceID = '%s/mem' % name @@ -231,7 +234,8 @@ net_type='ethernet', net_mac=const.Xen_default_mac, proc_vcpu=1, - mem_mb=512, + mem_val=1024, + mem_allocunit="KiloBytes", virt='Xen'): class_vssd = get_vssd_class(virt) vssd = class_vssd(name=dom_name, virt=virt) @@ -257,7 +261,8 @@ class_masd = get_masd_class(virt) m = class_masd( - megabytes=mem_mb, + mvirtquantity=mem_val, + mallocunits=mem_allocunit, name=dom_name) if virt == 'LXC': return vssd.mof(), [d.mof(), m.mof()]

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217331858 25200 # Node ID 8c8ec47bc8492eacc1f5feff6ed6fd871451a9d0 # Parent ec303feee0e302ddf29b8dad81d0d4416e0fb48a 1) Added support for KVM 2) Removed the invalid bug nos. 3) Removed check_attributes() and used check_reqstate_value() library function instead. 4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool. 5) used destroy_and_undefine_domain() to undefine and destroy the VS. 6) Used try_request_state_change() library function to verify the exception. 7) Used poll_for_state_change() to verify the poll and verify the EnabledState value. The changes are verified with KVM Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r ec303feee0e3 -r 8c8ec47bc849 suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Tue Jul 29 04:39:45 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Tue Jul 29 04:44:18 2008 -0700 @@ -4,7 +4,7 @@ # # Authors: # Anoop V Chakkalakkal<anoop.vijayan@in.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 @@ -26,7 +26,7 @@ # information is captured in the RequestedState Property of the VS. # The test is considered to be successful if RequestedState Property # has a value of 9 when the VS is moved from active to suspend state -# and has a value of 9 when supended again +# and returns an excpetion when supended again. # # List of Valid state values (Refer to VSP spec doc Table 2 for more) # --------------------------------- @@ -39,84 +39,89 @@ # Date: 29-02-2008 import sys +import pywbem from VirtLib import utils from CimTest.Globals import do_main, logger -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from XenKvmLib.test_doms import undefine_test_domain -from XenKvmLib.common_util import get_cs_instance +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.common_util import create_using_definesystem from XenKvmLib.common_util import call_request_state_change +from XenKvmLib.common_util import try_request_state_change +from XenKvmLib.common_util import poll_for_state_change +from XenKvmLib.common_util import check_reqstate_value +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM'] ACTIVE_STATE = 2 SUSPND_STATE = 9 -bug_req_state = "00002" -default_dom = 'test_domain' +default_dom = 'cs_test_domain' TIME = "00000000000000.000000:000" - -def check_attributes(domain_name, ip, en_state, rq_state, virt): - rc, cs = get_cs_instance(domain_name, ip, virt) - if rc != 0: - return rc - if cs.RequestedState != rq_state: - logger.error("RequestedState should be %d not %d", - rq_state, cs.RequestedState) - return XFAIL_RC(bug_req_state) - - if cs.EnabledState != en_state: - logger.error("EnabledState should be %d not %d", - en_state, cs.EnabledState) - return FAIL - - return PASS +err_no = pywbem.CIM_ERR_FAILED +err_desc = "Domain not running" @do_main(sup_types) def main(): options = main.options - status = FAIL + server = options.ip + virt = options.virt + + status, test_network = create_netpool_conf(server, virt, False) + if status != PASS: + return FAIL tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ - ('Suspend', [SUSPND_STATE, SUSPND_STATE]), \ - ('Suspend', [SUSPND_STATE, SUSPND_STATE])] + ('Suspend', [SUSPND_STATE, SUSPND_STATE])] try: # define the vs status = create_using_definesystem(default_dom, - options.ip, - virt=options.virt) + server, + virt=virt) if status != PASS: - logger.error("Unable to define domain %s using DefineSystem()", \ - default_dom) + logger.error("Unable to define domain '%s' using DefineSystem()", + default_dom) return status - # start, suspend and suspend again + # start, suspend for action, state in tc_scen: en_state = state[0] rq_state = state[1] - status = call_request_state_change(default_dom, options.ip, - rq_state, TIME, options.virt) + status = call_request_state_change(default_dom, server, + rq_state, TIME, virt) if status != PASS: - logger.error("Unable to %s dom %s using \ -RequestedStateChange()", action, default_dom) + logger.error("Unable to '%s' dom '%s' using RequestedStateChange()", + action, default_dom) break - # FIX ME - # sleep() + status = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status = check_reqstate_value(default_dom, server, rq_state, virt) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break except Exception, detail: - logger.error("Exception: %s", detail) + logger.error("Exception: '%s'", detail) status = FAIL - # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status + + # try to suspend already suspended VS + rq_state = SUSPND_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt) + + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) return status

- # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status + + # try to suspend already suspended VS + rq_state = SUSPND_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt)
I'm not sure I see the benefit of this change. You're not verifying the state of the guest. It's possible for RequestStateChange() to return a success and for the guest to be in an unexpected state.
+ + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt)
return status
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

- # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status + + # try to suspend already suspended VS + rq_state = SUSPND_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt)
I'm not sure I see the benefit of this change. You're not verifying the state of the guest.
It's possible for RequestStateChange() to return a success and for the guest to be in an unexpected state. This particular test case was previously written with the assumption
Kaitlin Rupert wrote: that moving an already suspended VS to suspend state will not return any exception from the provider and is a valid state transition. But this is not true anymore. Also, the the above test case used to XFAIL sometime back because of the problem in RequestedStateChange() bug. The provider now returns an exception when we try to suspend the VS which is already in suspended state. The exception is checked in the try_request_state_change() library function. The part of the code in the loop which we execute is not suppose to return any exception. Hence the code in the loop and the one in try_request_state_change() cannot be combined together. Regarding validating the req_state value after try_request_state_change() can be done to make sure the state still remains the same as it was in before calling the RequestStateChange(). Thanks and Regards, Deepti.
+ + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt)
return status

+ + # try to suspend already suspended VS + rq_state = SUSPND_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt)
I'm not sure I see the benefit of this change. You're not verifying the state of the guest.
It's possible for RequestStateChange() to return a success and for the guest to be in an unexpected state. This particular test case was previously written with the assumption that moving an already suspended VS to suspend state will not return any exception from the provider and is a valid state transition. But this is not true anymore. Also, the the above test case used to XFAIL sometime back because of the problem in RequestedStateChange() bug. The provider now returns an exception when we try to suspend the VS which is already in suspended state. The exception is checked in the try_request_state_change() library function. The part of the code in the loop which we execute is not suppose to return any exception. Hence the code in the loop and the one in try_request_state_change() cannot be combined together. Regarding validating the req_state value after try_request_state_change() can be done to make sure the state still remains the same as it was in before calling the RequestStateChange().
I was thinking that all of the calls to RSC() should be handled the same way - because any call to RSC() could potentially cause an exception or an error. But in the case where you call suspend twice in a row, you don't have an easy way of distinguishing between the first suspend call and the second. So my logic fails here. You need some way to distinguish the two calls, and this works in that case. So I'm fine with this approach. ;) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217332058 25200 # Node ID 00e3d0fff2b8379a1882c78ceffeecb68c61c5e7 # Parent 8c8ec47bc8492eacc1f5feff6ed6fd871451a9d0 1) Removed the invalid bug nos. 2) Removed check_attributes() and used check_reqstate_value() library function instead. 3) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool. 4) Used destroy_and_undefine_domain() to undefine and destroy the VS. 5) Used poll_for_state_change() to verify the poll and verify the EnabledState value. The changes are verified with KVM, Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 8c8ec47bc849 -r 00e3d0fff2b8 suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Tue Jul 29 04:44:18 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Tue Jul 29 04:47:38 2008 -0700 @@ -4,6 +4,7 @@ # # Authors: # Anoop V Chakkalakkal<anoop.vijayan@in.ibm.com> +# Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # # # This library is free software; you can redistribute it and/or @@ -25,7 +26,7 @@ # This test case is used to verify the Virtual System State Transition # information is captured in the RequestedState Property of the VS. # The test is considered to be successful if RequestedState Property -# has a value of 10 when the VS is moved from active to reboot state +# has a value of 10 when the VS is moved from active to reboot state. # # List of Valid state values (Refer to VSP spec doc Table 2 for more) # --------------------------------- @@ -41,72 +42,64 @@ from VirtLib import utils from CimTest.Globals import do_main, logger from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from XenKvmLib.test_doms import undefine_test_domain -from XenKvmLib.common_util import get_cs_instance +from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.common_util import create_using_definesystem from XenKvmLib.common_util import call_request_state_change +from XenKvmLib.common_util import poll_for_state_change +from XenKvmLib.common_util import check_reqstate_value +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool sup_types = ['Xen', 'XenFV'] ACTIVE_STATE = 2 REBOOT_STATE = 10 -bug_req_state = "00002" -default_dom = 'test_domain' +default_dom = 'cs_test_domain' TIME = "00000000000000.000000:000" - -def check_attributes(domain_name, ip, en_state, rq_state, virt): - rc, cs = get_cs_instance(domain_name, ip, virt) - if rc != 0: - return rc - if cs.RequestedState != rq_state: - logger.error("RequestedState should be %d not %d", - rq_state, cs.RequestedState) - return XFAIL_RC(bug_req_state) - - if cs.EnabledState != en_state: - logger.error("EnabledState should be %d not %d", - en_state, cs.EnabledState) - return FAIL - - return PASS @do_main(sup_types) def main(): options = main.options status = FAIL + server = options.ip + virt = options.virt + + status, test_network = create_netpool_conf(server, virt, False) + if status != PASS: + return FAIL tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ ('Reboot', [ACTIVE_STATE, REBOOT_STATE])] try: # define the vs - status = create_using_definesystem(default_dom, options.ip, - virt=options.virt) + status = create_using_definesystem(default_dom, server, + virt=virt) if status != PASS: - logger.error("Unable to define domain %s using DefineSystem()", \ - default_dom) + logger.error("Unable to define domain '%s' using DefineSystem()", + default_dom) return status # start, then reboot for action, state in tc_scen: en_state = state[0] rq_state = state[1] - status = call_request_state_change(default_dom, options.ip, + status = call_request_state_change(default_dom, server, rq_state, TIME, - virt=options.virt) + virt=virt) if status != PASS: - logger.error("Unable to %s dom %s using \ -RequestedStateChange()", action, default_dom) + logger.error("Unable to '%s' dom '%s' using RequestedStateChange()", + action, default_dom) break - # FIX ME - # sleep() + status = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status = check_reqstate_value(default_dom, server, rq_state, virt) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break @@ -114,9 +107,8 @@ logger.error("Exception: %s", detail) status = FAIL - # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) - + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) return status if __name__ == "__main__":

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217332224 25200 # Node ID af243cf40f479c533eb54547f2260d99f63e316b # Parent 00e3d0fff2b8379a1882c78ceffeecb68c61c5e7 1) Added support for KVM 2) Removed the invalid bug nos. 3) Removed check_attributes() and used check_reqstate_value() library function instead. 4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool. 5) Used destroy_and_undefine_domain() to undefine and destroy the VS. 6) Used try_request_state_change() library function to verify the exception. 7) Used poll_for_state_change() to verify the poll and verify the EnabledState value. The changes are verified with KVM, Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 00e3d0fff2b8 -r af243cf40f47 suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Tue Jul 29 04:47:38 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Tue Jul 29 04:50:24 2008 -0700 @@ -4,6 +4,7 @@ # # Authors: # Anoop V Chakkalakkal<anoop.vijayan@in.ibm.com> +# Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # # # This library is free software; you can redistribute it and/or @@ -26,7 +27,8 @@ # information is captured in the RequestedState Property of the VS. # The test is considered to be successful if RequestedState Property # has a value of 9 when the VS is moved from active to suspend state -# and has a value of 10 when rebooted +# and when rebooted we should get an exception as this is not a valid +# state transition. # # List of Valid state values (Refer to VSP spec doc Table 2 for more) # --------------------------------- @@ -40,77 +42,72 @@ # Date: 06-03-2008 import sys +import pywbem from VirtLib import utils from CimTest.Globals import do_main, logger from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from XenKvmLib.test_doms import undefine_test_domain -from XenKvmLib.common_util import get_cs_instance +from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.common_util import create_using_definesystem from XenKvmLib.common_util import call_request_state_change +from XenKvmLib.common_util import poll_for_state_change +from XenKvmLib.common_util import check_reqstate_value +from XenKvmLib.common_util import try_request_state_change +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM'] ACTIVE_STATE = 2 SUSPND_STATE = 9 REBOOT_STATE = 10 -bug_req_state = "00002" default_dom = 'test_domain' TIME = "00000000000000.000000:000" - -def check_attributes(domain_name, ip, en_state, rq_state, virt): - rc, cs = get_cs_instance(domain_name, ip, virt) - if rc != 0: - return rc - if cs.RequestedState != rq_state: - logger.error("RequestedState should be %d not %d", - rq_state, cs.RequestedState) - return XFAIL_RC(bug_req_state) - - if cs.EnabledState != en_state: - logger.error("EnabledState should be %d not %d", - en_state, cs.EnabledState) - return FAIL - - return PASS +err_no = pywbem.CIM_ERR_FAILED +err_desc = "Domain not running" @do_main(sup_types) def main(): options = main.options status = FAIL + server = options.ip + virt = options.virt + + status, test_network = create_netpool_conf(server, virt, False) + if status != PASS: + return FAIL tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ - ('Suspend', [SUSPND_STATE, SUSPND_STATE]), \ - ('Reboot', [SUSPND_STATE, REBOOT_STATE])] + ('Suspend', [SUSPND_STATE, SUSPND_STATE])] try: # define the vs - status = create_using_definesystem(default_dom, options.ip, - virt=options.virt) + status = create_using_definesystem(default_dom, server, + virt=virt) if status != PASS: - logger.error("Unable to define domain %s using DefineSystem()", \ - default_dom) + logger.error("Unable to define domain '%s' using DefineSystem()", + default_dom) return status # start, suspend and reboot for action, state in tc_scen: en_state = state[0] rq_state = state[1] - status = call_request_state_change(default_dom, options.ip, + status = call_request_state_change(default_dom, server, rq_state, TIME, - virt=options.virt) + virt=virt) if status != PASS: - logger.error("Unable to %s dom %s using \ -RequestedStateChange()", action, default_dom) + logger.error("Unable to '%s' dom '%s' using RequestedStateChange()", + action, default_dom) break - # FIX ME - # sleep() + status = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status = check_reqstate_value(default_dom, server, rq_state, virt) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break @@ -118,9 +115,19 @@ logger.error("Exception: %s", detail) status = FAIL - # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status + # Try to reboot the VS which is suspened + rq_state = REBOOT_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt) + + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) return status if __name__ == "__main__":

- # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status
+ # Try to reboot the VS which is suspened + rq_state = REBOOT_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt) +
Also here, you don't verify the guest has been rebooted properly. Is there a reason to pull this piece out of the loop? Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
- # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) + if status != PASS: + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) + return status
+ # Try to reboot the VS which is suspened + rq_state = REBOOT_STATE + status = try_request_state_change(default_dom, server, + rq_state, TIME, err_no, + err_desc, virt) +
Also here, you don't verify the guest has been rebooted properly. Is there a reason to pull this piece out of the loop?
The test case returns an exception when we try to reboot VS when it is in suspended state. The part of the code in the loop which we execute is not suppose to return any exception. Hence the code in the loop and the one in try_request_state_change() cannot be combined together. Regarding validating the req_state value after try_request_state_change() can be done to make sure the state still remains the same as it was in before calling the RequestStateChange(). Thanks and Regards, Deepti.
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

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217332491 25200 # Node ID f1ca2afeec3e973028686fab4fddde3ddbd375de # Parent af243cf40f479c533eb54547f2260d99f63e316b 1) Added support for KVM 2) Removed the invalid bug nos. 3) Removed check_attributes() and used check_reqstate_value() library function instead. 4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool. 5) Used destroy_and_undefine_domain() to undefine and destroy the VS. 6) Used poll_for_state_change() to verify the poll and verify the EnabledState value. The changes are verified with KVM, Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r af243cf40f47 -r f1ca2afeec3e suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Tue Jul 29 04:50:24 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Tue Jul 29 04:54:51 2008 -0700 @@ -4,6 +4,7 @@ # # Authors: # Anoop V Chakkalakkal<anoop.vijayan@in.ibm.com> +# Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # # # This library is free software; you can redistribute it and/or @@ -41,83 +42,76 @@ import sys from VirtLib import utils from CimTest.Globals import do_main, logger -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from XenKvmLib.test_doms import undefine_test_domain +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.common_util import get_cs_instance from XenKvmLib.common_util import create_using_definesystem from XenKvmLib.common_util import call_request_state_change +from XenKvmLib.common_util import poll_for_state_change +from XenKvmLib.common_util import check_reqstate_value +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM'] ACTIVE_STATE = 2 RESET_STATE = 11 -bug_req_state = "00002" -default_dom = 'test_domain' +default_dom = 'cs_test_domain' TIME = "00000000000000.000000:000" - -def check_attributes(domain_name, ip, en_state, rq_state, virt): - rc, cs = get_cs_instance(domain_name, ip, virt) - if rc != 0: - return rc - if cs.RequestedState != rq_state: - logger.error("RequestedState should be %d not %d", - rq_state, cs.RequestedState) - return XFAIL_RC(bug_req_state) - - if cs.EnabledState != en_state: - logger.error("EnabledState should be %d not %d", - en_state, cs.EnabledState) - return FAIL - - return PASS @do_main(sup_types) def main(): options = main.options status = FAIL + server = options.ip + virt = options.virt + + status, test_network = create_netpool_conf(server, virt, False) + if status != PASS: + return FAIL tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ ('Reset', [ACTIVE_STATE, RESET_STATE])] try: # define the vs - status = create_using_definesystem(default_dom, options.ip, - virt=options.virt) + status = create_using_definesystem(default_dom, server, + virt=virt) if status != PASS: - logger.error("Unable to define domain %s using DefineSystem()", \ - default_dom) + logger.error("Unable to define domain '%s' using DefineSystem()", + default_dom) return status # start and reset for action, state in tc_scen: en_state = state[0] rq_state = state[1] - status = call_request_state_change(default_dom, options.ip, + status = call_request_state_change(default_dom, server, rq_state, TIME, - virt=options.virt) + virt=virt) if status != PASS: - logger.error("Unable to %s dom %s using \ -RequestedStateChange()", action, default_dom) + logger.error("Unable to '%s' dom '%s' using RequestedStateChange()", + action, default_dom) break - # FIX ME - # sleep() + status = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status = check_reqstate_value(default_dom, server, rq_state, virt) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break + except Exception, detail: logger.error("Exception: %s", detail) status = FAIL - # undefine the vs - undefine_test_domain(default_dom, options.ip, options.virt) - + destroy_netpool(server, virt, test_network) + destroy_and_undefine_domain(default_dom, server, virt) return status if __name__ == "__main__":
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert