[PATCH 0 of 2] [TEST] Indications related fixes.

The first patch is a mirror of a change that was may in the libcmpiutil indication_tester.py. The second patch fixes a false positive situation. See commit log for details.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214946766 25200 # Node ID c5c60637d2ab399491b204ba1e4cbd00e9266416 # Parent 5872801b69296bac39b1b5060e6de2643471f290 [TEST] Based on recent updates to the indication_tester.py in libcmpiutil. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 5872801b6929 -r c5c60637d2ab suites/libvirt-cim/lib/XenKvmLib/indication_tester.py --- a/suites/libvirt-cim/lib/XenKvmLib/indication_tester.py Tue Jul 01 13:59:11 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/indication_tester.py Tue Jul 01 14:12:46 2008 -0700 @@ -81,7 +81,7 @@ <VALUE>%sHandler</VALUE> </PROPERTY> <PROPERTY NAME="Destination" TYPE="string"> - <VALUE>localhost:%i</VALUE> + <VALUE>http://localhost:%i</VALUE> </PROPERTY> </INSTANCE> </IPARAMVALUE>

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214946768 25200 # Node ID 1565499973597852f4ce91f93f611683f777ae2b # Parent c5c60637d2ab399491b204ba1e4cbd00e9266416 [TEST] Fix false positive in CSI 01_created_indication.py Test was not checking the return of waitpid() properly. Also, in the case of failure, the status value wasn't being set properly. Replace sys.exit() with os._exit() in child process. Only attempt to kill child process if the child didn't exit properly on its own. Fix some line length issues. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c5c60637d2ab -r 156549997359 suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py --- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jul 01 14:12:46 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jul 01 14:12:48 2008 -0700 @@ -43,10 +43,13 @@ status = FAIL dict = set_default(options.ip) - indication_name = get_typed_class(options.virt, 'ComputerSystemCreatedIndication') + 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 = 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) @@ -56,39 +59,55 @@ sub.server.handle_request() if len(sub.server.indications) == 0: logger.error("No valid indications received") - sys.exit(1) + os._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) + logger.error("Received indication %s instead of %s" % \ + (indication_name, str(sub.server.indications[0]))) + os._exit(2) else: - sys.exit(0) + os._exit(0) else: - status = create_using_definesystem(test_dom, options.ip, None, None, options.virt) + status = create_using_definesystem(test_dom, options.ip, None, None, + options.virt) if status != PASS: sub.unsubscribe(dict['default_auth']) logger.info("Cancelling subscription for %s" % indication_name) os.kill(pid, signal.SIGKILL) return status + status = FAIL for i in range(0,100): - pw = os.waitpid(pid, os.WNOHANG)[1] - if pw == 0: + pw = os.waitpid(pid, os.WNOHANG) + + # If pid exits, waitpid returns [pid, return_code] + # If pid is still running, waitpid returns [0, 0] + # Only return a success if waitpid returns the expected pid + # and the return code is 0. + if pw[0] == pid and pw[1] == 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") + elif pw[1] == 0 and i < 99: + if i % 10 == 0: + logger.info("In child process, waiting for indication") time.sleep(1) else: - logger.error("Received indication error or wait too long") + status = FAIL + + # Time is up and waitpid never returned the expected pid + if pw[0] != pid: + logger.error("Waited too long for indication") + os.kill(pid, signal.SIGKILL) + else: + logger.error("Received indication error: %d" % pw[1]) break + except Exception, details: logger.error("Unknown exception happened") logger.error(details) 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

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1214946768 25200 KR> # Node ID 1565499973597852f4ce91f93f611683f777ae2b KR> # Parent c5c60637d2ab399491b204ba1e4cbd00e9266416 KR> [TEST] Fix false positive in CSI 01_created_indication.py +1 Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert