Beispiel #1
0
class SuspendServerTestsV21(admin_only_action_common.CommonTests):
    suspend_server = suspend_server_v21
    controller_name = 'SuspendServerController'
    _api_version = '2.1'

    def setUp(self):
        super(SuspendServerTestsV21, self).setUp()
        self.controller = getattr(self.suspend_server, self.controller_name)()
        self.compute_api = self.controller.compute_api
        self.stub_out(
            'nova.api.openstack.compute.suspend_server.'
            'SuspendServerController', lambda *a, **kw: self.controller)

    def test_suspend_resume(self):
        self._test_actions(['_suspend', '_resume'])

    @ddt.data(
        exception.OperationNotSupportedForVDPAInterface(
            instance_uuid=uuids.instance, operation='foo'),
        exception.OperationNotSupportedForSEV(instance_uuid=uuids.instance,
                                              operation='foo'),
    )
    @mock.patch('nova.compute.api.API.suspend')
    def test_suspend__http_conflict_error(self, exc, mock_suspend):
        mock_suspend.side_effect = exc
        self.assertRaises(webob.exc.HTTPConflict,
                          self.controller._suspend,
                          self.req,
                          uuids.instance,
                          body={})
        self.assertTrue(mock_suspend.called)

    def test_suspend_resume_with_non_existed_instance(self):
        self._test_actions_with_non_existed_instance(['_suspend', '_resume'])

    def test_suspend_resume_raise_conflict_on_invalid_state(self):
        self._test_actions_raise_conflict_on_invalid_state(
            ['_suspend', '_resume'])

    def test_actions_with_locked_instance(self):
        self._test_actions_with_locked_instance(['_suspend', '_resume'])

    @mock.patch('nova.compute.api.API.suspend',
                side_effect=exception.ForbiddenWithAccelerators)
    def test_suspend_raises_http_forbidden(self, mock_suspend):
        self.assertRaises(webob.exc.HTTPForbidden,
                          self.controller._suspend,
                          self.req,
                          fakes.FAKE_UUID,
                          body={})
Beispiel #2
0
 def test_migrate_live_sev_not_supported(self):
     self._test_migrate_live_failed_with_exception(
         exception.OperationNotSupportedForSEV(instance_uuid=uuids.instance,
                                               operation='foo'),
         expected_exc=webob.exc.HTTPConflict,
         check_response=False)