From 9eddb132b2f1828cb36c6b5409b64ec54c2cc7ac Mon Sep 17 00:00:00 2001 From: Miguel Lavalle Date: Fri, 2 Sep 2022 17:10:11 -0500 Subject: [PATCH] Fix openstack-tox-py39-with-oslo-master job DB writer and reader contexts are added to test case [0] to make sure updates are commited to DB before testing if objects have been deleted. [0] neutron.tests.unit.objects.test_quota.ReservationDbObjectTestCase.test_delete_expired Change-Id: I7d3b940db867d97712b6d9de90920dca7c3c23eb Closes-Bug: #1988604 --- neutron/tests/unit/objects/test_quota.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/neutron/tests/unit/objects/test_quota.py b/neutron/tests/unit/objects/test_quota.py index 5f3ac86fffe..619ef33cde1 100644 --- a/neutron/tests/unit/objects/test_quota.py +++ b/neutron/tests/unit/objects/test_quota.py @@ -14,10 +14,10 @@ import datetime +from neutron_lib.db import api as db_api from oslo_utils import uuidutils from neutron.objects import quota -from neutron.tests import base as test_base from neutron.tests.unit.objects import test_base as obj_test_base from neutron.tests.unit import testlib_api @@ -59,18 +59,20 @@ class ReservationDbObjectTestCase(obj_test_base.BaseDbObjectTestCase, reservation.create() return reservation - @test_base.unstable_test('bug/1988604') def test_delete_expired(self): dt = datetime.datetime.utcnow() resources = {'goals': 2, 'assists': 1} exp_date1 = datetime.datetime(2016, 3, 31, 14, 30) - res1 = self._create_test_reservation(resources, exp_date1) exp_date2 = datetime.datetime(2015, 3, 31, 14, 30) - res2 = self._create_test_reservation(resources, exp_date2) - self.assertEqual(2, self._test_class.delete_expired( - self.context, dt, None)) - objs = self._test_class.get_objects(self.context, - id=[res1.id, res2.id]) + with db_api.CONTEXT_WRITER.using(self.context): + res1 = self._create_test_reservation(resources, exp_date1) + res2 = self._create_test_reservation(resources, exp_date2) + with db_api.CONTEXT_WRITER.using(self.context): + self.assertEqual(2, self._test_class.delete_expired( + self.context, dt, None)) + with db_api.CONTEXT_READER.using(self.context): + objs = self._test_class.get_objects(self.context, + id=[res1.id, res2.id]) self.assertEqual([], objs) def test_reservation_synthetic_field(self):