Browse Source

[FT] Reduce "test_walk_versions" upgrade executions

"_TestWalkMigrations.test_walk_versions" is inherited in other classes
to check a specific DB revision upgrade. The goal is to, from the
previous DB revision, create a testing condition and then upgrade to
the related DB revision. If the upgrade is correct, the test should
pass.

This patch reduces the number of Neutron DB upgrade operations to
just three:
- Upgrade the DB to the previous DB revision to check.
- Upgrade the DB to the related DB revision, after setting the testing
  conditions.
- A final upgrade up to the latest DB revision.

In a testing deployment, this reduces the execution time from 60 seconds
to 35 seconds, without reducing the testing scope.

Change-Id: Iffdc0373ed72aea1320155ea8bec93dce797f27c
Related-Bug: #1911153
(cherry picked from commit c84ae9762c)
changes/60/783560/1
Rodolfo Alonso Hernandez 7 months ago
parent
commit
7946e41a62
  1. 29
      neutron/tests/functional/db/test_migrations.py

29
neutron/tests/functional/db/test_migrations.py

@ -592,18 +592,18 @@ class _TestWalkMigrations(object):
# Destination, current
yield rev.revision, rev.down_revision
def _migrate_up(self, config, engine, dest, curr, with_data=False):
if with_data:
data = None
pre_upgrade = getattr(
self, "_pre_upgrade_%s" % dest, None)
if pre_upgrade:
data = pre_upgrade(engine)
migration.do_alembic_command(config, 'upgrade', dest)
if with_data:
check = getattr(self, "_check_%s" % dest, None)
if check and data:
check(engine, data)
def _migrate_up(self, config, engine, dest, curr):
data = None
check = getattr(self, "_check_%s" % dest, None)
pre_upgrade = getattr(self, "_pre_upgrade_%s" % dest, None)
if pre_upgrade:
if curr:
migration.do_alembic_command(config, 'upgrade', curr)
data = pre_upgrade(engine)
if check and data:
migration.do_alembic_command(config, 'upgrade', dest)
check(engine, data)
def test_walk_versions(self):
"""Test migrations ability to upgrade and downgrade.
@ -613,7 +613,10 @@ class _TestWalkMigrations(object):
config = self._get_alembic_config(engine.url)
revisions = self._revisions()
for dest, curr in revisions:
self._migrate_up(config, engine, dest, curr, with_data=True)
self._migrate_up(config, engine, dest, curr)
if dest:
migration.do_alembic_command(config, 'upgrade', dest)
class TestWalkMigrationsMysql(testlib_api.MySQLTestCaseMixin,

Loading…
Cancel
Save