[Libvirt-cim] [PATCH 2 of 2] [TEST] add ComputerSystemCreatedIndication test case

Guo Lian Yun yunguol at cn.ibm.com
Mon Mar 31 06:04:51 UTC 2008


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1206943438 25200
# Node ID 4bf2d38a4ce6d74c4834ade3177d12dc03bc26d8
# Parent  769a9211a486b64e6a3dedcd964ab6c93989202b
[TEST] add ComputerSystemCreatedIndication test case

Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>

diff -r 769a9211a486 -r 4bf2d38a4ce6 suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py	Sun Mar 30 23:03:58 2008 -0700
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+# 
+# Authors:
+#     Guolian Yun <yunguol at cn.ibm.com>
+# 
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License, or (at your option) any later version.
+# 
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+# 
+#  You should have received a copy of the GNU General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+# 
+
+import sys
+import os
+import signal
+import time
+from CimTest.Globals import log_param, logger
+from CimTest.Globals import do_main
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.common_util import create_using_definesystem 
+from XenKvmLib.test_doms import undefine_test_domain
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.indication_tester import CIMIndicationSubscription
+from XenKvmLib.vxml import set_default
+
+SUPPORTED_TYPES = ['Xen', 'XenFV', 'KVM']
+
+test_dom = "domU"
+
+ at do_main(SUPPORTED_TYPES)
+def main():
+    options = main.options
+    log_param()
+    status = FAIL
+
+    dict = set_default(options.ip)
+    indication_name = get_typed_class(options.virt, 'ComputerSystemCreatedIndication')
+    
+    sub = CIMIndicationSubscription(dict['default_name'], indication_name, dict['default_ns'],
+                                    dict['default_print_ind'], dict['default_sysname'])
+    sub.subscribe(dict['default_url'], dict['default_auth'])
+    logger.info("Watching for %s" % indication_name)
+     
+    try:
+        pid = os.fork()
+        if pid == 0:
+            sub.server.handle_request() 
+            if len(sub.server.indications) == 0:
+                logger.error("No valid indications received")
+                sys.exit(1)
+            elif str(sub.server.indications[0]) != indication_name:
+                logger.error("Received indication %s instead of %s" % (indication_name, str(sub.server.indications[0])))
+                sys.exit(2)
+            else:
+                sys.exit(0)
+        else:
+            create_using_definesystem(test_dom, options.ip, None, None, options.virt)
+            for i in range(0,100):
+                pw = os.waitpid(pid, os.WNOHANG)[1]
+                if pw == 0:
+                    logger.info("Great, got indication successfuly")
+                    status = PASS
+                    break
+                elif pw == 1 and i < 99:
+                    logger.info("still in child process, waiting for indication")
+                    time.sleep(1)
+                else:
+                    logger.error("Received indication error or wait too long")
+                    break 
+    except Exception, details:
+            logger.error("Unknown exception happened")
+            logger.error(details)
+    finally:    
+        sub.unsubscribe(dict['default_auth'])
+        logger.info("Cancelling subscription for %s" % indication_name)
+        os.kill(pid, signal.SIGKILL)
+        undefine_test_domain(test_dom, options.ip, options.virt)
+
+    return status
+
+if __name__=="__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list