From 52bd1e51d675a1eb1226a45e3e952b17bda712a2 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 16 Aug 2021 12:35:27 +0100 Subject: [PATCH] tests: Enable SQLAlchemy 2.0 deprecation warnings Well, sort of. We enable them but immediately filter out the ones we're actually seeing, the rationale being that we can address these in a piecemeal fashion without the risk of introducing new issues. There's a lot more to be done here. However, the work done in oslo.db [1] should provide a guide for how to resolve the outstanding issues. [1] https://review.opendev.org/q/topic:%2522sqlalchemy-20%2522+project:openstack/oslo.db Change-Id: Iafe726d3819031c357460fd131bb2bb58babb4e2 Signed-off-by: Stephen Finucane --- nova/tests/fixtures/nova.py | 114 +++++++++++++++++++++++++++++++++++- tox.ini | 2 + 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py index 1cc5b1b0d45b..eece97f5f11f 100644 --- a/nova/tests/fixtures/nova.py +++ b/nova/tests/fixtures/nova.py @@ -820,16 +820,126 @@ class WarningsFixture(fixtures.Fixture): 'error', message='Evaluating non-mapped column expression', category=sqla_exc.SAWarning) - # Enable deprecation warnings to capture upcoming SQLAlchemy changes + # Enable deprecation warnings for nova itself to capture upcoming + # SQLAlchemy changes + + warnings.filterwarnings( + 'ignore', + category=sqla_exc.SADeprecationWarning) warnings.filterwarnings( 'error', module='nova', category=sqla_exc.SADeprecationWarning) - # TODO(stephenfin): Remove once we fix this is oslo.db 10.0.1 or so + # ...but filter everything out until we get around to fixing them + # TODO(stephenfin): Fix all of these + warnings.filterwarnings( 'ignore', + module='nova', + message=r'The Engine.execute\(\) method is considered legacy', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The autoload parameter is deprecated .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The current statement is being autocommitted .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The MetaData.bind argument is deprecated .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The legacy calling style of select\(\) .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The ``bind`` argument for schema methods .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The Column.copy\(\) method is deprecated .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The Row.keys\(\) method is considered legacy .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'Using non-integer/slice indices on Row is deprecated .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The .close\(\) method on a so-called .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The Connection.connect\(\) method is considered .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'Passing a string to Connection.execute\(\) is .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The insert.inline parameter will be removed .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'Using strings to indicate column or relationship .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'Using strings to indicate relationship names .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The Executable.execute\(\) method is considered .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', + message=r'The Executable.scalar\(\) method is considered .*', + category=sqla_exc.SADeprecationWarning) + + warnings.filterwarnings( + 'ignore', + module='nova', message=r'Invoking and_\(\) without arguments is deprecated, .*', category=sqla_exc.SADeprecationWarning) diff --git a/tox.ini b/tox.ini index c03b9a8c9a17..3f03984e1637 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,8 @@ setenv = OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=160 PYTHONDONTWRITEBYTECODE=1 +# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0 + SQLALCHEMY_WARN_20=1 deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt