Merge "do not use str(url) to stringify a URL for subsequent use"

This commit is contained in:
Zuul 2024-07-10 20:47:29 +00:00 committed by Gerrit Code Review
commit 8a9bf456ad

View File

@ -69,8 +69,10 @@ class BaseWalkMigrationTestCase(object):
database functionality (reset default settings and session cleanup).
"""
CONF.set_override('uri', str(engine.url),
group='drivers:management_store:sqlalchemy')
CONF.set_override(
'uri',
engine.url.render_as_string(hide_password=False),
group='drivers:management_store:sqlalchemy')
def _alembic_command(self, alembic_command, engine, *args, **kwargs):
"""Most of alembic command return data into output.
@ -78,8 +80,10 @@ class BaseWalkMigrationTestCase(object):
We should redefine this setting for getting info.
"""
self.ALEMBIC_CONFIG.stdout = buf = io.StringIO()
CONF.set_override('uri', str(engine.url),
group='drivers:management_store:sqlalchemy')
CONF.set_override(
'uri',
engine.url.render_as_string(hide_password=False),
group='drivers:management_store:sqlalchemy')
getattr(command, alembic_command)(*args, **kwargs)
res = buf.getvalue().strip()
@ -180,8 +184,10 @@ class TestModelsMigrationsSync(t_m.ModelsMigrationsSync):
return self.engine
def db_sync(self, engine):
CONF.set_override('uri', str(engine.url),
group='drivers:management_store:sqlalchemy')
CONF.set_override(
'uri',
engine.url.render_as_string(hide_password=False),
group='drivers:management_store:sqlalchemy')
script_location = os.path.join(self.mg_path, 'alembic_migrations')
self.ALEMBIC_CONFIG.set_main_option('script_location', script_location)
alembic.command.upgrade(self.ALEMBIC_CONFIG, 'head')