<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-11-21
07:40:49:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1227224423 28800<br>
> # Node ID 4a3c5475c406dee444745f0c0d07fd237c6543c3<br>
> # Parent 648a7d0bb2f95fab9d43802326745157ece6bec7<br>
> [TEST] Fix CSI issues.<br>
> <br>
> Fixed bug in error message, also fixed handle_request() to deal with
the way<br>
> sfcb returns indications.<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r 648a7d0bb2f9 -r 4a3c5475c406 suites/libvirt-<br>
> cim/cimtest/ComputerSystemIndication/01_created_indication.py<br>
> --- a/suites/libvirt-<br>
> cim/cimtest/ComputerSystemIndication/01_created_indication.py
Fri <br>
> Nov 14 15:38:42 2008 -0800<br>
> +++ b/suites/libvirt-<br>
> cim/cimtest/ComputerSystemIndication/01_created_indication.py
Thu <br>
> Nov 20 15:40:23 2008 -0800<br>
> @@ -97,19 +97,29 @@<br>
> <br>
> return FAIL <br>
> <br>
> -def handle_request(sub, ind_name):<br>
> - sub.server.handle_request() <br>
> - if len(sub.server.indications) == 0:<br>
> - logger.error("No valid indications
received")<br>
> - return FAIL<br>
> - elif str(sub.server.indications[0]) != ind_name:<br>
> - logger.error("Received indication
%s instead of %s" % \<br>
> -
(str(sub.server.indications[0])), ind_name)<br>
> - return FAIL<br>
> +def handle_request(sub, ind_name, dict, exp_ind_ct):<br>
> + #sfcb delivers indications to all registrations, even
if the indication<br>
> + #isn't what the registration was subscribed to. So,
for modified and <br>
> + #deleted indications, we must loop through until the
indication we are<br>
> + #looking for is triggered.<br>
> + for i in range(0, exp_ind_ct):<br>
> + sub.server.handle_request() <br>
> + if len(sub.server.indications) < 1:<br>
> + logger.error("No valid
indications received")<br>
> + return FAIL<br>
> <br>
> - return PASS<br>
> + if str(sub.server.indications[0]) ==
ind_name:<br>
> + sub.unsubscribe(dict['default_auth'])<br>
> + logger.error("Cancelling
subscription for %s" % ind_name)</font></tt>
<br>
<br><tt><font size=2> I think we have to write logger.info()
instead of logger.error() here.</font></tt>
<br><tt><font size=2><br>
> + return PASS<br>
> + else:<br>
> + sub.server.indications.remove(sub.server.indications[0])<br>
> <br>
> -def poll_for_ind(pid):<br>
> + logger.error("Did not recieve indication %s"
% ind_name)<br>
> + return FAIL<br>
> +<br>
> +def poll_for_ind(pid, ind_name):<br>
> + status = FAIL<br>
> for i in range(0, 20):<br>
> pw = os.waitpid(pid, os.WNOHANG)<br>
> <br>
> @@ -118,17 +128,17 @@<br>
> # Only return a success if waitpid
returns the expected pid<br>
> # and the return code is 0.<br>
> if pw[0] == pid and pw[1] == 0:<br>
> - logger.info("Great,
got indication successfuly")<br>
> + logger.info("Great,
got %s indication successfuly", ind_name)<br>
> status = PASS<br>
> break<br>
> elif pw[1] == 0 and i < 19:<br>
> if i % 10 == 0:<br>
> - logger.info("In
child process, waiting for indication")<br>
> + logger.info("In
child, waiting for %s indication", ind_name)<br>
> time.sleep(1)<br>
> else:<br>
> # Time is up and waitpid
never returned the expected pid<br>
> if pw[0] != pid:<br>
> - logger.error("Waited
too long for indication")<br>
> + logger.error("Waited
too long for %s indication", ind_name)<br>
> os.kill(pid,
signal.SIGKILL)<br>
> else:<br>
> logger.error("Received
indication error: %d" % pw[1])<br>
> @@ -154,7 +164,7 @@<br>
> try:<br>
> pid = os.fork()<br>
> if pid == 0:<br>
> - status =
handle_request(sub, ind_name)<br>
> + status =
handle_request(sub, ind_name, dict, len(ind_list))<br>
> if status
!= PASS:<br>
>
os._exit(1)<br>
> <br>
> @@ -164,18 +174,18 @@<br>
>
status = gen_ind(test_dom, options.ip, options.virt, ind)<br>
>
if status != PASS:<br>
>
os.kill(pid, signal.SIGKILL)<br>
> -
return FAIL<br>
> +
raise Exception("Unable to generate indication")
<br>
> <br>
> - status
= poll_for_ind(pid)<br>
> + status
= poll_for_ind(pid, ind)<br>
> except
Exception, details:<br>
> - logger.error("Exception:
%s" % details)<br>
>
os.kill(pid, signal.SIGKILL)<br>
> - return
FAIL<br>
> + raise
Exception(details)<br>
> <br>
> except Exception, details:<br>
> logger.error("Exception:
%s" % details)<br>
> - return FAIL<br>
> + status = FAIL<br>
> <br>
> + #Make sure all subscriptions are really unsubscribed<br>
> for ind, sub in sub_list.iteritems():<br>
> sub.unsubscribe(dict['default_auth'])<br>
> logger.info("Cancelling subscription
for %s" % ind_names[ind])<br>
> <br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> https://www.redhat.com/mailman/listinfo/libvirt-cim<br>
</font></tt>