mirror of
https://github.com/docker/docs.git
synced 2026-03-31 08:18:55 +07:00
Extend up -t to pass timeout to stop running containers
Signed-off-by: Travis Thieman <travis.thieman@gmail.com>
This commit is contained in:
committed by
Daniel Nephin
parent
60351a8e07
commit
c24d5380e6
@@ -162,6 +162,19 @@ class CLITestCase(DockerClientTestCase):
|
||||
|
||||
self.assertEqual(old_ids, new_ids)
|
||||
|
||||
def test_up_with_timeout(self):
|
||||
self.command.dispatch(['up', '-d', '-t', '1'], None)
|
||||
service = self.project.get_service('simple')
|
||||
another = self.project.get_service('another')
|
||||
self.assertEqual(len(service.containers()), 1)
|
||||
self.assertEqual(len(another.containers()), 1)
|
||||
|
||||
# Ensure containers don't have stdin and stdout connected in -d mode
|
||||
config = service.containers()[0].inspect()['Config']
|
||||
self.assertFalse(config['AttachStderr'])
|
||||
self.assertFalse(config['AttachStdout'])
|
||||
self.assertFalse(config['AttachStdin'])
|
||||
|
||||
@patch('dockerpty.start')
|
||||
def test_run_service_without_links(self, mock_stdout):
|
||||
self.command.base_dir = 'tests/fixtures/links-composefile'
|
||||
|
||||
@@ -254,6 +254,15 @@ class ServiceTest(unittest.TestCase):
|
||||
new_container.start.assert_called_once_with()
|
||||
mock_container.remove.assert_called_once_with()
|
||||
|
||||
@mock.patch('compose.service.Container', autospec=True)
|
||||
def test_recreate_container_with_timeout(self, _):
|
||||
mock_container = mock.create_autospec(Container)
|
||||
self.mock_client.inspect_image.return_value = {'Id': 'abc123'}
|
||||
service = Service('foo', client=self.mock_client, image='someimage')
|
||||
service.recreate_container(mock_container, timeout=1)
|
||||
|
||||
mock_container.stop.assert_called_once_with(timeout=1)
|
||||
|
||||
def test_parse_repository_tag(self):
|
||||
self.assertEqual(parse_repository_tag("root"), ("root", ""))
|
||||
self.assertEqual(parse_repository_tag("root:tag"), ("root", "tag"))
|
||||
|
||||
Reference in New Issue
Block a user