Merge "trivial: Remove legacy API artifact"
This commit is contained in:
@@ -88,13 +88,8 @@ class CommonMixin(object):
|
||||
|
||||
with mock.patch.object(self.compute_api, method) as mock_method:
|
||||
controller_function = getattr(self.controller, action)
|
||||
res = controller_function(self.req, instance.uuid, body=body)
|
||||
# NOTE: on v2.1, http status code is set as wsgi_codes of API
|
||||
# method instead of status_int in a response object.
|
||||
if self._api_version == '2.1':
|
||||
status_int = controller_function.wsgi_codes(self.req)
|
||||
else:
|
||||
status_int = res.status_int
|
||||
controller_function(self.req, instance.uuid, body=body)
|
||||
status_int = controller_function.wsgi_codes(self.req)
|
||||
self.assertEqual(202, status_int)
|
||||
mock_method.assert_called_once_with(self.context, instance, *args,
|
||||
**kwargs)
|
||||
|
||||
@@ -12,21 +12,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.api.openstack.compute import admin_actions as admin_actions_v21
|
||||
from nova.api.openstack.compute import admin_actions
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
|
||||
|
||||
class AdminActionsTestV21(admin_only_action_common.CommonTests):
|
||||
admin_actions = admin_actions_v21
|
||||
_api_version = '2.1'
|
||||
class AdminActionsTest(admin_only_action_common.CommonTests):
|
||||
|
||||
def setUp(self):
|
||||
super(AdminActionsTestV21, self).setUp()
|
||||
self.controller = self.admin_actions.AdminActionsController()
|
||||
super().setUp()
|
||||
self.controller = admin_actions.AdminActionsController()
|
||||
self.compute_api = self.controller.compute_api
|
||||
self.stub_out('nova.api.openstack.compute.admin_actions.'
|
||||
'AdminActionsController',
|
||||
lambda *a, **k: self.controller)
|
||||
|
||||
def test_actions(self):
|
||||
actions = ['_inject_network_info']
|
||||
|
||||
@@ -17,24 +17,18 @@ from unittest import mock
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute import lock_server as lock_server_v21
|
||||
from nova.api.openstack.compute import lock_server
|
||||
from nova import exception
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
from nova.tests.unit import fake_instance
|
||||
|
||||
|
||||
class LockServerTestsV21(admin_only_action_common.CommonTests):
|
||||
lock_server = lock_server_v21
|
||||
controller_name = 'LockServerController'
|
||||
_api_version = '2.1'
|
||||
class LockServerTests(admin_only_action_common.CommonTests):
|
||||
|
||||
def setUp(self):
|
||||
super(LockServerTestsV21, self).setUp()
|
||||
self.controller = getattr(self.lock_server, self.controller_name)()
|
||||
super().setUp()
|
||||
self.controller = lock_server.LockServerController()
|
||||
self.compute_api = self.controller.compute_api
|
||||
self.stub_out('nova.api.openstack.compute.lock_server.'
|
||||
'LockServerController',
|
||||
lambda *a, **kw: self.controller)
|
||||
|
||||
def test_lock_unlock(self):
|
||||
args_map = {'_lock': ((), {"reason": None})}
|
||||
@@ -74,7 +68,7 @@ class LockServerTestsV21(admin_only_action_common.CommonTests):
|
||||
self.req.environ['nova.context'], instance, reason=None)
|
||||
|
||||
|
||||
class LockServerTestsV273(LockServerTestsV21):
|
||||
class LockServerTestsV273(LockServerTests):
|
||||
|
||||
def setUp(self):
|
||||
super(LockServerTestsV273, self).setUp()
|
||||
|
||||
@@ -21,31 +21,23 @@ from oslo_utils import uuidutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute import migrate_server as \
|
||||
migrate_server_v21
|
||||
from nova.api.openstack.compute import migrate_server
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
|
||||
|
||||
class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
migrate_server = migrate_server_v21
|
||||
controller_name = 'MigrateServerController'
|
||||
validation_error = exception.ValidationError
|
||||
_api_version = '2.1'
|
||||
class MigrateServerTests(admin_only_action_common.CommonTests):
|
||||
disk_over_commit = False
|
||||
force = None
|
||||
async_ = False
|
||||
host_name = None
|
||||
|
||||
def setUp(self):
|
||||
super(MigrateServerTestsV21, self).setUp()
|
||||
self.controller = getattr(self.migrate_server, self.controller_name)()
|
||||
super().setUp()
|
||||
self.controller = migrate_server.MigrateServerController()
|
||||
self.compute_api = self.controller.compute_api
|
||||
self.stub_out('nova.api.openstack.compute.migrate_server.'
|
||||
'MigrateServerController',
|
||||
lambda *a, **kw: self.controller)
|
||||
self.mock_neutron_extension_list = self.useFixture(
|
||||
fixtures.MockPatch(
|
||||
'nova.network.neutron.API._refresh_neutron_extensions_cache'
|
||||
@@ -181,14 +173,14 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
def test_migrate_live_without_host(self):
|
||||
body = self._get_migration_body()
|
||||
del body['os-migrateLive']['host']
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
def test_migrate_live_without_block_migration(self):
|
||||
body = self._get_migration_body()
|
||||
del body['os-migrateLive']['block_migration']
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -196,13 +188,13 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
body = {'os-migrateLive':
|
||||
{'host': 'hostname',
|
||||
'block_migration': False}}
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
def test_migrate_live_with_invalid_block_migration(self):
|
||||
body = self._get_migration_body(block_migration='foo')
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -211,7 +203,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
{'host': 'hostname',
|
||||
'block_migration': False,
|
||||
'disk_over_commit': "foo"}}
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -219,7 +211,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
body = self._get_migration_body(host='hostname')
|
||||
del body['os-migrateLive']['host']
|
||||
body['os-migrateLive']['dummy'] = 'hostname'
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -337,7 +329,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
|
||||
class MigrateServerTestsV225(MigrateServerTestsV21):
|
||||
class MigrateServerTestsV225(MigrateServerTests):
|
||||
|
||||
# We don't have disk_over_commit in v2.25
|
||||
disk_over_commit = None
|
||||
@@ -377,7 +369,7 @@ class MigrateServerTestsV225(MigrateServerTestsV21):
|
||||
{'host': 'hostname',
|
||||
'block_migration': 'auto',
|
||||
'disk_over_commit': False}}
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -414,7 +406,7 @@ class MigrateServerTestsV230(MigrateServerTestsV225):
|
||||
def test_forced_live_migrate_with_no_provided_host(self):
|
||||
body = {'os-migrateLive':
|
||||
{'force': 'true'}}
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -526,7 +518,7 @@ class MigrateServerTestsV256(MigrateServerTestsV234):
|
||||
'2.56')
|
||||
|
||||
def _test_migrate_validation_error(self, body):
|
||||
self.assertRaises(self.validation_error,
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
|
||||
@@ -625,7 +617,7 @@ class MigrateServerTestsV268(MigrateServerTestsV256):
|
||||
body = {'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto',
|
||||
'force': 'true'}}
|
||||
ex = self.assertRaises(self.validation_error,
|
||||
ex = self.assertRaises(exception.ValidationError,
|
||||
self.controller._migrate_live,
|
||||
self.req, fakes.FAKE_UUID, body=body)
|
||||
self.assertIn('force', str(ex))
|
||||
|
||||
@@ -13,23 +13,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.api.openstack.compute import pause_server as \
|
||||
pause_server_v21
|
||||
from nova.api.openstack.compute import pause_server
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
|
||||
|
||||
class PauseServerTestsV21(admin_only_action_common.CommonTests):
|
||||
pause_server = pause_server_v21
|
||||
controller_name = 'PauseServerController'
|
||||
_api_version = '2.1'
|
||||
class PauseServerTests(admin_only_action_common.CommonTests):
|
||||
|
||||
def setUp(self):
|
||||
super(PauseServerTestsV21, self).setUp()
|
||||
self.controller = getattr(self.pause_server, self.controller_name)()
|
||||
super().setUp()
|
||||
self.controller = pause_server.PauseServerController()
|
||||
self.compute_api = self.controller.compute_api
|
||||
self.stub_out('nova.api.openstack.compute.pause_server.'
|
||||
'PauseServerController',
|
||||
lambda *a, **kw: self.controller)
|
||||
|
||||
def test_pause_unpause(self):
|
||||
self._test_actions(
|
||||
|
||||
@@ -18,25 +18,18 @@ import ddt
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import suspend_server as \
|
||||
suspend_server_v21
|
||||
from nova.api.openstack.compute import suspend_server
|
||||
from nova import exception
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class SuspendServerTestsV21(admin_only_action_common.CommonTests):
|
||||
suspend_server = suspend_server_v21
|
||||
controller_name = 'SuspendServerController'
|
||||
_api_version = '2.1'
|
||||
class SuspendServerTests(admin_only_action_common.CommonTests):
|
||||
|
||||
def setUp(self):
|
||||
super(SuspendServerTestsV21, self).setUp()
|
||||
self.controller = getattr(self.suspend_server, self.controller_name)()
|
||||
super().setUp()
|
||||
self.controller = suspend_server.SuspendServerController()
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user