Esempio n. 1
0
 def test_validate_container_state(self):
     container = Container(self.context, **utils.get_test_container())
     container.status = 'Stopped'
     self.assertRaises(exception.InvalidStateException,
                       self.compute_manager._validate_container_state,
                       container, 'stop')
     self.assertRaises(exception.InvalidStateException,
                       self.compute_manager._validate_container_state,
                       container, 'pause')
     container.status = 'Running'
     self.assertRaises(exception.InvalidStateException,
                       self.compute_manager._validate_container_state,
                       container, 'start')
     self.assertRaises(exception.InvalidStateException,
                       self.compute_manager._validate_container_state,
                       container, 'unpause')
Esempio n. 2
0
 def test_container_delete_invalid_state(self, mock_validate):
     container = Container(self.context, **utils.get_test_container())
     mock_validate.side_effect = exception.InvalidStateException
     self.assertRaises(exception.InvalidStateException,
                       self.compute_manager.container_delete, self.context,
                       container, False)
Esempio n. 3
0
 def test_container_delete(self, mock_delete, mock_validate):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager.container_delete(self.context, container, False)
     mock_delete.assert_called_once_with(container, False)
Esempio n. 4
0
 def test_container_create_docker_create_failed(self, mock_fail,
                                                mock_create, mock_save):
     container = Container(self.context, **utils.get_test_container())
     mock_create.side_effect = exception.DockerError
     self.compute_manager._do_container_create(self.context, container)
     mock_fail.assert_called_once_with(container)
Esempio n. 5
0
 def test_container_create(self, mock_create, mock_pull, mock_save):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager._do_container_create(self.context, container)
     mock_save.assert_called_with()
     mock_pull.assert_called_once_with(container.image)
     mock_create.assert_called_once_with(container)
Esempio n. 6
0
 def test_fail_container(self, mock_save):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager._fail_container(container)
     self.assertEqual(fields.ContainerStatus.ERROR, container.status)
     self.assertIsNone(container.task_state)
Esempio n. 7
0
 def test_container_kill(self, mock_kill):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager.container_kill(self.context, container, None)
     mock_kill.assert_called_once_with(container, None)
Esempio n. 8
0
 def test_container_kill_failed(self, mock_kill, mock_validate):
     container = Container(self.context, **utils.get_test_container())
     mock_kill.side_effect = exception.DockerError
     self.assertRaises(exception.DockerError,
                       self.compute_manager.container_kill, self.context,
                       container, None)
Esempio n. 9
0
 def test_container_execute_failed(self, mock_execute):
     container = Container(self.context, **utils.get_test_container())
     mock_execute.side_effect = exception.DockerError
     self.assertRaises(exception.DockerError,
                       self.compute_manager.container_exec, self.context,
                       container, 'fake_cmd')
Esempio n. 10
0
 def test_container_execute(self, mock_execute):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager.container_exec(self.context, container,
                                         'fake_cmd')
     mock_execute.assert_called_once_with(container, 'fake_cmd')
Esempio n. 11
0
 def test_container_logs_failed(self, mock_logs):
     container = Container(self.context, **utils.get_test_container())
     mock_logs.side_effect = exception.DockerError
     self.assertRaises(exception.DockerError,
                       self.compute_manager.container_logs, self.context,
                       container)
Esempio n. 12
0
 def test_container_logs(self, mock_logs):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager.container_logs(self.context, container)
     mock_logs.assert_called_once_with(container)
Esempio n. 13
0
 def test_container_unpause(self, mock_unpause, mock_validate):
     container = Container(self.context, **utils.get_test_container())
     self.compute_manager.container_unpause(self.context, container)
     mock_unpause.assert_called_once_with(container)