Commit 3501098b authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Fix ATS issue with no-Content-Length caching

Fixes and tests https://github.com/apache/trafficserver/issues/7880
parent 434a7eef
Pipeline #16077 failed with stage
in 0 seconds
...@@ -26,6 +26,9 @@ recipe = slapos.recipe.cmmi ...@@ -26,6 +26,9 @@ recipe = slapos.recipe.cmmi
url = http://apache.claz.org/trafficserver/trafficserver-9.0.1.tar.bz2 url = http://apache.claz.org/trafficserver/trafficserver-9.0.1.tar.bz2
md5sum = 98bb2de25f332715339ade87530a9f5a md5sum = 98bb2de25f332715339ade87530a9f5a
shared = true shared = true
patch-options = -p1
patches =
https://patch-diff.githubusercontent.com/raw/apache/trafficserver/pull/7577.patch
configure-options = configure-options =
--with-openssl=${openssl:location} --with-openssl=${openssl:location}
--with-pcre=${pcre:location} --with-pcre=${pcre:location}
......
...@@ -509,6 +509,7 @@ class TestHandler(BaseHTTPRequestHandler): ...@@ -509,6 +509,7 @@ class TestHandler(BaseHTTPRequestHandler):
if 'x-reply-body' in self.headers.dict: if 'x-reply-body' in self.headers.dict:
config['Body'] = base64.b64decode(self.headers.dict['x-reply-body']) config['Body'] = base64.b64decode(self.headers.dict['x-reply-body'])
config['X-Drop-Header'] = self.headers.dict.get('x-drop-header')
self.configuration[self.path] = config self.configuration[self.path] = config
self.send_response(201) self.send_response(201)
...@@ -3877,7 +3878,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3877,7 +3878,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
max_stale_age = 30 max_stale_age = 30
max_age = int(max_stale_age / 2.) max_age = int(max_stale_age / 2.)
body_200 = b'Body 200' # body_200 is big enough to trigger
# https://github.com/apache/trafficserver/issues/7880
body_200 = b'Body 200' * 500
body_502 = b'Body 502' body_502 = b'Body 502'
body_502_new = b'Body 502 new' body_502_new = b'Body 502 new'
body_200_new = b'Body 200 new' body_200_new = b'Body 200 new'
...@@ -3891,6 +3894,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3891,6 +3894,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'X-Reply-Header-Cache-Control': 'max-age=%s, public' % (max_age,), 'X-Reply-Header-Cache-Control': 'max-age=%s, public' % (max_age,),
'X-Reply-Status-Code': status_code, 'X-Reply-Status-Code': status_code,
'X-Reply-Body': base64.b64encode(body), 'X-Reply-Body': base64.b64encode(body),
# drop Content-Length header to ensure
# https://github.com/apache/trafficserver/issues/7880
'X-Drop-Header': 'Content-Length',
}) })
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, httplib.CREATED)
...@@ -3901,7 +3907,6 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3901,7 +3907,6 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
) )
self.assertEqual(result.status_code, status_code) self.assertEqual(result.status_code, status_code)
self.assertEqual(result.text, body) self.assertEqual(result.text, body)
self.assertNotIn('Expires', result.headers)
# backend returns something correctly # backend returns something correctly
configureResult('200', body_200) configureResult('200', body_200)
...@@ -3912,9 +3917,13 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3912,9 +3917,13 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# even if backend returns 502, ATS gives cached result # even if backend returns 502, ATS gives cached result
checkResult(httplib.OK, body_200) checkResult(httplib.OK, body_200)
time.sleep(max_stale_age + 2) # interesting moment, time is between max_age and max_stale_age, triggers
# https://github.com/apache/trafficserver/issues/7880
time.sleep(max_age + 1)
checkResult(httplib.OK, body_200)
# max_stale_age passed, time to return 502 from the backend # max_stale_age passed, time to return 502 from the backend
time.sleep(max_stale_age + 2)
checkResult(httplib.BAD_GATEWAY, body_502) checkResult(httplib.BAD_GATEWAY, body_502)
configureResult('502', body_502_new) configureResult('502', body_502_new)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment