Mercurial > hg > nginx-tests
annotate proxy_next_upstream_tries.t @ 716:e3fd2c8d257e
Tests: added HTTP/2 tests for some http core module variables.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Sat, 26 Sep 2015 00:03:22 +0300 |
parents | ef1c363dd648 |
children | a6764c2a9f12 |
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 |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
494
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8); |
462
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 server { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 listen 127.0.0.1:8080; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server_name localhost; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 proxy_next_upstream http_404; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 proxy_intercept_errors on; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 error_page 404 /404; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location /tries { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 proxy_pass http://u; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 proxy_next_upstream_tries 2; |
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 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 location /tries/backup { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 proxy_pass http://u2; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 proxy_next_upstream_tries 2; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
70 location /tries/resolver { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
71 resolver 127.0.0.1:8083; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
72 resolver_timeout 1s; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
73 |
494
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
74 proxy_pass http://$host:8081; |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
75 proxy_next_upstream_tries 2; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
76 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
77 |
493
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
78 location /tries/zero { |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
79 proxy_pass http://u; |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
80 proxy_next_upstream_tries 0; |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
81 } |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
82 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 location /timeout { |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
84 proxy_pass http://u/w2; |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
85 proxy_next_upstream_timeout 3800ms; |
462
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 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 location /timeout/backup { |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
89 proxy_pass http://u2/w2; |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
90 proxy_next_upstream_timeout 3800ms; |
462
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 |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
93 location /timeout/resolver { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
94 resolver 127.0.0.1:8083; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
95 resolver_timeout 1s; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
96 |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
97 proxy_pass http://$host:8081/w2; |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
98 proxy_next_upstream_timeout 3800ms; |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
99 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
100 |
493
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
101 location /timeout/zero { |
494
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
102 proxy_pass http://u/w; |
493
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
103 proxy_next_upstream_timeout 0; |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
104 } |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
105 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 location /404 { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 return 200 x${upstream_status}x; |
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 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 } |
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 EOF |
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 $t->run_daemon(\&http_daemon, 8081); |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
115 $t->run_daemon(\&dns_daemon, 8083, $t); |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
494
diff
changeset
|
116 $t->run(); |
462
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 $t->waitforsocket('127.0.0.1:8081'); |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
119 $t->waitforfile($t->testdir . '/8083'); |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
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 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 like(http_get('/tries'), qr/x404, 404x/, 'tries'); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 like(http_get('/tries/backup'), qr/x404, 404x/, 'tries backup'); |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
125 like(http_get('/tries/resolver'), qr/x404, 404x/, 'tries resolved'); |
493
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
126 like(http_get('/tries/zero'), qr/x404, 404, 404x/, 'tries zero'); |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
127 |
492
799487ee9aee
Tests: adjusted proxy_next_upstream_timeout values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
485
diff
changeset
|
128 # two tries fit into 1.9s |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
130 SKIP: { |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
131 skip 'long tests', 4 unless $ENV{TEST_NGINX_UNSAFE}; |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
132 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 like(http_get('/timeout'), qr/x404, 404x/, 'timeout'); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 like(http_get('/timeout/backup'), qr/x404, 404x/, 'timeout backup'); |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
135 like(http_get('/timeout/resolver'), qr/x404, 404x/, 'timeout resolved'); |
493
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
136 like(http_get('/timeout/zero'), qr/x404, 404, 404x/, 'timeout zero'); |
d456ed8a18de
Tests: added proxy_next_upstream_tries.t tests with zero value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
492
diff
changeset
|
137 |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
138 } |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
139 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 ############################################################################### |
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 sub http_daemon { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 my ($port) = @_; |
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 my $server = IO::Socket::INET->new( |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 Proto => 'tcp', |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 LocalHost => '127.0.0.1', |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 LocalPort => $port, |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 Listen => 5, |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 Reuse => 1 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 ) |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 or die "Can't create listening socket: $!\n"; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 local $SIG{PIPE} = 'IGNORE'; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 while (my $client = $server->accept()) { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 $client->autoflush(1); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 my $headers = ''; |
494
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
160 my $uri = ''; |
462
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 while (<$client>) { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 $headers .= $_; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 last if (/^\x0d?\x0a?$/); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 next if $headers eq ''; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
494
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
169 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
170 |
623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
493
diff
changeset
|
171 if ($uri eq '/w') { |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 Test::Nginx::log_core('||', "$port: sleep(1)"); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 select undef, undef, undef, 1; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
608
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
176 if ($uri eq '/w2') { |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
177 Test::Nginx::log_core('||', "$port: sleep(2)"); |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
178 select undef, undef, undef, 2; |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
179 } |
ef1c363dd648
Tests: adjusted proxy_next_upstream_tries.t test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
180 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 Test::Nginx::log_core('||', "$port: response, 404"); |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 print $client <<EOF; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 HTTP/1.1 404 Not Found |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 Connection: close |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 EOF |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 } continue { |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 close $client; |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 } |
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
193 sub reply_handler { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
194 my ($recv_data) = @_; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
195 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
196 my (@name, @rdata); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
197 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
198 use constant NOERROR => 0; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
199 use constant A => 1; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
200 use constant IN => 1; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
201 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
202 # default values |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
203 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
204 my ($hdr, $rcode, $ttl) = (0x8180, NOERROR, 3600); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
205 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
206 # decode name |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
207 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
208 my ($len, $offset) = (undef, 12); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
209 while (1) { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
210 $len = unpack("\@$offset C", $recv_data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
211 last if $len == 0; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
212 $offset++; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
213 push @name, unpack("\@$offset A$len", $recv_data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
214 $offset += $len; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
215 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
216 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
217 $offset -= 1; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
218 my ($id, $type, $class) = unpack("n x$offset n2", $recv_data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
219 |
485
cbfe90b632e8
Tests: removed stray semicolon, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
484
diff
changeset
|
220 @rdata = map { rd_addr($ttl, '127.0.0.1') } (1 .. 3) if $type == A; |
479
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
221 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
222 $len = @name; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
223 pack("n6 (w/a*)$len x n2", $id, $hdr | $rcode, 1, scalar @rdata, |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
224 0, 0, @name, $type, $class) . join('', @rdata); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
225 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
226 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
227 sub rd_addr { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
228 my ($ttl, $addr) = @_; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
229 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
230 my $code = 'split(/\./, $addr)'; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
231 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
232 return pack 'n3N', 0xc00c, A, IN, $ttl if $addr eq ''; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
233 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
234 pack 'n3N nC4', 0xc00c, A, IN, $ttl, eval "scalar $code", eval($code); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
235 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
236 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
237 sub dns_daemon { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
238 my ($port, $t) = @_; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
239 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
240 my ($data, $recv_data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
241 my $socket = IO::Socket::INET->new( |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
242 LocalAddr => '127.0.0.1', |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
243 LocalPort => $port, |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
244 Proto => 'udp', |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
245 ) |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
246 or die "Can't create listening socket: $!\n"; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
247 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
248 # signal we are ready |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
249 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
250 open my $fh, '>', $t->testdir() . '/' . $port; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
251 close $fh; |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
252 |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
253 while (1) { |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
254 $socket->recv($recv_data, 65536); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
255 $data = reply_handler($recv_data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
256 $socket->send($data); |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
257 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
258 } |
b8f10ffa02cd
Tests: proxy_next_upstream_tries tests with resolved upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
462
diff
changeset
|
259 |
462
cb0662e12d6e
Tests: proxy_next_upstream_{tries,timeout} tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 ############################################################################### |