Fix py311 unit test issues

- Dell EMC driver had an issue with mocking an object
and sending it forward.

- Some of the create table statements in the database
migrations didn't have the charset specified. That seemed
to trick the DB engine while defining foreign keys and
adding a name to them, as the default charset was defined
in the schema, but not in the tables. This behavior was also
noted in different places, like [1]. Fix this issue by
adding the charset to all create table statements, so they
match the engine default charset.

[1] https://github.com/apache/superset/issues/8808

Change-Id: I7cd6fa0cc8e054af112493746e753fef2024000f
(cherry picked from commit b44c36e5ba)
This commit is contained in:
silvacarloss 2023-09-20 18:50:18 -03:00 committed by Carlos Eduardo
parent 215389e014
commit 880da6ee68
8 changed files with 19 additions and 5 deletions

View File

@ -64,3 +64,8 @@ possible to use ``manila-manage db revision`` or the corresponding tox command::
In addition every migration script must be tested. See examples in
``manila/tests/db/migrations/alembic/migrations_data_checks.py``.
.. note::
When writing database migrations that create tables with unique constraints
or foreign keys, please ensure that the ``mysql_charset`` matches the
referenced table.

View File

@ -60,7 +60,7 @@ def upgrade():
nullable=False),
sa.Column('spec_key', sa.String(length=255)),
sa.Column('spec_value', sa.String(length=255)),
mysql_engine='InnoDB')
mysql_engine='InnoDB', mysql_charset='utf8')
LOG.info("Migrating volume_type_extra_specs to "
"share_type_extra_specs")

View File

@ -45,7 +45,8 @@ def upgrade():
sa.ForeignKey('share_snapshots.id',
name='ssam_snapshot_fk')),
sa.Column('access_type', sa.String(255)),
sa.Column('access_to', sa.String(255))
sa.Column('access_to', sa.String(255)),
mysql_charset='utf8'
)
op.create_table(
@ -62,7 +63,8 @@ def upgrade():
sa.ForeignKey('share_snapshot_access_map.id',
name='ssam_access_fk')),
sa.Column('state', sa.String(255),
default=constants.ACCESS_STATE_QUEUED_TO_APPLY)
default=constants.ACCESS_STATE_QUEUED_TO_APPLY),
mysql_charset='utf8'
)
op.create_table(
@ -76,7 +78,8 @@ def upgrade():
sa.ForeignKey('share_snapshot_instances.id',
name='ssiel_snapshot_instance_fk')),
sa.Column('path', sa.String(2000)),
sa.Column('is_admin_only', sa.Boolean, default=False, nullable=False)
sa.Column('is_admin_only', sa.Boolean, default=False, nullable=False),
mysql_charset='utf8'
)
op.add_column('shares',

View File

@ -49,6 +49,7 @@ def upgrade():
'share_type_id', 'resource', 'deleted',
name="uc_quotas_per_share_types"),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
for table_name in ('quota_usages', 'reservations'):
op.add_column(

View File

@ -99,6 +99,7 @@ def upgrade():
sa.UniqueConstraint('export_location_id', 'key', 'deleted',
name="elm_el_id_uc"),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
except Exception:
LOG.error("Failed to create '%s' table!", ELM_TABLE_NAME)

View File

@ -49,6 +49,7 @@ def upgrade():
sql.UniqueConstraint(
'name', 'deleted', name="uniq_share_group_type_name"),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
except Exception:
LOG.error("Table |%s| not created!", 'share_group_types')
@ -70,6 +71,7 @@ def upgrade():
sql.ForeignKey(
'share_group_types.id', name="sgtp_id_extra_specs_fk")),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
except Exception:
LOG.error("Table |%s| not created!", 'share_group_type_specs')
@ -92,6 +94,7 @@ def upgrade():
'share_group_type_id', 'project_id', 'deleted',
name="sgtp_project_id_uc"),
mysql_engine='InnoDB',
mysql_charset='utf8',
)
except Exception:
LOG.error("Table |%s| not created!", 'share_group_type_projects')

View File

@ -59,6 +59,7 @@ def upgrade():
sql.UniqueConstraint('share_type_id', 'project_id', 'deleted',
name="stp_project_id_uc"),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
except Exception:
LOG.error("Table |%s| not created!", 'share_type_projects')

View File

@ -278,7 +278,7 @@ class EMCShareFrameworkTestCase(test.TestCase):
snapshot_access_rules, share_server)
def test_unmanage_manage(self):
share = mock.Mock()
share = {}
server_details = {}
share_server = mock.Mock()
snapshot = mock.Mock()