Make the wait_for_server_status timeout message a bit more clear
The current error message when wait_for_server_status times out only
includes the vm_state but the method, by default, is really waiting for
a state combination of vm_state/task_state.
Sometimes the vm_state is the desired status but the task_state is not,
for example:
"Server 613b9fd8-9f3f-41a6-86cc-a36301aa7fc8 failed to reach ACTIVE
status within the required time (196 s). Current status: ACTIVE."
This patch adds the current task_state to the error message for clarity
when the timeout occurs.
Related-Bug: #1257561
Change-Id: Icfce12035bf4938eac3a13a7b640db4398ef832f
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 497a297..44198f0 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -75,10 +75,16 @@
timed_out = int(time.time()) - start_time >= timeout
if timed_out:
- message = ('Server %s failed to reach %s status within the '
- 'required time (%s s).' %
- (server_id, status, timeout))
+ expected_task_state = 'None' if ready_wait else 'n/a'
+ message = ('Server %(server_id)s failed to reach %(status)s '
+ 'status and task state "%(expected_task_state)s" '
+ 'within the required time (%(timeout)s s).' %
+ {'server_id': server_id,
+ 'status': status,
+ 'expected_task_state': expected_task_state,
+ 'timeout': timeout})
message += ' Current status: %s.' % server_status
+ message += ' Current task state: %s.' % task_state
raise exceptions.TimeoutException(message)
old_status = server_status
old_task_state = task_state