Merge "Fix new errors with SQLAlchemy 1.4"

This commit is contained in:
Zuul 2021-06-21 08:36:40 +00:00 committed by Gerrit Code Review
commit 1d77e93f28
2 changed files with 13 additions and 8 deletions

View File

@ -807,7 +807,7 @@ class Repositories(object):
:returns: An amphora stats dictionary :returns: An amphora stats dictionary
""" """
with session.begin(subtransactions=True): with session.begin(subtransactions=True):
columns = (models.ListenerStatistics.__table__.columns + columns = (list(models.ListenerStatistics.__table__.columns) +
[models.Amphora.load_balancer_id]) [models.Amphora.load_balancer_id])
amp_records = ( amp_records = (
session.query(*columns) session.query(*columns)
@ -1920,7 +1920,8 @@ class L7PolicyRepository(BaseRepository):
listener.l7policies.reorder() listener.l7policies.reorder()
session.flush() session.flush()
l7policy.updated_at = None with session.begin(subtransactions=True):
l7policy.updated_at = None
return self.get(session, id=l7policy.id) return self.get(session, id=l7policy.id)
def delete(self, session, id, **filters): def delete(self, session, id, **filters):

View File

@ -494,7 +494,8 @@ class HealthMonitorModelTest(base.OctaviaDBTestBase, ModelTestMixin):
def test_update(self): def test_update(self):
health_monitor = self.create_health_monitor(self.session, self.pool.id) health_monitor = self.create_health_monitor(self.session, self.pool.id)
health_monitor.name = 'test1' with self.session.begin():
health_monitor.name = 'test1'
new_health_monitor = self.session.query( new_health_monitor = self.session.query(
models.HealthMonitor).filter_by( models.HealthMonitor).filter_by(
pool_id=health_monitor.pool_id).first() pool_id=health_monitor.pool_id).first()
@ -585,7 +586,8 @@ class VipModelTest(base.OctaviaDBTestBase, ModelTestMixin):
def test_update(self): def test_update(self):
vip = self.create_vip(self.session, self.load_balancer.id) vip = self.create_vip(self.session, self.load_balancer.id)
vip.ip_address = "10.0.0.1" with self.session.begin():
vip.ip_address = "10.0.0.1"
new_vip = self.session.query(models.Vip).filter_by( new_vip = self.session.query(models.Vip).filter_by(
load_balancer_id=self.load_balancer.id).first() load_balancer_id=self.load_balancer.id).first()
self.assertEqual("10.0.0.1", new_vip.ip_address) self.assertEqual("10.0.0.1", new_vip.ip_address)
@ -718,8 +720,9 @@ class L7PolicyModelTest(base.OctaviaDBTestBase, ModelTestMixin):
def test_update(self): def test_update(self):
l7policy = self.create_l7policy(self.session, self.listener.id) l7policy = self.create_l7policy(self.session, self.listener.id)
pool = self.create_pool(self.session) pool = self.create_pool(self.session)
l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL with self.session.begin():
l7policy.redirect_pool_id = pool.id l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL
l7policy.redirect_pool_id = pool.id
new_l7policy = self.session.query( new_l7policy = self.session.query(
models.L7Policy).filter_by(id=l7policy.id).first() models.L7Policy).filter_by(id=l7policy.id).first()
self.assertEqual(pool.id, new_l7policy.redirect_pool_id) self.assertEqual(pool.id, new_l7policy.redirect_pool_id)
@ -758,8 +761,9 @@ class L7PolicyModelTest(base.OctaviaDBTestBase, ModelTestMixin):
def test_pool_relationship(self): def test_pool_relationship(self):
l7policy = self.create_l7policy(self.session, self.listener.id) l7policy = self.create_l7policy(self.session, self.listener.id)
self.create_pool(self.session, id=self.FAKE_UUID_2) self.create_pool(self.session, id=self.FAKE_UUID_2)
l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL with self.session.begin():
l7policy.redirect_pool_id = self.FAKE_UUID_2 l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL
l7policy.redirect_pool_id = self.FAKE_UUID_2
new_l7policy = self.session.query( new_l7policy = self.session.query(
models.L7Policy).filter_by(id=l7policy.id).first() models.L7Policy).filter_by(id=l7policy.id).first()
self.assertIsNotNone(new_l7policy.redirect_pool) self.assertIsNotNone(new_l7policy.redirect_pool)