Mercurial > hg > nginx-tests
comparison proxy_next_upstream_tries.t @ 494:623863fcb1d1
Tests: simplified proxy_next_upstream_tries.t tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 07 Nov 2014 15:20:02 +0300 |
parents | d456ed8a18de |
children | 907e89fba9c3 |
comparison
equal
deleted
inserted
replaced
493:d456ed8a18de | 494:623863fcb1d1 |
---|---|
47 server 127.0.0.1:8081; | 47 server 127.0.0.1:8081; |
48 server 127.0.0.1:8081 backup; | 48 server 127.0.0.1:8081 backup; |
49 server 127.0.0.1:8081 backup; | 49 server 127.0.0.1:8081 backup; |
50 } | 50 } |
51 | 51 |
52 upstream u3 { | |
53 server 127.0.0.1:8082; | |
54 server 127.0.0.1:8082; | |
55 server 127.0.0.1:8082; | |
56 } | |
57 | |
58 upstream u4 { | |
59 server 127.0.0.1:8082; | |
60 server 127.0.0.1:8082 backup; | |
61 server 127.0.0.1:8082 backup; | |
62 } | |
63 | |
64 server { | 52 server { |
65 listen 127.0.0.1:8080; | 53 listen 127.0.0.1:8080; |
66 server_name localhost; | 54 server_name localhost; |
67 | 55 |
68 proxy_next_upstream http_404; | 56 proxy_next_upstream http_404; |
81 | 69 |
82 location /tries/resolver { | 70 location /tries/resolver { |
83 resolver 127.0.0.1:8083; | 71 resolver 127.0.0.1:8083; |
84 resolver_timeout 1s; | 72 resolver_timeout 1s; |
85 | 73 |
86 proxy_pass http://$host:8081/backend; | 74 proxy_pass http://$host:8081; |
87 proxy_next_upstream_tries 2; | 75 proxy_next_upstream_tries 2; |
88 } | 76 } |
89 | 77 |
90 location /tries/zero { | 78 location /tries/zero { |
91 proxy_pass http://u; | 79 proxy_pass http://u; |
92 proxy_next_upstream_tries 0; | 80 proxy_next_upstream_tries 0; |
93 } | 81 } |
94 | 82 |
95 location /timeout { | 83 location /timeout { |
96 proxy_pass http://u3; | 84 proxy_pass http://u/w; |
97 proxy_next_upstream_timeout 1900ms; | 85 proxy_next_upstream_timeout 1900ms; |
98 } | 86 } |
99 | 87 |
100 location /timeout/backup { | 88 location /timeout/backup { |
101 proxy_pass http://u4; | 89 proxy_pass http://u2/w; |
102 proxy_next_upstream_timeout 1900ms; | 90 proxy_next_upstream_timeout 1900ms; |
103 } | 91 } |
104 | 92 |
105 location /timeout/resolver { | 93 location /timeout/resolver { |
106 resolver 127.0.0.1:8083; | 94 resolver 127.0.0.1:8083; |
107 resolver_timeout 1s; | 95 resolver_timeout 1s; |
108 | 96 |
109 proxy_pass http://$host:8082/backend; | 97 proxy_pass http://$host:8081/w; |
110 proxy_next_upstream_timeout 1900ms; | 98 proxy_next_upstream_timeout 1900ms; |
111 } | 99 } |
112 | 100 |
113 location /timeout/zero { | 101 location /timeout/zero { |
114 proxy_pass http://u3; | 102 proxy_pass http://u/w; |
115 proxy_next_upstream_timeout 0; | 103 proxy_next_upstream_timeout 0; |
116 } | 104 } |
117 | 105 |
118 location /404 { | 106 location /404 { |
119 return 200 x${upstream_status}x; | 107 return 200 x${upstream_status}x; |
122 } | 110 } |
123 | 111 |
124 EOF | 112 EOF |
125 | 113 |
126 $t->run_daemon(\&http_daemon, 8081); | 114 $t->run_daemon(\&http_daemon, 8081); |
127 $t->run_daemon(\&http_daemon, 8082); | |
128 $t->run_daemon(\&dns_daemon, 8083, $t); | 115 $t->run_daemon(\&dns_daemon, 8083, $t); |
129 $t->try_run('no proxy_next_upstream_tries')->plan(8); | 116 $t->try_run('no proxy_next_upstream_tries')->plan(8); |
130 | 117 |
131 $t->waitforsocket('127.0.0.1:8081'); | 118 $t->waitforsocket('127.0.0.1:8081'); |
132 $t->waitforsocket('127.0.0.1:8082'); | |
133 $t->waitforfile($t->testdir . '/8083'); | 119 $t->waitforfile($t->testdir . '/8083'); |
134 | 120 |
135 ############################################################################### | 121 ############################################################################### |
136 | 122 |
137 like(http_get('/tries'), qr/x404, 404x/, 'tries'); | 123 like(http_get('/tries'), qr/x404, 404x/, 'tries'); |
178 | 164 |
179 while (my $client = $server->accept()) { | 165 while (my $client = $server->accept()) { |
180 $client->autoflush(1); | 166 $client->autoflush(1); |
181 | 167 |
182 my $headers = ''; | 168 my $headers = ''; |
169 my $uri = ''; | |
183 | 170 |
184 while (<$client>) { | 171 while (<$client>) { |
185 $headers .= $_; | 172 $headers .= $_; |
186 last if (/^\x0d?\x0a?$/); | 173 last if (/^\x0d?\x0a?$/); |
187 } | 174 } |
188 | 175 |
189 next if $headers eq ''; | 176 next if $headers eq ''; |
190 | 177 |
191 if ($port == 8082) { | 178 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
179 | |
180 if ($uri eq '/w') { | |
192 Test::Nginx::log_core('||', "$port: sleep(1)"); | 181 Test::Nginx::log_core('||', "$port: sleep(1)"); |
193 select undef, undef, undef, 1; | 182 select undef, undef, undef, 1; |
194 } | 183 } |
195 | 184 |
196 Test::Nginx::log_core('||', "$port: response, 404"); | 185 Test::Nginx::log_core('||', "$port: response, 404"); |