Merge "Add step info and timestamp to get actions command"

This commit is contained in:
Zuul 2018-07-09 20:10:19 +00:00 committed by Gerrit Code Review
commit a4474f7bc2
3 changed files with 29 additions and 4 deletions

View File

@ -122,20 +122,43 @@ def gen_action_table(action_list):
'action_lifecycle'
"""
actions = format_utils.table_factory(
field_names=['Name', 'Action', 'Lifecycle'])
field_names=['Name', 'Action', 'Lifecycle', 'Execution Time',
'Step Succ/Fail/Oth'])
if action_list:
# sort by id, which is ULID - chronological.
for action in sorted(action_list, key=lambda k: k['id']):
actions.add_row([
action.get('name'), 'action/{}'.format(action.get('id')),
action.get('action_lifecycle')
action.get('name'),
'action/{}'.format(action.get('id')),
action.get('action_lifecycle'),
action.get('dag_execution_date'),
_step_summary(action.get('steps', []))
])
else:
actions.add_row(['None', '', ''])
actions.add_row(['None', '', '', '', ''])
return format_utils.table_get_string(actions)
def _step_summary(step_list):
"""Creates a single string representation of the step status
Success/Failed/Other counts in each position
"""
successes = 0
failures = 0
other = 0
for s in step_list:
state = s.get('state')
if state in ['success']:
successes += 1
elif state in ['failed']:
failures += 1
else:
other += 1
return "{}/{}/{}".format(successes, failures, other)
def gen_collection_table(collection_list):
"""Generates a list of collections and their status

View File

@ -55,6 +55,7 @@ def test_create_action(*args):
assert 'Lifecycle' in response
assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' in response
assert 'Error:' not in response
assert '0/0/0' in response
@responses.activate

View File

@ -77,6 +77,7 @@ def test_get_actions(*args):
assert 'deploy_site' in response
assert 'action/01BTP9T2WCE1PAJR2DWYXG805V' in response
assert 'Lifecycle' in response
assert '2/1/0' in response
@responses.activate