Mercurial > hg > nginx-tests
comparison proxy_cache_use_stale.t @ 1138:d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 27 Feb 2017 17:15:24 +0300 |
parents | 129b9e4ca3b3 |
children | 4039b6b3a75a |
comparison
equal
deleted
inserted
replaced
1137:129b9e4ca3b3 | 1138:d6acd17ca4e3 |
---|---|
76 | 76 |
77 location /t8.html { | 77 location /t8.html { |
78 proxy_pass http://127.0.0.1:8081/t.html; | 78 proxy_pass http://127.0.0.1:8081/t.html; |
79 | 79 |
80 proxy_cache_valid 1s; | 80 proxy_cache_valid 1s; |
81 } | |
82 | |
83 if ($arg_if) { | |
84 # nothing | |
81 } | 85 } |
82 } | 86 } |
83 } | 87 } |
84 server { | 88 server { |
85 listen 127.0.0.1:8081; | 89 listen 127.0.0.1:8081; |
105 $t->write_file('tt.html', 'SEE-THIS'); | 109 $t->write_file('tt.html', 'SEE-THIS'); |
106 $t->write_file('t2.html', 'SEE-THIS'); | 110 $t->write_file('t2.html', 'SEE-THIS'); |
107 $t->write_file('t3.html', 'SEE-THIS'); | 111 $t->write_file('t3.html', 'SEE-THIS'); |
108 $t->write_file('t6.html', 'SEE-THIS'); | 112 $t->write_file('t6.html', 'SEE-THIS'); |
109 | 113 |
110 $t->try_run('no proxy_cache_background_update')->plan(25); | 114 $t->try_run('no proxy_cache_background_update')->plan(27); |
111 | 115 |
112 ############################################################################### | 116 ############################################################################### |
113 | 117 |
114 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); | 118 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); |
115 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); | 119 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); |
173 like(http_get('/t3.html?e=1'), qr/ 500 /, 's-w-r - ceased'); | 177 like(http_get('/t3.html?e=1'), qr/ 500 /, 's-w-r - ceased'); |
174 like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - ceased'); | 178 like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - ceased'); |
175 like(http_get('/updating/t2.html'), qr/STALE/, | 179 like(http_get('/updating/t2.html'), qr/STALE/, |
176 's-w-r - overriden with use_stale updating'); | 180 's-w-r - overriden with use_stale updating'); |
177 | 181 |
182 # due to the missing content_handler inheritance in a cloned subrequest, | |
183 # this used to access a static file in the update request | |
184 | |
185 like(http_get('/t2.html?if=1'), qr/STALE/, 'background update in if'); | |
186 | |
187 TODO: { | |
188 local $TODO = 'not yet' unless $t->has_version('1.11.11'); | |
189 | |
190 like(http_get('/t2.html?if=1'), qr/HIT/, 'background update in if - updated'); | |
191 | |
192 } | |
193 | |
178 ############################################################################### | 194 ############################################################################### |
179 | 195 |
180 sub get { | 196 sub get { |
181 my ($url, $extra, %extra) = @_; | 197 my ($url, $extra, %extra) = @_; |
182 return http(<<EOF, %extra); | 198 return http(<<EOF, %extra); |