From 2a9ac87cc412431b268aba40729e144bd34bdf32 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 12 Jul 2023 19:01:19 +0100 Subject: [PATCH] Add job to test with SQLAlchemy master (2.x) Signed-off-by: Stephen Finucane Change-Id: Ib67538ebd0f8ebbea5a700343f52655b0f7fecd4 --- manila/tests/db/sqlalchemy/test_api.py | 34 ++++++++++++++++++++++---- zuul.d/project.yaml | 18 ++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/manila/tests/db/sqlalchemy/test_api.py b/manila/tests/db/sqlalchemy/test_api.py index 1cb1c7d944..fa990faa30 100644 --- a/manila/tests/db/sqlalchemy/test_api.py +++ b/manila/tests/db/sqlalchemy/test_api.py @@ -1997,13 +1997,37 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase): def test_share_snapshot_instance_access_get_all(self): access = db_utils.create_snapshot_access( share_snapshot_id=self.snapshot_1['id']) - values = {'share_snapshot_instance_id': self.snapshot_instances[0].id, - 'access_id': access['id']} - rules = db_api.share_snapshot_instance_access_get_all( - self.ctxt, access['id']) + # NOTE(zzzeek) the create_snapshot_access routine iterates through the + # ShareSnapshot.instances collection and creates a new + # ShareSnapshotInstanceAccessMapping for each ShareSnapshotInstance. + # however, this collection is unordered and does not have any guarantee + # that its ordering would match that of our self.snapshot_instances + # collection. Therefore key the fixture values and the resulting + # ShareSnapshotInstanceAccessMapping objects by share_snapshot_id + # and compare individually. - self.assertSubDictMatch(values, rules[0].to_dict()) + values_by_sid = { + snapshot_instance.id: { + 'share_snapshot_instance_id': snapshot_instance.id, + 'access_id': access['id'] + } + for snapshot_instance in self.snapshot_instances + if "fake" not in snapshot_instance.id + } + + rules_by_sid = { + rule.share_snapshot_instance_id: rule + for rule in db_api.share_snapshot_instance_access_get_all( + self.ctxt, access['id'] + ) + } + + for sid in values_by_sid: + self.assertSubDictMatch( + values_by_sid[sid], + rules_by_sid[sid].to_dict() + ) def test_share_snapshot_access_get(self): access = db_utils.create_snapshot_access( diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index ca61ccd2dd..95bd89b37f 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -10,6 +10,7 @@ queue: manila check: jobs: + - manila-tox-py311-with-sqlalchemy-2x - manila-tox-genconfig - openstack-tox-pylint: voting: false @@ -30,9 +31,26 @@ voting: false gate: jobs: + - manila-tox-py311-with-sqlalchemy-2x - manila-tempest-plugin-dummy-no-dhss - manila-tempest-plugin-dummy-dhss +# Temporary job until SQLAlchemy 2.0 is no longer blocked by upper-requirements +- job: + name: manila-tox-py311-with-sqlalchemy-2x + parent: openstack-tox-py311 + description: | + Run unit tests with main branch of SQLAlchemy, alembic and oslo.db. + Takes advantage of the base tox job's install-siblings feature. + # The job only tests the latest and shouldn't be run on the stable branches + branches: master + required-projects: + - name: github.com/sqlalchemy/sqlalchemy + override-checkout: main + - name: github.com/sqlalchemy/alembic + override-checkout: main + - name: openstack/oslo.db + - job: name: manila-tox-genconfig parent: openstack-tox