Ensure online migrations have a unique name
As noted at [1], we rely on the names of migration functions in the output of 'online_data_migrations' command. Enforce this in tests. The test is renamed to match what it's testing so I can find it by grepping. [1] https://review.opendev.org/#/c/537414/19/nova/cmd/manage.py@697 Change-Id: I5a4b9b8648dbfccf7afc64f00bb86b0e01cbb671 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
463017b51b
commit
008b60a1cc
|
@ -383,6 +383,7 @@ class DbCommands(object):
|
|||
# remains. If found is nonzero and done is zero, some records are
|
||||
# not migratable (or don't need migrating), but all migrations that can
|
||||
# complete have finished.
|
||||
# NOTE(stephenfin): These names must be unique
|
||||
online_migrations = (
|
||||
# Added in Pike
|
||||
# TODO(mriedem): Remove this in the U release.
|
||||
|
|
|
@ -377,17 +377,22 @@ class NeutronV2NetworkCommandsTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(2, self.commands.modify('192.168.0.1'))
|
||||
|
||||
|
||||
class DBCommandsTestCase(test.NoDBTestCase):
|
||||
class DbCommandsTestCase(test.NoDBTestCase):
|
||||
USES_DB_SELF = True
|
||||
|
||||
def setUp(self):
|
||||
super(DBCommandsTestCase, self).setUp()
|
||||
super(DbCommandsTestCase, self).setUp()
|
||||
self.output = StringIO()
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output))
|
||||
self.commands = manage.DbCommands()
|
||||
self.useFixture(nova_fixtures.Database())
|
||||
self.useFixture(nova_fixtures.Database(database='api'))
|
||||
|
||||
def test_online_migrations_unique(self):
|
||||
names = [m.__name__ for m in self.commands.online_migrations]
|
||||
self.assertEqual(len(set(names)), len(names),
|
||||
'Online migrations must have a unique name')
|
||||
|
||||
def test_archive_deleted_rows_negative(self):
|
||||
self.assertEqual(2, self.commands.archive_deleted_rows(-1))
|
||||
|
||||
|
|
Loading…
Reference in New Issue