
+1 for me :). Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216741569 25200 # Node ID 0b2f67eed74e01561029d4c46fc8d54716e9b462 # Parent 9fb3407dd5098ab438653d4854d77b44ff9888e1 [TEST] #4 Fix CS 22 to use providers instead of virsh.
This test was defining a guest with virsh and then suspending it with virsh, which doesn't touch the providers in anyway. Now the test calls DefineSystem() and RequestStateChange().
Updates from 1 to 2: -Add check to verify guest is the expected state after the RequestStateChange() call. -Create a network pool because the VSMS provider requires a network pool to exist in order to create a guest.
Updates from 2 to 3: -Remove destroy_netpool() if create_netpool_conf() fails. This is not needed.
Updates from 3 to 4: -Changed log message from "%s not in defined state as expected." to "%s should have been in defined state"
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 9fb3407dd509 -r 0b2f67eed74e suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Mon Jul 21 09:51:32 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Tue Jul 22 08:46:09 2008 -0700 @@ -32,54 +32,71 @@ from XenKvmLib import computersystem from VirtLib import utils from XenKvmLib import vxml -from XenKvmLib.test_doms import destroy_and_undefine_all -from CimTest.Globals import do_main -from CimTest import Globals +from XenKvmLib.test_doms import destroy_and_undefine_domain +from CimTest.Globals import do_main, logger from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import create_using_definesystem, \ + call_request_state_change, get_cs_instance, \ + create_netpool_conf, destroy_netpool
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] test_dom = "domgst"
+DEFINE_STATE = 3 +SUSPND_STATE = 9 +TIME = "00000000000000.000000:000" + +def chk_state(domain_name, ip, en_state, virt): + rc, cs = get_cs_instance(domain_name, ip, virt) + if rc != 0: + return rc + + 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 - - cxml = vxml.get_class(options.virt)(test_dom)
-#define VS + status, test_network = create_netpool_conf(options.ip, options.virt) + if status != PASS: + return FAIL + try: - ret = cxml.define(options.ip) - if not ret: - Globals.logger.error(Globals.VIRSH_ERROR_DEFINE % test_dom) - return status - - cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom) - if not (cs.Name == test_dom) : - Globals.logger.error("Error: VS %s not found" % test_dom) - cxml.undefine(options.ip) + # define the vs + status = create_using_definesystem(test_dom, options.ip, + virt=options.virt) + if status != PASS: + logger.error("Unable to define %s using DefineSystem()" % test_dom) + destroy_netpool(options.ip, options.virt, test_network) return status
- except Exception, detail: - Globals.logger.error("Errors: %s" % detail) + # suspend the vs + status = call_request_state_change(test_dom, options.ip, SUSPND_STATE, + TIME, virt=options.virt) + if status != PASS: + logger.info("Suspending defined %s failed, as expected" % test_dom) + status = PASS
-#Suspend the defined VS - - try: - ret = cxml.run_virsh_cmd(options.ip, "suspend") - if not ret : - Globals.logger.info("Suspending defined VS %s failed, as expected" \ -% test_dom) - status = PASS + status = chk_state(test_dom, options.ip, DEFINE_STATE, options.virt) + if status != PASS: + logger.error("%s should have been in defined state" % test_dom) + status = FAIL + else : - Globals.logger.info("Error: Suspending defined VS %s should not \ -have been allowed" % test_dom) + logger.error("Suspending defined %s should have failed" % test_dom) status = FAIL
except Exception, detail: - Globals.logger.error("Error: %s" % detail) + logger.error("Error: %s" % detail) + status = FAIL
- ret = cxml.undefine(options.ip) + destroy_netpool(options.ip, options.virt, test_network) + destroy_and_undefine_domain(test_dom, options.ip, options.virt) return status
if __name__ == "__main__":
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim