changeset 1587:17b227c271a2

Tests: 4xx and 5xx codes with stale-while-revalidate. Now these codes do not fall under stale-if-error (enabled by stale-while-revalidate).
author Roman Arutyunyan <arut@nginx.com>
date Fri, 14 Aug 2020 13:32:27 +0300
parents e145509cc6eb
children 3afb634f287d
files proxy_cache_use_stale.t
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_cache_use_stale.t
+++ b/proxy_cache_use_stale.t
@@ -151,7 +151,7 @@ EOF
 $t->write_file('escape html', 'SEE-THIS');
 $t->write_file('regexp.html', 'SEE-THIS');
 
-$t->run()->plan(35);
+$t->run()->plan(36);
 
 ###############################################################################
 
@@ -171,6 +171,7 @@ get('/t7.html', 'max-age=1, stale-while-
 http_get('/ssi.html');
 get('/updating/t.html', 'max-age=1');
 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2');
+get('/updating/tt.html', 'max-age=1, stale-if-error=5');
 get('/t8.html', 'stale-while-revalidate=10');
 get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10');
 get('/escape html', 'max-age=1, stale-while-revalidate=10');
@@ -178,8 +179,18 @@ get('/regexp.html', 'max-age=1, stale-wh
 
 sleep 2;
 
-like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale');
-like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2');
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.19.3');
+
+# stale 5xx response is ignored since 1.19.3,
+# "proxy_cache_use_stale updating;" allows to get it still
+
+like(http_get('/t.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore');
+like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore 2');
+
+}
+
+like(http_get('/updating/tt.html'), qr/STALE/, 's-i-e - stale 5xx updating');
 like(http_get('/t.html'), qr/REVALIDATED/, 's-i-e - revalidated');
 
 like(http_get('/t2.html?e=1'), qr/STALE/, 's-w-r - revalidate error');
@@ -190,8 +201,14 @@ like(get('/t4.html', 'max-age=1, stale-w
 	's-w-r - unconditional revalidate');
 like(http_get('/t4.html'), qr/HIT/, 's-w-r - unconditional revalidated');
 
-like(http_get('/t5.html?e=1'), qr/STALE/,
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.19.3');
+
+like(http_get('/t5.html?e=1'), qr/ 500 /,
 	's-w-r - foreground revalidate error');
+
+}
+
 like(http_get('/t5.html'), qr/REVALIDATED/, 's-w-r - foreground revalidated');
 
 # proxy_pass to regular expression with named and positional captures