[perl-POE-Component-Client-Keepalive] Fix a race in t/10_resolver.t
Petr Pisar
ppisar at fedoraproject.org
Fri Sep 5 15:02:30 UTC 2014
commit ea29d95930d4d0048fdd4ee94361b1a11fd45abb
Author: Petr Písař <ppisar at redhat.com>
Date: Fri Sep 5 16:48:40 2014 +0200
Fix a race in t/10_resolver.t
...alive-0.271-Fix-a-race-in-t-10_resolver.t.patch | 78 ++++++++++++++++++++
perl-POE-Component-Client-Keepalive.spec | 8 ++-
2 files changed, 85 insertions(+), 1 deletions(-)
---
diff --git a/POE-Component-Client-Keepalive-0.271-Fix-a-race-in-t-10_resolver.t.patch b/POE-Component-Client-Keepalive-0.271-Fix-a-race-in-t-10_resolver.t.patch
new file mode 100644
index 0000000..e3e3be6
--- /dev/null
+++ b/POE-Component-Client-Keepalive-0.271-Fix-a-race-in-t-10_resolver.t.patch
@@ -0,0 +1,78 @@
+From 499ac9b0e8a1b22734ad11286639cec5974286c6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Fri, 5 Sep 2014 16:39:27 +0200
+Subject: [PATCH] Fix a race in t/10_resolver.t
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+'second request honored asynchronously' t/10_resolver.t fails on
+a very slow machine.
+
+There is a race between reusing a TCP connection and a keep-a-live
+timeout set to 120 s in the library. The bug can be reproduced by
+adding "sleep 130;" into t/10_resolver.t at beginning of got_conn()
+subroutine.
+
+This patch will kips the test if test run time exceeds the timeout.
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ t/10_resolver.t | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/t/10_resolver.t b/t/10_resolver.t
+index bfe9d8c..17122dd 100644
+--- a/t/10_resolver.t
++++ b/t/10_resolver.t
+@@ -22,6 +22,9 @@ use TestServer;
+ use constant PORT => int(rand(65535-2000)) + 2000;
+ TestServer->spawn(PORT);
+
++my $timeout = 120;
++my $start;
++
+ POE::Session->create(
+ inline_states => {
+ _child => sub { },
+@@ -42,6 +45,7 @@ POE::Session->create(
+
+ sub start_with {
+ my $heap = $_[HEAP];
++ $start = time;
+
+ $_[KERNEL]->alias_set ('WITH');
+ $heap->{cm} = POE::Component::Client::Keepalive->new(
+@@ -54,6 +58,7 @@ sub start_with {
+ port => PORT,
+ event => "got_conn",
+ context => "first",
++ timeout => $timeout,
+ );
+ }
+ sub start_without {
+@@ -70,6 +75,7 @@ sub start_without {
+ port => PORT,
+ event => "got_conn",
+ context => "second",
++ timeout => $timeout,
+ );
+ }
+
+@@ -79,7 +85,12 @@ sub got_conn{
+ # The delete() ensures only one copy of the connection exists.
+ my $connection = delete $stuff->{connection};
+ my $which = $stuff->{context};
+- ok(defined($connection), "$which request honored asynchronously");
++ SKIP: {
++ if ($which eq 'second' and time - $start >= $timeout) {
++ skip "Test run time exceded keepalive timeout $timeout s", 1;
++ }
++ ok(defined($connection), "$which request honored asynchronously");
++ }
+ ok(not (defined ($stuff->{'from_cache'})), "$which request not from cache");
+
+ if ($which eq 'first') {
+--
+1.9.3
+
diff --git a/perl-POE-Component-Client-Keepalive.spec b/perl-POE-Component-Client-Keepalive.spec
index 95d396f..a2ebf29 100644
--- a/perl-POE-Component-Client-Keepalive.spec
+++ b/perl-POE-Component-Client-Keepalive.spec
@@ -3,12 +3,14 @@ Name: perl-POE-Component-Client-Keepalive
# Keep four digits to stay above the unfortunate 0.0901,
# so that epoch need not be changed.
Version: %{real_ver}0
-Release: 9%{?dist}
+Release: 10%{?dist}
Summary: Manages and keeps alive client connections
Group: Development/Libraries
License: GPL+ or Artistic
URL: http://search.cpan.org/dist/POE-Component-Client-Keepalive
Source0: http://search.cpan.org/CPAN/authors/id/R/RC/RCAPUTO/POE-Component-Client-Keepalive-%{real_ver}.tar.gz
+# Fix a race in t/10_resolver.t, bug #1136851, CPAN RT#98644
+Patch0: POE-Component-Client-Keepalive-0.271-Fix-a-race-in-t-10_resolver.t.patch
BuildArch: noarch
# core
BuildRequires: perl(constant)
@@ -46,6 +48,7 @@ probably be silly.
%prep
%setup -q -n POE-Component-Client-Keepalive-%{real_ver}
+%patch0 -p1
chmod -c -x mylib/* t/*
for test in t/release-pod-syntax.t \
t/release-pod-coverage.t \
@@ -76,6 +79,9 @@ make test
%{_mandir}/man3/*.3*
%changelog
+* Fri Sep 05 2014 Petr Pisar <ppisar at redhat.com> - 0.2710-10
+- Fix a race in t/10_resolver.t (bug #1136851)
+
* Fri Aug 29 2014 Jitka Plesnikova <jplesnik at redhat.com> - 0.2710-9
- Perl 5.20 rebuild
More information about the scm-commits
mailing list