Commit 26900109 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

caddy-frontend: Test try_duration and try_interval

Extend the backend with Timeout configuration via headers and use it
to prove, that request taking more than try_duration is correctly served.

Also prove that try_duration and try_interval are correct passed to the slave
configuration.
parent 4f168972
......@@ -468,6 +468,8 @@ class TestMasterRequestDomain(HttpFrontendTestCase, TestDataMixin):
class TestHandler(BaseHTTPRequestHandler):
def do_GET(self):
timeout = int(self.headers.dict.get('Timeout', '0'))
time.sleep(timeout)
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header('Set-Cookie', 'secured=value;secure')
......@@ -1169,7 +1171,9 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
result = self.fakeHTTPSResult(
parameter_dict['domain'], parameter_dict['public-ipv4'],
'test-path/deep/.././deeper')
'test-path/deep/.././deeper',
headers={'Timeout': '10'} # more than default proxy-try-duration == 5
)
self.assertEqual(
self.certificate_pem,
......@@ -1183,6 +1187,8 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
raise ValueError('JSON decode problem in:\n%s' % (result.text,))
self.assertFalse('remote_user' in j['Incoming Headers'].keys())
self.assertEqual(j['Incoming Headers']['timeout'], '10')
self.assertFalse('Content-Encoding' in result.headers)
self.assertEqual(
......@@ -1208,6 +1214,14 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
result_http.headers['Set-Cookie']
)
# check that try_duration == 5 in the test_url slave
slave_configuration_file = glob.glob(os.path.join(
self.instance_path, '*', 'etc', '*slave-conf.d', '_url.conf'))[0]
with open(slave_configuration_file) as fh:
content = fh.read()
self.assertTrue('try_duration 5s' in content)
self.assertTrue('try_interval 250ms' in content)
@skip('Feature postponed')
def test_url_ipv6_access(self):
parameter_dict = self.parseSlaveParameterDict('url')
......
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