annotate proxy_next_upstream_tries.t @ 462:cb0662e12d6e

Tests: proxy_next_upstream_{tries,timeout} tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 16 Sep 2014 14:22:27 +0400
parents
children b8f10ffa02cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http proxy module, proxy_next_upstream_tries
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 # and proxy_next_upstream_timeout directives.
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 ###############################################################################
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use warnings;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use strict;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 use Test::More;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use lib 'lib';
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 $t->write_file_expand('nginx.conf', <<'EOF');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 upstream u {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server 127.0.0.1:8081;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server 127.0.0.1:8081;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 server 127.0.0.1:8081;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 upstream u2 {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 server 127.0.0.1:8081;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 server 127.0.0.1:8081 backup;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 server 127.0.0.1:8081 backup;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 upstream u3 {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 server 127.0.0.1:8082;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 server 127.0.0.1:8082;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 server 127.0.0.1:8082;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 upstream u4 {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 server 127.0.0.1:8082;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 server 127.0.0.1:8082 backup;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 server 127.0.0.1:8082 backup;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 server {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 listen 127.0.0.1:8080;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 server_name localhost;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 proxy_next_upstream http_404;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 proxy_intercept_errors on;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 error_page 404 /404;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 location /tries {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 proxy_pass http://u;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 proxy_next_upstream_tries 2;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 location /tries/backup {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 proxy_pass http://u2;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 proxy_next_upstream_tries 2;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 location /timeout {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 proxy_pass http://u3;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 proxy_next_upstream_timeout 1500ms;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 location /timeout/backup {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 proxy_pass http://u4;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 proxy_next_upstream_timeout 1500ms;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 location /404 {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 return 200 x${upstream_status}x;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 EOF
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 $t->run_daemon(\&http_daemon, 8081);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 $t->run_daemon(\&http_daemon, 8082);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 $t->try_run('no proxy_next_upstream_tries')->plan(4);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 $t->waitforsocket('127.0.0.1:8081');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 $t->waitforsocket('127.0.0.1:8082');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 ###############################################################################
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 like(http_get('/tries'), qr/x404, 404x/, 'tries');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 like(http_get('/tries/backup'), qr/x404, 404x/, 'tries backup');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 # two tries fit into 1.5s
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 like(http_get('/timeout'), qr/x404, 404x/, 'timeout');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 like(http_get('/timeout/backup'), qr/x404, 404x/, 'timeout backup');
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 ###############################################################################
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 sub http_daemon {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 my ($port) = @_;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 my $server = IO::Socket::INET->new(
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 Proto => 'tcp',
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 LocalHost => '127.0.0.1',
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 LocalPort => $port,
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 Listen => 5,
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 Reuse => 1
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 )
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 or die "Can't create listening socket: $!\n";
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 local $SIG{PIPE} = 'IGNORE';
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 while (my $client = $server->accept()) {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 $client->autoflush(1);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 my $headers = '';
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 while (<$client>) {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 $headers .= $_;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 last if (/^\x0d?\x0a?$/);
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 next if $headers eq '';
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 if ($port == 8082) {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 Test::Nginx::log_core('||', "$port: sleep(1)");
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 select undef, undef, undef, 1;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 Test::Nginx::log_core('||', "$port: response, 404");
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 print $client <<EOF;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 HTTP/1.1 404 Not Found
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 Connection: close
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 EOF
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 } continue {
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 close $client;
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 }
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161
cb0662e12d6e Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 ###############################################################################