From 401e35e152912361e084ef8b5915cf5620b9f1d6 Mon Sep 17 00:00:00 2001 From: Mike Fedosin Date: Tue, 24 Mar 2015 15:58:08 +0300 Subject: [PATCH] Fix metadef tags migrations Adds new migration to fix an issue with an index created by mysql. Also includes patch I00da67ab06cd0a3c46aa8a6cd815d0559408c2f0, because without it tests won't pass. Change-Id: Iffb54d5ee404889d49c40dbe0401d61e55723872 Co-Authored-By: Mike Fedosin Co-Authored-By: Andreas Jaeger Co-Authored-By: Oleksii Chuprykov --- ...40_add_changes_to_satisfy_metadefs_tags.py | 24 +++++++++++++++ glance/tests/unit/test_migrations.py | 15 ++++++++-- requirements.txt | 30 +++++++++---------- test-requirements.txt | 4 +-- 4 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py diff --git a/glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py b/glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py new file mode 100644 index 0000000000..1c52e90155 --- /dev/null +++ b/glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py @@ -0,0 +1,24 @@ +# 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. + + +import sqlalchemy +from sqlalchemy import (Table, Index) + + +def upgrade(migrate_engine): + if migrate_engine.name == 'mysql': + meta = sqlalchemy.MetaData() + meta.bind = migrate_engine + metadef_tags = Table('metadef_tags', meta, autoload=True) + Index('namespace_id', metadef_tags.c.namespace_id, + metadef_tags.c.name).drop() diff --git a/glance/tests/unit/test_migrations.py b/glance/tests/unit/test_migrations.py index 3233e27f1c..184a252cca 100644 --- a/glance/tests/unit/test_migrations.py +++ b/glance/tests/unit/test_migrations.py @@ -90,7 +90,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin): return self.engine def test_walk_versions(self): - self._walk_versions(True, False) + # No more downgrades + self._walk_versions(False, False) def _create_unversioned_001_db(self, engine): # Create the initial version of the images table @@ -1485,6 +1486,15 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin): self.assertTrue(unique_constraint_exist( 'name', metadef_resource_types.name, engine)) + def _check_040(self, engine, data): + meta = sqlalchemy.MetaData() + meta.bind = engine + metadef_tags = sqlalchemy.Table('metadef_tags', meta, autoload=True) + + if engine.name == 'mysql': + self.assertFalse(index_exist('namespace_id', + metadef_tags.name, engine)) + class TestMysqlMigrations(test_base.MySQLOpportunisticTestCase, MigrationsMixin): @@ -1518,7 +1528,8 @@ class TestPostgresqlMigrations(test_base.PostgreSQLOpportunisticTestCase, class TestSqliteMigrations(test_base.DbTestCase, MigrationsMixin): def test_walk_versions(self): - self._walk_versions(True, True) + # No more downgrades + self._walk_versions(False, False) class ModelsMigrationSyncMixin(object): diff --git a/requirements.txt b/requirements.txt index 3a4db2b3d2..9837114c05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ greenlet>=0.3.2 # < 0.8.0/0.8 does not work, see https://bugs.launchpad.net/bugs/1153983 SQLAlchemy>=0.9.7,<=0.9.99 anyjson>=0.3.3 -eventlet>=0.16.1 +eventlet>=0.16.1,!=0.17.0 PasteDeploy>=1.5.0 Routes>=1.12.3,!=2.0 WebOb>=1.2.3 @@ -22,13 +22,13 @@ kombu>=2.5.0 pycrypto>=2.6 iso8601>=0.1.9 ordereddict -oslo.config>=1.9.0 # Apache-2.0 -oslo.concurrency>=1.4.1 # Apache-2.0 -oslo.context>=0.2.0 # Apache-2.0 -oslo.utils>=1.2.0 # Apache-2.0 -stevedore>=1.1.0 # Apache-2.0 -taskflow>=0.6 -keystonemiddleware>=1.0.0 +oslo.config>=1.9.3,<1.10.0 # Apache-2.0 +oslo.concurrency>=1.8.0,<1.9.0 # Apache-2.0 +oslo.context>=0.2.0,<0.3.0 # Apache-2.0 +oslo.utils>=1.4.0,<1.5.0 # Apache-2.0 +stevedore>=1.3.0,<1.4.0 # Apache-2.0 +taskflow>=0.7.1,<0.8.0 +keystonemiddleware>=1.5.0 WSME>=0.6 # For openstack/common/lockutils posix_ipc @@ -37,7 +37,7 @@ posix_ipc python-swiftclient>=2.2.0 # For VMware storage backed. -oslo.vmware>=0.11.0 # Apache-2.0 +oslo.vmware>=0.11.1,<0.12.0 # Apache-2.0 # For paste.util.template used in keystone.common.template Paste @@ -49,12 +49,12 @@ semantic_version>=2.3.1 # Required by openstack.common libraries six>=1.9.0 -oslo.db>=1.5.0 # Apache-2.0 -oslo.i18n>=1.3.0 # Apache-2.0 -oslo.log>=0.4.0 # Apache-2.0 -oslo.messaging>=1.6.0 # Apache-2.0 -oslo.policy~=0.3.1 # Apache-2.0 -oslo.serialization>=1.2.0 # Apache-2.0 +oslo.db>=1.7.0,<1.8.0 # Apache-2.0 +oslo.i18n>=1.5.0,<1.6.0 # Apache-2.0 +oslo.log>=1.0.0,<1.1.0 # Apache-2.0 +oslo.messaging>=1.8.0,<1.9.0 # Apache-2.0 +oslo.policy>=0.3.1,<0.4.0 # Apache-2.0 +oslo.serialization>=1.4.0,<1.5.0 # Apache-2.0 retrying>=1.2.3,!=1.3.0 # Apache-2.0 osprofiler>=0.3.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index e2b6f4e839..74617b36fc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -19,7 +19,7 @@ requests>=2.2.0,!=2.4.0 testrepository>=0.0.18 testtools>=0.9.36,!=1.2.0 psutil>=1.1.1,<2.0.0 -oslotest>=1.2.0 # Apache-2.0 +oslotest>=1.5.1,<1.6.0 # Apache-2.0 # Optional packages that should be installed when testing MySQL-python psycopg2 @@ -28,4 +28,4 @@ qpid-python xattr>=0.4 # Documentation -oslosphinx>=2.2.0 # Apache-2.0 +oslosphinx>=2.5.0,<2.6.0 # Apache-2.0