Add more verbose info for wait_for_..._status methods
If this method failed because the resource will not reach desired status, you just know expected status, not actual status at time of timeout. It can help with debugging. Change-Id: I583f0739bf771dd587acd13c1453ae6a440a9e87
This commit is contained in:
parent
1beedac2ba
commit
1102c3a8df
@ -111,22 +111,24 @@ def wait_for_image_status(client, image_id, status):
|
||||
while image['status'] != status:
|
||||
time.sleep(client.build_interval)
|
||||
resp, image = client.get_image(image_id)
|
||||
if image['status'] == 'ERROR':
|
||||
status_curr = image['status']
|
||||
if status_curr == 'ERROR':
|
||||
raise exceptions.AddImageException(image_id=image_id)
|
||||
|
||||
# check the status again to avoid a false negative where we hit
|
||||
# the timeout at the same time that the image reached the expected
|
||||
# status
|
||||
if image['status'] == status:
|
||||
if status_curr == status:
|
||||
return
|
||||
|
||||
if int(time.time()) - start >= client.build_timeout:
|
||||
message = ('Image %(image_id)s failed to reach %(status)s '
|
||||
'status within the required time (%(timeout)s s).' %
|
||||
message = ('Image %(image_id)s failed to reach %(status)s state'
|
||||
'(current state %(status_curr)s) '
|
||||
'within the required time (%(timeout)s s).' %
|
||||
{'image_id': image_id,
|
||||
'status': status,
|
||||
'status_curr': status_curr,
|
||||
'timeout': client.build_timeout})
|
||||
message += ' Current status: %s.' % image['status']
|
||||
caller = misc_utils.find_test_caller()
|
||||
if caller:
|
||||
message = '(%s) %s' % (caller, message)
|
||||
@ -144,7 +146,8 @@ def wait_for_bm_node_status(client, node_id, attr, status):
|
||||
while node[attr] != status:
|
||||
time.sleep(client.build_interval)
|
||||
_, node = client.show_node(node_id)
|
||||
if node[attr] == status:
|
||||
status_curr = node[attr]
|
||||
if status_curr == status:
|
||||
return
|
||||
|
||||
if int(time.time()) - start >= client.build_timeout:
|
||||
@ -154,7 +157,7 @@ def wait_for_bm_node_status(client, node_id, attr, status):
|
||||
'attr': attr,
|
||||
'status': status,
|
||||
'timeout': client.build_timeout})
|
||||
message += ' Current state of %s: %s.' % (attr, node[attr])
|
||||
message += ' Current state of %s: %s.' % (attr, status_curr)
|
||||
caller = misc_utils.find_test_caller()
|
||||
if caller:
|
||||
message = '(%s) %s' % (caller, message)
|
||||
|
@ -79,9 +79,10 @@ class InterfacesClientJSON(rest_client.RestClient):
|
||||
timed_out = int(time.time()) - start >= self.build_timeout
|
||||
|
||||
if interface_status != status and timed_out:
|
||||
message = ('Interface %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(port_id, status, self.build_timeout))
|
||||
message = ('Interface %s failed to reach %s status '
|
||||
'(current %s) within the required time (%s s).' %
|
||||
(port_id, status, interface_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
return resp, body
|
||||
|
@ -103,9 +103,10 @@ class VolumesExtensionsClientJSON(rest_client.RestClient):
|
||||
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
|
||||
|
||||
if int(time.time()) - start >= self.build_timeout:
|
||||
message = ('Volume %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(volume_id, status, self.build_timeout))
|
||||
message = ('Volume %s failed to reach %s status (current %s) '
|
||||
'within the required time (%s s).' %
|
||||
(volume_id, status, volume_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
def is_resource_deleted(self, id):
|
||||
|
@ -80,9 +80,10 @@ class InterfacesV3ClientJSON(rest_client.RestClient):
|
||||
timed_out = int(time.time()) - start >= self.build_timeout
|
||||
|
||||
if interface_status != status and timed_out:
|
||||
message = ('Interface %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(port_id, status, self.build_timeout))
|
||||
message = ('Interface %s failed to reach %s status '
|
||||
'(current %s) within the required time (%s s).' %
|
||||
(port_id, status, interface_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
return resp, body
|
||||
|
@ -259,6 +259,7 @@ class NetworkClientBase(object):
|
||||
# At this point, the wait has timed out
|
||||
message = 'Resource %s' % (str(resource))
|
||||
message += ' failed to reach status %s' % status
|
||||
message += ' (current: %s)' % resource['status']
|
||||
message += ' within the required time %s' % timeout
|
||||
caller = misc.find_test_caller()
|
||||
if caller:
|
||||
|
@ -185,9 +185,12 @@ class OrchestrationClient(rest_client.RestClient):
|
||||
resource_status_reason=body['resource_status_reason'])
|
||||
|
||||
if int(time.time()) - start >= self.build_timeout:
|
||||
message = ('Resource %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(resource_name, status, self.build_timeout))
|
||||
message = ('Resource %s failed to reach %s status '
|
||||
'(current %s) within the required time (%s s).' %
|
||||
(resource_name,
|
||||
status,
|
||||
resource_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
time.sleep(self.build_interval)
|
||||
|
||||
@ -214,9 +217,10 @@ class OrchestrationClient(rest_client.RestClient):
|
||||
stack_status_reason=body['stack_status_reason'])
|
||||
|
||||
if int(time.time()) - start >= self.build_timeout:
|
||||
message = ('Stack %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(stack_name, status, self.build_timeout))
|
||||
message = ('Stack %s failed to reach %s status (current: %s) '
|
||||
'within the required time (%s s).' %
|
||||
(stack_name, status, stack_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
time.sleep(self.build_interval)
|
||||
|
||||
|
@ -95,9 +95,10 @@ class BaseBackupsClientJSON(rest_client.RestClient):
|
||||
raise exceptions.VolumeBackupException(backup_id=backup_id)
|
||||
|
||||
if int(time.time()) - start >= self.build_timeout:
|
||||
message = ('Volume backup %s failed to reach %s status within '
|
||||
'the required time (%s s).' %
|
||||
(backup_id, status, self.build_timeout))
|
||||
message = ('Volume backup %s failed to reach %s status '
|
||||
'(current %s) within the required time (%s s).' %
|
||||
(backup_id, status, backup_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
|
||||
|
@ -174,10 +174,12 @@ class BaseVolumesClientJSON(rest_client.RestClient):
|
||||
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
|
||||
|
||||
if int(time.time()) - start >= self.build_timeout:
|
||||
message = 'Volume %s failed to reach %s status within '\
|
||||
'the required time (%s s).' % (volume_id,
|
||||
status,
|
||||
self.build_timeout)
|
||||
message = ('Volume %s failed to reach %s status (current: %s) '
|
||||
'within the required time '
|
||||
'(%s s).' % (volume_id,
|
||||
status,
|
||||
volume_status,
|
||||
self.build_timeout))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
def is_resource_deleted(self, id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user