Browse Source

Merge "wait_for_server_status(): report original request ID if failure"

changes/11/825111/1
Zuul 4 months ago committed by Gerrit Code Review
parent
commit
e414221c32
  1. 4
      tempest/common/compute.py
  2. 14
      tempest/common/waiters.py

4
tempest/common/compute.py

@ -197,6 +197,7 @@ def create_test_server(clients, validatable=False, validation_resources=None,
body = clients.servers_client.create_server(name=name, imageRef=image_id,
flavorRef=flavor,
**kwargs)
request_id = body.response['x-openstack-request-id']
# handle the case of multiple servers
if multiple_create_request:
@ -234,7 +235,8 @@ def create_test_server(clients, validatable=False, validation_resources=None,
for server in servers:
try:
waiters.wait_for_server_status(
clients.servers_client, server['id'], wait_until)
clients.servers_client, server['id'], wait_until,
request_id=request_id)
# Multiple validatable servers are not supported for now. Their
# creation will fail with the condition above.

14
tempest/common/waiters.py

@ -32,7 +32,8 @@ def _get_task_state(body):
# NOTE(afazekas): This function needs to know a token and a subject.
def wait_for_server_status(client, server_id, status, ready_wait=True,
extra_timeout=0, raise_on_error=True):
extra_timeout=0, raise_on_error=True,
request_id=None):
"""Waits for a server to reach a given status."""
# NOTE(afazekas): UNKNOWN status possible on ERROR
@ -71,11 +72,12 @@ def wait_for_server_status(client, server_id, status, ready_wait=True,
'/'.join((server_status, str(task_state))),
time.time() - start_time)
if (server_status == 'ERROR') and raise_on_error:
details = ''
if 'fault' in body:
raise exceptions.BuildErrorException(body['fault'],
server_id=server_id)
else:
raise exceptions.BuildErrorException(server_id=server_id)
details += 'Fault: %s.' % body['fault']
if request_id:
details += ' Server boot request ID: %s.' % request_id
raise exceptions.BuildErrorException(details, server_id=server_id)
timed_out = int(time.time()) - start_time >= timeout
@ -88,6 +90,8 @@ def wait_for_server_status(client, server_id, status, ready_wait=True,
'status': status,
'expected_task_state': expected_task_state,
'timeout': timeout})
if request_id:
message += ' Server boot request ID: %s.' % request_id
message += ' Current status: %s.' % server_status
message += ' Current task state: %s.' % task_state
caller = test_utils.find_test_caller()

Loading…
Cancel
Save