Remove unnecessary inspect in kill and related testcases

Details refer to the bug list:
https://bugs.launchpad.net/zun/+bug/1701870

Co-Author: Kien Nguyen <kiennt@vn.fujitsu.com>
Change-Id: Icd2f3c66d50067ae79a2060965644f056cc1cc77
Closes-Bug: #1701870
This commit is contained in:
00129207 2017-07-03 10:22:18 +08:00 committed by Kien Nguyen
parent e5ee7827a6
commit 745cebc9ef
2 changed files with 0 additions and 51 deletions

View File

@ -405,16 +405,6 @@ class DockerDriver(driver.ContainerDriver):
docker.kill(container.container_id)
else:
docker.kill(container.container_id, signal)
try:
response = docker.inspect_container(container.container_id)
except errors.APIError as api_error:
if '404' in str(api_error):
container.status = consts.ERROR
container.status_reason = six.text_type(api_error)
return container
raise
self._populate_container(container, response)
return container
@check_container_id

View File

@ -280,59 +280,18 @@ class TestDockerDriver(base.DriverTestCase):
def test_kill_successful_signal_is_none(self):
self.mock_docker.kill = mock.Mock()
self.mock_docker.inspect_container = mock.Mock(
return_value={'State': 'exited'})
mock_container = mock.MagicMock()
self.driver.kill(mock_container, signal=None)
self.mock_docker.kill.assert_called_once_with(
mock_container.container_id)
self.mock_docker.inspect_container.assert_called_once_with(
mock_container.container_id)
def test_kill_successful_signal_is_not_none(self):
self.mock_docker.kill = mock.Mock()
self.mock_docker.inspect_container = mock.Mock(
return_value={'State': 'exited'})
mock_container = mock.MagicMock()
self.driver.kill(mock_container, signal='test')
self.mock_docker.kill.assert_called_once_with(
mock_container.container_id,
'test')
self.mock_docker.inspect_container.assert_called_once_with(
mock_container.container_id)
def test_kill_fail_container_status_error(self):
with mock.patch.object(errors.APIError, '__str__',
return_value='404 Not Found') as mock_init:
self.mock_docker.kill = mock.Mock()
self.mock_docker.inspect_container = mock.Mock(
side_effect=errors.APIError('Error', '', ''))
mock_container = mock.MagicMock()
result_container = self.driver.kill(mock_container,
signal='test')
self.mock_docker.kill.assert_called_once_with(
mock_container.container_id, 'test')
self.mock_docker.inspect_container.assert_called_once_with(
mock_container.container_id)
self.assertEqual(result_container.status,
consts.ERROR)
self.assertEqual(2, mock_init.call_count)
def test_kill_fail_api_error(self):
with mock.patch.object(errors.APIError, '__str__',
return_value='test') as mock_init:
self.mock_docker.kill = mock.Mock()
self.mock_docker.inspect_container = mock.Mock(
side_effect=errors.APIError('Error', '', ''))
mock_container = mock.MagicMock()
self.assertRaises(errors.APIError, self.driver.kill,
mock_container,
'test')
self.mock_docker.kill.assert_called_once_with(
mock_container.container_id, 'test')
self.mock_docker.inspect_container.assert_called_once_with(
mock_container.container_id)
self.assertEqual(1, mock_init.call_count)
def test_resize(self):
self.mock_docker.resize = mock.Mock()