[Libvirt-cim] [PATCH 5 of 7] [TEST] Added KVM support to 32_start_reboot.py of CS

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Mon Aug 4 06:28:49 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at 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 at 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 at in.ibm.com>
+#    Deepti B. Kalakeri<deeptik at 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__":




More information about the Libvirt-cim mailing list