Fix timing bug that causes false negative tests

All drivers call (or at least should) the helper method
successful_completion method when they're driver action has
completed succesfully.  Some tempest tests exposed an issue where
the load balancer statuses would get updated before children were,
causing an inconsistent behavior.  The load balancer should always
have its status updated last.

Change-Id: I4e422b7feaec5110ee856994631785e6e55a467e
Closes-Bug: 1534886
This commit is contained in:
Brandon Logan 2016-01-16 14:21:19 -06:00
parent b5d4e5c0fe
commit 7f3af5e414
1 changed files with 17 additions and 8 deletions

View File

@ -98,14 +98,15 @@ class BaseManagerMixin(object):
self.driver.plugin.db.update_loadbalancer( self.driver.plugin.db.update_loadbalancer(
context, obj.id, {'vip_address': obj.vip_address, context, obj.id, {'vip_address': obj.vip_address,
'vip_port_id': obj.vip_port_id}) 'vip_port_id': obj.vip_port_id})
self.driver.plugin.db.update_status( if delete:
context, models.LoadBalancer, obj.root_loadbalancer.id, # We cannot update the status of obj if it was deleted but if the
provisioning_status=lb_p_status, # obj is not a load balancer, the root load balancer should be
operating_status=lb_op_status) # updated
if obj == obj.root_loadbalancer or delete: if not isinstance(obj, data_models.LoadBalancer):
# Do not want to update the status of the load balancer again self.driver.plugin.db.update_status(
# Or the obj was deleted from the db so no need to update the context, models.LoadBalancer, obj.root_loadbalancer.id,
# statuses provisioning_status=lb_p_status,
operating_status=lb_op_status)
return return
obj_op_status = lb_const.ONLINE obj_op_status = lb_const.ONLINE
if isinstance(obj, data_models.HealthMonitor): if isinstance(obj, data_models.HealthMonitor):
@ -118,6 +119,14 @@ class BaseManagerMixin(object):
context, obj_sa_cls, obj.id, context, obj_sa_cls, obj.id,
provisioning_status=constants.ACTIVE, provisioning_status=constants.ACTIVE,
operating_status=obj_op_status) operating_status=obj_op_status)
if not isinstance(obj, data_models.LoadBalancer):
# Only update the status of the root_loadbalancer if the previous
# update was not the root load balancer so we are not updating
# it twice.
self.driver.plugin.db.update_status(
context, models.LoadBalancer, obj.root_loadbalancer.id,
provisioning_status=lb_p_status,
operating_status=lb_op_status)
def failed_completion(self, context, obj): def failed_completion(self, context, obj):
""" """