nova/nova/tests/functional/db/test_request_spec.py
Matt Riedemann ed4fe3ead6 Drop request spec migration code
This removes the request spec online data migration
routine added via change I61b9b50436d8bdb8ff06259cc2f876502d688b91
in Newton.

A nova-status upgrade check was added for this in Rocky with
change I1fb63765f0b0e8f35d6a66dccf9d12cc20e9c661 so operators should
be able to tell, either from the results of the nova-status upgrade
check command or "nova-manage db online_data_migrations" command,
whether or not they have completed the migration and can upgrade to
Stein.

This also allows us to start removing the various compat checks
in the API and conductor services for old instances that predated
having a request spec since those should have a request spec now
via the online data migration.

Related to blueprint request-spec-use-by-compute

Change-Id: Ib0de49b3c0d6b3d807c4eb321976848773c1a9e8
2018-12-17 13:54:48 -05:00

81 lines
3.0 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nova import context
from nova import exception
from nova.objects import base as obj_base
from nova.objects import request_spec
from nova import test
from nova.tests import fixtures
from nova.tests.unit import fake_request_spec
class RequestSpecTestCase(test.NoDBTestCase):
USES_DB_SELF = True
def setUp(self):
super(RequestSpecTestCase, self).setUp()
self.useFixture(fixtures.Database(database='api'))
# NOTE(danms): Only needed for the fallback legacy main db loading
# code in InstanceGroup.
self.useFixture(fixtures.Database(database='main'))
self.context = context.RequestContext('fake-user', 'fake-project')
self.spec_obj = request_spec.RequestSpec()
self.instance_uuid = None
def _create_spec(self):
args = fake_request_spec.fake_db_spec()
args.pop('id', None)
self.instance_uuid = args['instance_uuid']
request_spec.RequestSpec._from_db_object(self.context, self.spec_obj,
self.spec_obj._create_in_db(self.context, args))
return self.spec_obj
def test_get_by_instance_uuid_not_found(self):
self.assertRaises(exception.RequestSpecNotFound,
self.spec_obj._get_by_instance_uuid_from_db, self.context,
self.instance_uuid)
def test_get_by_uuid(self):
spec = self._create_spec()
db_spec = self.spec_obj.get_by_instance_uuid(self.context,
self.instance_uuid)
self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
def test_save_in_db(self):
spec = self._create_spec()
old_az = spec.availability_zone
spec.availability_zone = '%s-new' % old_az
spec.save()
db_spec = self.spec_obj.get_by_instance_uuid(self.context,
spec.instance_uuid)
self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
self.assertNotEqual(old_az, db_spec.availability_zone)
def test_double_create(self):
spec = self._create_spec()
self.assertRaises(exception.ObjectActionError, spec.create)
def test_destroy(self):
spec = self._create_spec()
spec.destroy()
self.assertRaises(
exception.RequestSpecNotFound,
self.spec_obj._get_by_instance_uuid_from_db, self.context,
self.instance_uuid)
def test_destroy_not_found(self):
spec = self._create_spec()
spec.destroy()
self.assertRaises(exception.RequestSpecNotFound, spec.destroy)