From 66c8827c22f05b67ec4a8812edbdfe69ff6e5a68 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 22 Feb 2013 03:32:51 +0000 Subject: [PATCH] t/http.t: test error handling on non-running server We need to ensure we don't blow up a worker process if a server is shutdown and a connection attempted before the monitor notices. --- t/http.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/t/http.t b/t/http.t index 04ee993..22c4044 100644 --- a/t/http.t +++ b/t/http.t @@ -289,6 +289,26 @@ sim_node_timeout(1); has_nothing_queued(); } +# server is not running +{ + my $resp; + + # we want an empty pool to avoid retries + my $pool = $idle_pool->{"$host->{hostip}:$host->{http_port}"}; + is(0, scalar @$pool, "connection pool is empty"); + + Danga::Socket->SetPostLoopCallback(sub { ! defined($resp) }); + $http->close; # $http is unusable after this + $host->http("GET", "/fail", undef, sub { $resp = $_[0] }); + Danga::Socket->EventLoop; + ok(! $resp->is_success, "HTTP response is not successful"); + ok($resp->header("X-MFS-Error"), "X-MFS-Error is set"); + is(0, scalar @$pool, "connection pool is empty"); + + has_nothing_inflight(); + has_nothing_queued(); +} + done_testing(); sub has_nothing_inflight { -- 2.11.4.GIT