mirror of https://github.com/docker/compose.git
Added unit test and used stop_timeout
Signed-off-by: Andy Neff <andyneff@users.noreply.github.com>
This commit is contained in:
parent
2df3d6f75a
commit
0e4bd32a65
|
@ -14,8 +14,8 @@ from docker.errors import APIError
|
|||
from docker.errors import ImageNotFound
|
||||
from docker.errors import NotFound
|
||||
from docker.types import LogConfig
|
||||
from docker.utils import version_lt
|
||||
from docker.utils import version_gte
|
||||
from docker.utils import version_lt
|
||||
from docker.utils.ports import build_port_bindings
|
||||
from docker.utils.ports import split_port
|
||||
from docker.utils.utils import convert_tmpfs_mounts
|
||||
|
@ -762,8 +762,7 @@ class Service(object):
|
|||
|
||||
if (version_gte(self.client.api_version, '1.25') and
|
||||
'stop_grace_period' in self.options):
|
||||
container_options['stop_timeout'] = parse_seconds_float(
|
||||
self.options.pop('stop_grace_period'))
|
||||
container_options['stop_timeout'] = self.stop_timeout(None)
|
||||
|
||||
if 'ports' in container_options or 'expose' in self.options:
|
||||
container_options['ports'] = build_container_ports(
|
||||
|
|
|
@ -228,6 +228,17 @@ class ServiceTest(unittest.TestCase):
|
|||
{'Type': 'syslog', 'Config': {'syslog-address': 'tcp://192.168.0.42:123'}}
|
||||
)
|
||||
|
||||
def test_stop_grace_period(self):
|
||||
self.mock_client.api_version = '1.25'
|
||||
self.mock_client.create_host_config.return_value = {}
|
||||
service = Service(
|
||||
'foo',
|
||||
image='foo',
|
||||
client=self.mock_client,
|
||||
stop_grace_period="1m35s")
|
||||
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
||||
self.assertEqual(opts['stop_timeout'], 95)
|
||||
|
||||
def test_split_domainname_none(self):
|
||||
service = Service(
|
||||
'foo',
|
||||
|
|
Loading…
Reference in New Issue