Merge pull request #4419 from shin-/4418-healthcheck-extends

Don't re-parse healthcheck values coming from extended services
This commit is contained in:
Joffrey F 2017-02-03 12:24:53 -08:00 committed by GitHub
commit 951497c0f2
4 changed files with 36 additions and 2 deletions

View File

@ -716,9 +716,15 @@ def process_healthcheck(service_dict, service_name):
hc['test'] = raw['test'] hc['test'] = raw['test']
if 'interval' in raw: if 'interval' in raw:
if not isinstance(raw['interval'], six.integer_types):
hc['interval'] = parse_nanoseconds_int(raw['interval']) hc['interval'] = parse_nanoseconds_int(raw['interval'])
else: # Conversion has been done previously
hc['interval'] = raw['interval']
if 'timeout' in raw: if 'timeout' in raw:
if not isinstance(raw['timeout'], six.integer_types):
hc['timeout'] = parse_nanoseconds_int(raw['timeout']) hc['timeout'] = parse_nanoseconds_int(raw['timeout'])
else: # Conversion has been done previously
hc['timeout'] = raw['timeout']
if 'retries' in raw: if 'retries' in raw:
hc['retries'] = raw['retries'] hc['retries'] = raw['retries']

View File

@ -0,0 +1,9 @@
version: '2.1'
services:
demo:
image: foobar:latest
healthcheck:
test: ["CMD", "/health.sh"]
interval: 10s
timeout: 5s
retries: 36

View File

@ -0,0 +1,6 @@
version: '2.1'
services:
demo:
extends:
file: healthcheck-1.yml
service: demo

View File

@ -3116,6 +3116,19 @@ class ExtendsTest(unittest.TestCase):
'other': {'condition': 'service_started'} 'other': {'condition': 'service_started'}
} }
def test_extends_with_healthcheck(self):
service_dicts = load_from_filename('tests/fixtures/extends/healthcheck-2.yml')
assert service_sort(service_dicts) == [{
'name': 'demo',
'image': 'foobar:latest',
'healthcheck': {
'test': ['CMD', '/health.sh'],
'interval': 10000000000,
'timeout': 5000000000,
'retries': 36,
}
}]
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash') @pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
class ExpandPathTest(unittest.TestCase): class ExpandPathTest(unittest.TestCase):