]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Support new mitaka directory with revisions
authorIhar Hrachyshka <ihrachys@redhat.com>
Wed, 30 Sep 2015 14:00:21 +0000 (16:00 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Wed, 30 Sep 2015 16:58:52 +0000 (18:58 +0200)
Also, don't initialize a new 'per-release' directory with new revisions
that have branch labels because we don't maintain per release labels
anymore.

Change-Id: I3a875e239602147d82d28994788c3409d64d6992

neutron/db/migration/__init__.py
neutron/db/migration/autogen.py
neutron/db/migration/cli.py
neutron/tests/unit/db/test_migration.py

index 81b491083083b4fe19a39bf33ff216e65437cd35..e69b8ab6bfd0883bc3058c88885bd8790c9cc739 100644 (file)
@@ -23,10 +23,12 @@ from sqlalchemy.engine import reflection
 
 # Neutron milestones for upgrade aliases
 LIBERTY = 'liberty'
+MITAKA = 'mitaka'
 
 NEUTRON_MILESTONES = [
     # earlier milestones were not tagged
     LIBERTY,
+    MITAKA,
 ]
 
 CREATION_OPERATIONS = (sa.sql.ddl.CreateIndex,
index 68257e44e0820be686c8e8ddc6190bf6901fe90f..daa3aaa802ac460eb6bfa2c5272b68cce89c6ed9 100644 (file)
@@ -52,7 +52,8 @@ def _migration_script_ops(context, directive, phase):
     the correct branch labels/depends_on/head revision are set up.
 
     """
-    version_path = cli._get_version_branch_path(context.config, phase)
+    version_path = cli._get_version_branch_path(
+        context.config, release=cli.CURRENT_RELEASE, branch=phase)
     autogen_kwargs = {}
     cli._check_bootstrap_new_branch(phase, version_path, autogen_kwargs)
 
index b998a082c004330153513ed695944ac97b500e6d..9dbb457d2edccc4bf5d37bdf6538e3be5c825ce2 100644 (file)
@@ -31,7 +31,12 @@ from neutron.db import migration
 
 HEAD_FILENAME = 'HEAD'
 HEADS_FILENAME = 'HEADS'
-CURRENT_RELEASE = migration.LIBERTY
+
+CURRENT_RELEASE = migration.MITAKA
+RELEASES = (
+    migration.LIBERTY,
+    migration.MITAKA,
+)
 
 EXPAND_BRANCH = 'expand'
 CONTRACT_BRANCH = 'contract'
@@ -216,7 +221,6 @@ def _check_bootstrap_new_branch(branch, version_path, addn_kwargs):
     if not os.path.exists(version_path):
         # Bootstrap initial directory structure
         utils.ensure_dir(version_path)
-        addn_kwargs['branch_label'] = branch
 
 
 def do_revision(config, cmd):
@@ -231,7 +235,9 @@ def do_revision(config, cmd):
 def _get_release_labels(labels):
     result = set()
     for label in labels:
-        result.add('%s_%s' % (CURRENT_RELEASE, label))
+        # release labels were introduced Liberty for a short time and dropped
+        # in that same release cycle
+        result.add('%s_%s' % (migration.LIBERTY, label))
     return result
 
 
@@ -453,10 +459,10 @@ def _get_heads_file_path(config):
         HEADS_FILENAME)
 
 
-def _get_version_branch_path(config, branch=None):
+def _get_version_branch_path(config, release=None, branch=None):
     version_path = _get_root_versions_dir(config)
-    if branch:
-        return os.path.join(version_path, CURRENT_RELEASE, branch)
+    if branch and release:
+        return os.path.join(version_path, release, branch)
     return version_path
 
 
@@ -474,11 +480,14 @@ def _use_separate_migration_branches(config):
 
 def _set_version_locations(config):
     '''Make alembic see all revisions in all migration branches.'''
+    split_branches = False
     version_paths = [_get_version_branch_path(config)]
-    for branch in MIGRATION_BRANCHES:
-        version_path = _get_version_branch_path(config, branch)
-        if os.path.exists(version_path):
-            version_paths.append(version_path)
+    for release in RELEASES:
+        for branch in MIGRATION_BRANCHES:
+            version_path = _get_version_branch_path(config, release, branch)
+            if split_branches or os.path.exists(version_path):
+                split_branches = True
+                version_paths.append(version_path)
 
     config.set_main_option('version_locations', ' '.join(version_paths))
 
index d5e0eda7581926ac06e7077214a8c32c303a8141..3c149ea87ce8a3573296219398d7a0a3a48c22f1 100644 (file)
@@ -531,7 +531,7 @@ class TestCli(base.BaseTestCase):
             use_separate_migration_branches):
 
         use_separate_migration_branches.return_value = True
-        get_version_branch_path.side_effect = lambda cfg, branch: (
+        get_version_branch_path.side_effect = lambda cfg, release, branch: (
             "/foo/expand" if branch == 'expand' else "/foo/contract")
 
         migration_script = alembic_ops.MigrationScript(