Block flavor creation until main database is empty
This makes Flavor.create() fail until the main database has had all of its flavors migrated. Since we want to avoid any overlap or clashes in integer ids we need to enforce this. The flavor API was poorly designed in that it exposes this internal id. Luckily, flavor creation is infrequent and flavor migration is fast. The flavors in our database are hard-coded in the first migration, which means we have to basically do the migration during every unit test in order to avoid having a legacy environment. Since that leaves us with deleted flavors in the DB (which screws up the DB archiving tests), this adds a hard_delete flag to the migration to do an actual purge of those from our database. What a mess. Related to blueprint flavor-cell-api Depends-On: I8ab03af9d2f4974f26a7f8487ec978caea957e45 Change-Id: Iea063448f43da1043d16dd521d255dd29a0e1bc5
This commit is contained in:
@@ -49,6 +49,7 @@ from nova import db
|
||||
from nova.network import manager as network_manager
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova.objects import base as objects_base
|
||||
from nova.objects import flavor as flavor_obj
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
from nova.tests.unit import conf_fixture
|
||||
from nova.tests.unit import policy_fixture
|
||||
@@ -213,6 +214,11 @@ class TestCase(testtools.TestCase):
|
||||
if self.USES_DB:
|
||||
self.useFixture(nova_fixtures.Database())
|
||||
self.useFixture(nova_fixtures.Database(database='api'))
|
||||
# NOTE(danms): Flavors are encoded in our original migration
|
||||
# which means we have no real option other than to migrate them
|
||||
# onlineish every time we build a new database (for now).
|
||||
ctxt = context.get_admin_context()
|
||||
flavor_obj.migrate_flavors(ctxt, 100, hard_delete=True)
|
||||
elif not self.USES_DB_SELF:
|
||||
self.useFixture(nova_fixtures.DatabasePoisonFixture())
|
||||
|
||||
|
Reference in New Issue
Block a user