Skip to content

Commit

Permalink
extract upstream down test to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Feb 18, 2015
1 parent 27fd379 commit 9ff343b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
2 changes: 2 additions & 0 deletions h2o.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
10AA2EAB1A8DE0AE004322AC /* multithread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = multithread.c; sourceTree = "<group>"; };
10AA2EAD1A8E22DA004322AC /* multithread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = multithread.c; sourceTree = "<group>"; };
10AA2EB11A931409004322AC /* 50access-log.t */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "50access-log.t"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.perl; };
10AA2EB21A9479B4004322AC /* 50reverse-proxy-upstream-down.t */ = {isa = PBXFileReference; lastKnownFileType = text; path = "50reverse-proxy-upstream-down.t"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.perl; };
10BA72A919AAD6300059392A /* stream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stream.c; sourceTree = "<group>"; };
10D0903919F0A51C0043D458 /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
10D0903D19F0A8190043D458 /* socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = socket.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -730,6 +731,7 @@
10AA2EA81A8DAFD4004322AC /* 50redirect.t */,
105534F91A460F4200627ECB /* 50reverse-proxy.t */,
104C65021A6DF36B000AC190 /* 50reverse-proxy-config.t */,
10AA2EB21A9479B4004322AC /* 50reverse-proxy-upstream-down.t */,
104B9A2B1A4BBDA4009EEE64 /* 50server-starter.t */,
105534FA1A460F4200627ECB /* 50sni.t */,
105534FE1A46134A00627ECB /* 80issues61.t */,
Expand Down
24 changes: 24 additions & 0 deletions t/50reverse-proxy-upstream-down.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use strict;
use warnings;
use Net::EmptyPort qw(check_port empty_port);
use Test::More;
use t::Util;

# should return 502 in case of upstream error
subtest 'upstream-down' => sub {
plan skip_all => 'curl not found'
unless prog_exists('curl');
my $upstream_port = empty_port();
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
proxy.reverse.url: http://127.0.0.1:$upstream_port
EOT
my $port = $server->{port};
my $res = `curl --silent --dump-header /dev/stderr http://127.0.0.1:$port/ 2>&1 > /dev/null`;
like $res, qr{^HTTP/1\.1 502 }, "502 response on upstream error";
};

done_testing();
17 changes: 0 additions & 17 deletions t/50reverse-proxy.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,6 @@ EOT
ok ! check_port($upstream_port), "upstream should be down now";
}

# should return 502 in case of upstream error
subtest 'upstream-down' => sub {
plan skip_all => 'curl not found'
unless prog_exists('curl');
my $upstream_port = empty_port();
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
proxy.reverse.url: http://127.0.0.1:$upstream_port
EOT
my $port = $server->{port};
my $res = `curl --silent --dump-header /dev/stderr http://127.0.0.1:$port/ 2>&1 > /dev/null`;
like $res, qr{^HTTP/1\.1 502 }, "502 response on upstream error";
};

sub spawn_upstream {
my ($port, @extra) = @_;
spawn_server(
Expand Down

0 comments on commit 9ff343b

Please sign in to comment.