[PATCH 0 of 7] Changes to common_util.py library and test cases affected changes.

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) Changed the poll_for_state_change() function to return cs instance along with the status. 5) Added KVM support to 23_suspend_suspend.py, 32_start_reboot.py, 33_suspend_reboot.py, 35_start_reset.py. 6) Fixing 06_paused_active_suspend.py tc. 7) Updated 09_procrasd_persist.py to accomdate the poll_for_state_change() changes. 8) Updated 01_migratable_host.py and 02_host_migrate_type.py to accomdate the poll_for_state_change() changes. For the tc to work on KVM, this patchset is dependent on the vsms library related changes submit as part of "Adding AllocationUnits field to MemRASD and updating the call to MemRASD in the libraries where it is accessed." patch. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830031 25200 # Node ID 5e9892634c019ddb4fb95abd47959ab3a5e67e0e # Parent 00331e6468e447afad6ea78b96cf26f08d4582f4 [TEST] Adding verify_err_desc(), Modifying poll_for_state_change() and Fixing get_cs_instance(). 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) Changed the poll_for_state_change() function to return cs instance along with the status. The changes are verified with KVM, Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 00331e6468e4 -r 5e9892634c01 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Fri Aug 01 11:16:25 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Aug 03 23:07:11 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,11 +145,27 @@ 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): + dom_cs = None cs = computersystem.get_cs_class(virt) try: @@ -146,22 +174,22 @@ dom_cs = cs(server, name=dom) if dom_cs is None or dom_cs.Name != dom: logger.error("CS instance not returned for %s." % dom) - return FAIL + return FAIL, dom_cs if dom_cs.EnabledState == exp_state: break except Exception, detail: logger.error("Exception: %s" % detail) - return FAIL + return FAIL, dom_cs if dom_cs.EnabledState != exp_state: logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState, exp_state)) logger.error("Try to increase the timeout and run the test again") - return FAIL + return FAIL, dom_cs - return PASS + return PASS, dom_cs def get_host_info(server, virt="Xen"): status = PASS @@ -191,20 +219,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 +233,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 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
I think this is a special case and that we don't need a separate function for this. There will only be a few cases where this is used, I think. Or maybe it's possible to modify call_request_state_change(0 to handle errors?
def poll_for_state_change(server, virt, dom, exp_state, timeout=30): + dom_cs = None cs = computersystem.get_cs_class(virt)
try: @@ -146,22 +174,22 @@ dom_cs = cs(server, name=dom) if dom_cs is None or dom_cs.Name != dom: logger.error("CS instance not returned for %s." % dom) - return FAIL + return FAIL, dom_cs
if dom_cs.EnabledState == exp_state: break
except Exception, detail: logger.error("Exception: %s" % detail) - return FAIL + return FAIL, dom_cs
if dom_cs.EnabledState != exp_state: logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState, exp_state)) logger.error("Try to increase the timeout and run the test again") - return FAIL + return FAIL, dom_cs
- return PASS + return PASS, dom_cs
This is a good set of changes - thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830288 25200 # Node ID 4ed904b18000ef148cb82e6b28729460970cca24 # Parent 5e9892634c019ddb4fb95abd47959ab3a5e67e0e [TEST] Fixing the 06_paused_active_suspend.py tc of ComputerSystem. 1) Updated the tc to use the poll_for_state_change() function. 2) Removed cxml.undefine() call since it was not req. 3) Fixed Indentation. 4) Removed the bug no 0002 since it is fixed. 5) Added create_netpool_conf(), destroy_netpool() The changes are verified with KVM, Xen, XenFV with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 5e9892634c01 -r 4ed904b18000 suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Sun Aug 03 23:07:11 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Sun Aug 03 23:11:28 2008 -0700 @@ -41,110 +41,100 @@ # Date :18-10-2007 import sys -from time import sleep from XenKvmLib import computersystem from XenKvmLib import vxml from VirtLib import utils from XenKvmLib.test_doms import destroy_and_undefine_all from CimTest.Globals import logger from CimTest.Globals import do_main -from XenKvmLib.common_util import call_request_state_change -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from XenKvmLib.common_util import call_request_state_change, \ +poll_for_state_change +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool sup_types = ['Xen', 'KVM', 'XenFV'] test_dom = "DomST1" mem = 128 # MB -# Keeping the bug no for future reference -# bug_no_req_change_method = "90559" -bug_no_req_change_prop = "00002" START_STATE = 2 FINAL_STATE = 9 -REQUESTED_STATE = FINAL_STATE TIME = "00000000000000.000000:000" @do_main(sup_types) def main(): options = main.options status = FAIL + server = options.ip + virt = options.virt + + destroy_and_undefine_all(server) + status, test_network = create_netpool_conf(server, virt) + if status != PASS: + return FAIL - cxml = vxml.get_class(options.virt)(test_dom, mem) + cxml = vxml.get_class(virt)(test_dom, mem) -#Create VS + #Create VS try: - ret = cxml.create(options.ip) + ret = cxml.create(server) if not ret: - logger.error("ERROR: VS %s was not created" % test_dom) - return status - cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom) - if cs.Name == test_dom: - from_State = cs.EnabledState - else: - logger.error("ERROR: VS %s not found" % test_dom) + logger.error("VS '%s' was not created" % test_dom) return status except Exception, detail: logger.error("Exception variable: %s" % detail) - cxml.destroy(options.ip) - cxml.undefine(options.ip) return status -#Suspend the VS - rc = call_request_state_change(test_dom, options.ip, REQUESTED_STATE, - TIME, options.virt) - if rc != 0: - logger.error("Unable to suspend dom %s using RequestedStateChange()", test_dom) - cxml.destroy(options.ip) - cxml.undefine(options.ip) - return status -#Polling for the value of EnabledState to be set to 9. -#We need to wait for the EnabledState to be set appropriately since -#it does not get set immediatley to value of 9 when suspended. - timeout = 10 - try: + status, dom_cs = poll_for_state_change(server, virt, test_dom, + START_STATE) - for i in range(1, (timeout + 1)): - sleep(1) - cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom) - if cs.Name == test_dom: - to_RequestedState = cs.RequestedState - enabledState = cs.EnabledState - else: - logger.error("VS %s not found" % test_dom) - return status - if enabledState == FINAL_STATE: - status = PASS - break - - except Exception, detail: - logger.error("Exception variable: %s" % detail) + if status != PASS: + cxml.destroy(server) + destroy_netpool(server, virt, test_network) return status - if enabledState != FINAL_STATE: - logger.error("EnabledState has %i instead of %i", enabledState, FINAL_STATE) - logger.error("Try to increase the timeout and run the test again") + from_State = dom_cs.EnabledState + + #Suspend the VS + status = call_request_state_change(test_dom, server, FINAL_STATE, + TIME, virt) + if status != PASS: + logger.error("Unable to suspend dom '%s' using RequestedStateChange()", + test_dom) + cxml.destroy(server) + destroy_netpool(server, virt, test_network) + return status + + #Polling for the value of EnabledState to be set to 9. + #We need to wait for the EnabledState to be set appropriately since + #it does not get set immediatley to value of 9 when suspended. + status, dom_cs = poll_for_state_change(server, virt, test_dom, + FINAL_STATE, timeout=40) if status != PASS: - ret = cxml.destroy(options.ip) - cxml.undefine(options.ip) + cxml.destroy(server) + destroy_netpool(server, virt, test_network) return status -# Success: -# if -# From state == 9 -# To state == 2 -# Enabled_state == RequestedState + enabledState = dom_cs.EnabledState + to_RequestedState = dom_cs.RequestedState + + # Success: + # if + # From state == 2 + # To state == 9 + # Enabled_state == RequestedState if from_State == START_STATE and \ to_RequestedState == FINAL_STATE and \ - enabledState == to_RequestedState: + to_RequestedState == enabledState: status = PASS else: - logger.error("ERROR: VS %s transition from suspend State to Activate state \ - was not Successful" % test_dom) -# Replace the status with FAIL once the bug is fixed. - status = XFAIL_RC(bug_no_req_change_prop) - ret = cxml.destroy(options.ip) - cxml.undefine(options.ip) + logger.error("VS '%s' transition from Activate State to Suspend State" + " was not Successful" % test_dom) + status = FAIL + + cxml.destroy(server) + destroy_netpool(server, virt, test_network) + return status - if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830581 25200 # Node ID a5b12e49cfe1db373f34bd35cf20060ca74f83a7 # Parent 4ed904b18000ef148cb82e6b28729460970cca24 [TEST] Updating the test cases which are affected by poll_for_state_change() library function changes. 1) Updated 09_procrasd_persist.py to accomdate the poll_for_state_change() changes. Also, modified to include the create_netpool_conf(), destroy_netpool() functions. 2) Updated 01_migratable_host.py and 02_host_migrate_type.py to accomdate the poll_for_state_change() changes. The changes are verified with KVM, Xen, XenFV with current sources. 01_migratable_host.py and 02_host_migrate_type.py are skipped for KVM and should be supported to work on KVM. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 4ed904b18000 -r a5b12e49cfe1 suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py Sun Aug 03 23:11:28 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py Sun Aug 03 23:16:21 2008 -0700 @@ -30,6 +30,7 @@ from CimTest.Globals import do_main from CimTest.ReturnCodes import FAIL, PASS from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool sup_types = ['Xen', 'XenFV', 'KVM'] default_dom = 'rstest_domain' @@ -94,6 +95,11 @@ def main(): options = main.options + status, test_network = create_netpool_conf(options.ip, options.virt, False) + if status != PASS: + return FAIL + + status, vssd, rasd = setup_rasd_mof(options.ip, options.virt) if status != PASS: return status @@ -111,8 +117,8 @@ raise Exception("Unable to start %s using RequestedStateChange()" % default_dom) - status = poll_for_state_change(options.ip, options.virt, default_dom, - REQUESTED_STATE) + status, dom_cs = poll_for_state_change(options.ip, options.virt, default_dom, + REQUESTED_STATE) if status != PASS: raise Exception("%s didn't change state as expected" % default_dom) @@ -128,6 +134,7 @@ logger.error(details) status = FAIL + destroy_netpool(options.ip, options.virt, test_network) destroy_and_undefine_domain(default_dom, options.ip, options.virt) return status diff -r 4ed904b18000 -r a5b12e49cfe1 suites/libvirt-cim/cimtest/VirtualSystemMigrationService/01_migratable_host.py --- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/01_migratable_host.py Sun Aug 03 23:11:28 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/01_migratable_host.py Sun Aug 03 23:16:21 2008 -0700 @@ -49,8 +49,8 @@ logger.error("Error create domain %s" % guest_name) return FAIL - status = poll_for_state_change(ip, virt, guest_name, - REQUESTED_STATE) + status, dom_cs = poll_for_state_change(ip, virt, guest_name, + REQUESTED_STATE) if status != PASS: raise Exception("%s didn't change state as expected" % guest_name) return FAIL diff -r 4ed904b18000 -r a5b12e49cfe1 suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py --- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py Sun Aug 03 23:11:28 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py Sun Aug 03 23:16:21 2008 -0700 @@ -99,8 +99,8 @@ cxml = virt_xml(guest_name) cxml.start(ip) - status = poll_for_state_change(ip, virt, guest_name, - REQUESTED_STATE) + status, dom_cs = poll_for_state_change(ip, virt, guest_name, + REQUESTED_STATE) if status != PASS: raise Exception("%s didn't change state as expected" % guest_name) return FAIL, None

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830744 25200 # Node ID 776e7915449e10bf12562be362eb14d2599a0445 # Parent a5b12e49cfe1db373f34bd35cf20060ca74f83a7 [TEST] Adding KVM support to 23_suspend_suspend.py of CS. 1) Added support for KVM 2) Removed the invalid bug nos. 3) Removed check_attributes() function. 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 and also to get the RequestedState 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 a5b12e49cfe1 -r 776e7915449e suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Sun Aug 03 23:16:21 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Sun Aug 03 23:19:04 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,87 @@ # 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 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, dom_cs = poll_for_state_change(server, virt, default_dom, en_state, + timeout=30) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) - if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + if dom_cs.RequestedState != rq_state: + 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

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830823 25200 # Node ID 0da57be7b99849de19732a5affec07739a8c6f37 # Parent 776e7915449e10bf12562be362eb14d2599a0445 [TEST] Added KVM support to 32_start_reboot.py of CS. 1) Removed the invalid bug nos. 2) Removed check_attributes() . 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 and to get the RequestedState 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 776e7915449e -r 0da57be7b998 suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Sun Aug 03 23:19:04 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Sun Aug 03 23:20:23 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,63 @@ 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 create_netpool_conf, destroy_netpool -sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM'] +bug_req_state = "00002" 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) + status = XFAIL_RC(bug_req_state) break - # FIX ME - # sleep() - - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + break + + if dom_cs.RequestedState != rq_state: + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break @@ -114,9 +106,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__":

@@ -41,72 +42,63 @@ 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 create_netpool_conf, destroy_netpool
-sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM']
+bug_req_state = "00002"
Is this still an issue? Dan submitted a patch that should fix this. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
@@ -41,72 +42,63 @@ 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 create_netpool_conf, destroy_netpool
-sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM']
+bug_req_state = "00002"
Is this still an issue? Dan submitted a patch that should fix this.
For a KVM guest the RequestedStateChange() fails to reboot the VS. Here is the error which occurs when we try to reboot a KVM guest. libvir: error : this function is not supported by the hypervisor: virDomainReboot error: Failed to reboot domain cs_test_domain Here is the XML config file which I used to create the guest. <domain type='kvm'> <uuid>a980e2f5-48a6-48d9-a71b-e90939849c7a</uuid> <name>cs_test_domain</name> <on_poweroff>destroy</on_poweroff> <on_crash>destroy</on_crash> <os> <type>hvm</type> <boot dev='hd'/> </os> <currentMemory>524288</currentMemory> <memory>524288</memory> <vcpu>1</vcpu> <devices> <interface type='network'> <mac address='11:22:33:aa:bb:cc'/> <source network='default-net14'/> </interface> <disk type='file' device='disk'> <source file='/tmp/default-kvm-dimage'/> <target dev='hda'/> </disk> <graphics type='vnc' port='-1'/> </devices> </domain> I had already informed about this particular problem in the previous mail "Need CS state transition related info." Thanks and Regards, Deepti.

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
@@ -41,72 +42,63 @@ 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 create_netpool_conf, destroy_netpool
-sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM']
+bug_req_state = "00002"
Is this still an issue? Dan submitted a patch that should fix this.
For a KVM guest the RequestedStateChange() fails to reboot the VS. Here is the error which occurs when we try to reboot a KVM guest. libvir: error : this function is not supported by the hypervisor: virDomainReboot error: Failed to reboot domain cs_test_domain
I had already informed about this particular problem in the previous mail "Need CS state transition related info."
I think there should be a different bug number for this. Bug 00002 was because the providers were persisting the state properly. This particular issue is because libvirt doesn't support reboot for KVM, and the provider isn't handling the reboot on its own. Can you add a different bug number to the wiki and change the bug number in the test? Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
@@ -41,72 +42,63 @@ 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 create_netpool_conf, destroy_netpool
-sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM']
+bug_req_state = "00002"
Is this still an issue? Dan submitted a patch that should fix this.
For a KVM guest the RequestedStateChange() fails to reboot the VS. Here is the error which occurs when we try to reboot a KVM guest. libvir: error : this function is not supported by the hypervisor: virDomainReboot error: Failed to reboot domain cs_test_domain
I had already informed about this particular problem in the previous mail "Need CS state transition related info."
I think there should be a different bug number for this. Bug 00002 was because the providers were persisting the state properly. This particular issue is because libvirt doesn't support reboot for KVM, and the provider isn't handling the reboot on its own. Since this was related to RSC() call I thought of using the existing bug number and I know this bug no could be misleading. Also, I was not sure if I could create a new one.
Can you add a different bug number to the wiki and change the bug number in the test? Yeah sure, I will update the wiki with the new bug number and send a new
Kaitlin Rupert wrote: patch.
Thanks!

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1217830892 25200 # Node ID 2776112e3333225f5007bd359ec3c53d795ae90f # Parent 0da57be7b99849de19732a5affec07739a8c6f37 [TEST] Added KVM support to 33_suspend_reboot.py of CS provider. 1) Added support for KVM, added XFAIL_RC bcs the VS fails to move from suspend to reboot. 2) Removed check_attributes(). 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 try_request_state_change() library function to verify the exception. 6) Used poll_for_state_change() to verify the poll and verify the EnabledState value and also get the RequestedState 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 0da57be7b998 -r 2776112e3333 suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Sun Aug 03 23:20:23 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Sun Aug 03 23:21:32 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,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 10 when rebooted +# and when rebooted the value of RequestedState should be 10. # # List of Valid state values (Refer to VSP spec doc Table 2 for more) # --------------------------------- @@ -40,77 +41,71 @@ # 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 try_request_state_change +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -sup_types = ['Xen', 'XenFV'] +sup_types = ['Xen', 'XenFV', 'KVM'] +bug_req_state = "00002" 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 @do_main(sup_types) def main(): options = main.options status = FAIL + server = options.ip + virt = options.virt - tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ - ('Suspend', [SUSPND_STATE, SUSPND_STATE]), \ - ('Reboot', [SUSPND_STATE, REBOOT_STATE])] + 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])] 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) + status = XFAIL_RC(bug_req_state) break - # FIX ME - # sleep() - - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) + status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state, + timeout=10) if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + break + + if dom_cs.RequestedState != rq_state: + logger.error("RequestedState for dom '%s' is not set as expected.", default_dom) break @@ -118,9 +113,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 1217830969 25200 # Node ID 56ae86dadb4d67ebcfce703e3895c7fb8a118c58 # Parent 2776112e3333225f5007bd359ec3c53d795ae90f [TEST] Added support for KVM to 35_start_reset.py of CS provider. 1) Added support for KVM 2) Removed the invalid bug nos. 3) Removed check_attributes() . 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 and get RequestedState 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 2776112e3333 -r 56ae86dadb4d suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Sun Aug 03 23:21:32 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Sun Aug 03 23:22:49 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,74 @@ 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 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 - tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \ + 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, dom_cs = poll_for_state_change(server, virt, default_dom, en_state, + timeout=30) + if status != PASS: + break - status = check_attributes(default_dom, options.ip, - en_state, rq_state, options.virt) - if status != PASS: - logger.error("Attributes for dom %s not set as expected.", + if dom_cs.RequestedState != rq_state: + 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