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
This commit is contained in:
parent
d0e33b9f32
commit
9eddb132b2
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from neutron.objects import quota
|
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.objects import test_base as obj_test_base
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
|
|
||||||
|
@ -59,18 +59,20 @@ class ReservationDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
|
||||||
reservation.create()
|
reservation.create()
|
||||||
return reservation
|
return reservation
|
||||||
|
|
||||||
@test_base.unstable_test('bug/1988604')
|
|
||||||
def test_delete_expired(self):
|
def test_delete_expired(self):
|
||||||
dt = datetime.datetime.utcnow()
|
dt = datetime.datetime.utcnow()
|
||||||
resources = {'goals': 2, 'assists': 1}
|
resources = {'goals': 2, 'assists': 1}
|
||||||
exp_date1 = datetime.datetime(2016, 3, 31, 14, 30)
|
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)
|
exp_date2 = datetime.datetime(2015, 3, 31, 14, 30)
|
||||||
res2 = self._create_test_reservation(resources, exp_date2)
|
with db_api.CONTEXT_WRITER.using(self.context):
|
||||||
self.assertEqual(2, self._test_class.delete_expired(
|
res1 = self._create_test_reservation(resources, exp_date1)
|
||||||
self.context, dt, None))
|
res2 = self._create_test_reservation(resources, exp_date2)
|
||||||
objs = self._test_class.get_objects(self.context,
|
with db_api.CONTEXT_WRITER.using(self.context):
|
||||||
id=[res1.id, res2.id])
|
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)
|
self.assertEqual([], objs)
|
||||||
|
|
||||||
def test_reservation_synthetic_field(self):
|
def test_reservation_synthetic_field(self):
|
||||||
|
|
Loading…
Reference in New Issue