Dne Pá 05.zář.2014 09:36:21, ppisar napsal(a):
Show quoted text> I recommend to skip the affected tests if the test run time exceeds
> the time-out.
Attached patch implements the idea.
-- Petr
From 460aea659bc8d7d2d15aa68b873bb171e4f4a44e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 5 Sep 2014 16:39:27 +0200
Subject: [PATCH] Fix a race in t/10_resolver.t
'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.
---
t/10_resolver.t | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/t/10_resolver.t b/t/10_resolver.t
index 5c5e734..38ea52d 100644
--- a/t/10_resolver.t
+++ b/t/10_resolver.t
@@ -20,6 +20,8 @@ use TestServer;
my $server_port = TestServer->spawn(0);
my $test_server_use_count = 0;
+my $timeout = 120;
+my $start;
POE::Session->create(
inline_states => {
@@ -41,6 +43,7 @@ POE::Session->create(
sub start_with {
my $heap = $_[HEAP];
+ $start = time;
$_[KERNEL]->alias_set ('WITH');
$heap->{cm} = POE::Component::Client::Keepalive->new(
@@ -53,6 +56,7 @@ sub start_with {
port => $server_port,
event => "got_conn",
context => "first",
+ timeout => $timeout,
);
++$test_server_use_count;
@@ -72,6 +76,7 @@ sub start_without {
port => $server_port,
event => "got_conn",
context => "second",
+ timeout => $timeout,
);
++$test_server_use_count;
@@ -88,14 +93,19 @@ sub got_conn{
my $connection = delete $response->{connection};
my $which = $response->{context};
- if (defined $connection) {
- pass "$which request honored asynchronously";
- }
- else {
- fail(
- "$which request $response->{function} error $response->{error_num}: " .
- $response->{error_str}
- );
+ SKIP: {
+ if ($which eq 'second' and time - $start >= $timeout) {
+ skip "Test run time exceded keepalive timeout $timeout s", 1;
+ }
+ if (defined $connection) {
+ pass "$which request honored asynchronously";
+ }
+ else {
+ fail(
+ "$which request $response->{function} error $response->{error_num}: " .
+ $response->{error_str}
+ );
+ }
}
ok(
--
2.1.0