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,6 +1920,7 @@ class L7PolicyRepository(BaseRepository):
listener.l7policies.reorder() listener.l7policies.reorder()
session.flush() session.flush()
with session.begin(subtransactions=True):
l7policy.updated_at = None l7policy.updated_at = None
return self.get(session, id=l7policy.id) return self.get(session, id=l7policy.id)

View File

@ -494,6 +494,7 @@ 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)
with self.session.begin():
health_monitor.name = 'test1' health_monitor.name = 'test1'
new_health_monitor = self.session.query( new_health_monitor = self.session.query(
models.HealthMonitor).filter_by( models.HealthMonitor).filter_by(
@ -585,6 +586,7 @@ 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)
with self.session.begin():
vip.ip_address = "10.0.0.1" 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()
@ -718,6 +720,7 @@ 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)
with self.session.begin():
l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL
l7policy.redirect_pool_id = pool.id l7policy.redirect_pool_id = pool.id
new_l7policy = self.session.query( new_l7policy = self.session.query(
@ -758,6 +761,7 @@ 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)
with self.session.begin():
l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL l7policy.action = constants.L7POLICY_ACTION_REDIRECT_TO_POOL
l7policy.redirect_pool_id = self.FAKE_UUID_2 l7policy.redirect_pool_id = self.FAKE_UUID_2
new_l7policy = self.session.query( new_l7policy = self.session.query(