# HG changeset patch # User Sergey Kandaurov # Date 1436438803 -10800 # Node ID cb35a9ec44287b4346cdb0b09d14054ce273d09e # Parent 5f9dfe85a1f24e5c774f2dba647e0a83671676b8 Tests: adjusted proxy_limit_rate test timeouts. Sometimes, on slow hosts, it may get quite some time to complete request delayed with proxy_limit_rate, and we still need to known how much it took. The timeout value used internally in the http() library routine is not enough. diff --git a/proxy_limit_rate.t b/proxy_limit_rate.t --- a/proxy_limit_rate.t +++ b/proxy_limit_rate.t @@ -58,7 +58,8 @@ EOF ############################################################################### -my $r = http_get('/'); +my $s = http_get('/', start => 1); +my $r = http_end_gentle($s); my ($t1) = $r =~ /X-Msec: (\d+)/; my $diff = time() - $t1; @@ -69,3 +70,29 @@ cmp_ok(abs($diff - 3), '<=', 1, 'proxy_l like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body'); ############################################################################### + +sub http_end_gentle { + my ($s) = @_; + my $reply; + + eval { + local $SIG{ALRM} = sub { die "timeout\n" }; + local $SIG{PIPE} = sub { die "sigpipe\n" }; + alarm(8); + + local $/; + $reply = $s->getline(); + + alarm(0); + }; + alarm(0); + if ($@) { + log_in("died: $@"); + return undef; + } + + log_in($reply); + return $reply; +} + +###############################################################################