added support statistics only for report execution API
-added statistics-only option for `execution-get-report` command, which will only return statistics of an execution. -modified "print_statistics": *in case of statistics-only,there is no need to print execution tree. *print a new field "estimated time". Implements: blueprint mistral-executions-report-return-statistics-only Depends-on: I7038d6d2a48f9f0455545f6be8dce33a48b25e1c Change-Id: I77f9120ea1f1d4469772f67be334921fe4f7862f Signed-off-by: ali <ali.abdelal@nokia.com>
This commit is contained in:
mistralclient
@ -124,7 +124,8 @@ class ExecutionManager(base.ResourceManager):
|
||||
|
||||
self._delete('/executions/%s%s' % (id, query_string))
|
||||
|
||||
def get_report(self, id, errors_only=True, max_depth=None):
|
||||
def get_report(self, id, errors_only=True, max_depth=None,
|
||||
statistics_only=False):
|
||||
self._ensure_not_empty(id=id)
|
||||
|
||||
query_params = {}
|
||||
@ -132,6 +133,9 @@ class ExecutionManager(base.ResourceManager):
|
||||
if errors_only:
|
||||
query_params['errors_only'] = True
|
||||
|
||||
if statistics_only:
|
||||
query_params['statistics_only'] = True
|
||||
|
||||
if max_depth is not None:
|
||||
query_params['max_depth'] = max_depth
|
||||
|
||||
|
@ -361,6 +361,12 @@ class GetReport(command.Command):
|
||||
action='store_true',
|
||||
help='Only error paths will be included.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--statistics-only',
|
||||
dest='statistics_only',
|
||||
action='store_true',
|
||||
help='Only the statistics will be included.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-errors-only',
|
||||
dest='errors_only',
|
||||
@ -459,6 +465,12 @@ class GetReport(command.Command):
|
||||
stat['paused_tasks_count']
|
||||
)
|
||||
|
||||
if 'estimated_time' in stat:
|
||||
self.print_line(
|
||||
'Estimated time (seconds) for the execution to finish:'' %s\n'
|
||||
% stat['estimated_time']
|
||||
)
|
||||
|
||||
def print_report(self, report_json):
|
||||
self.print_line(
|
||||
"\nTo get more details on a task failure "
|
||||
@ -473,14 +485,15 @@ class GetReport(command.Command):
|
||||
)
|
||||
self.print_statistics(report_json['statistics'])
|
||||
|
||||
self.print_line(
|
||||
'%s Workflow Execution Tree %s\n' %
|
||||
(frame_line, frame_line)
|
||||
)
|
||||
self.print_workflow_execution_entry(
|
||||
report_json['root_workflow_execution'],
|
||||
0
|
||||
)
|
||||
if 'root_workflow_execution' in report_json:
|
||||
self.print_line(
|
||||
'%s Workflow Execution Tree %s\n' %
|
||||
(frame_line, frame_line)
|
||||
)
|
||||
self.print_workflow_execution_entry(
|
||||
report_json['root_workflow_execution'],
|
||||
0
|
||||
)
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
mistral_client = self.app.client_manager.workflow_engine
|
||||
@ -488,7 +501,8 @@ class GetReport(command.Command):
|
||||
report_json = mistral_client.executions.get_report(
|
||||
parsed_args.id,
|
||||
errors_only=parsed_args.errors_only,
|
||||
max_depth=parsed_args.max_depth
|
||||
max_depth=parsed_args.max_depth,
|
||||
statistics_only=parsed_args.statistics_only,
|
||||
)
|
||||
|
||||
self.print_report(report_json)
|
||||
|
@ -272,7 +272,7 @@ class WorkflowCLITests(base_v2.MistralClientTestBase):
|
||||
for wf_name in wf_names:
|
||||
self.mistral_admin(
|
||||
'workflow-delete',
|
||||
params=wf_name+' --namespace abcdef'
|
||||
params=wf_name + ' --namespace abcdef'
|
||||
)
|
||||
|
||||
wfs = self.mistral_admin('workflow-list')
|
||||
|
@ -279,6 +279,20 @@ class TestExecutionsV2(base.BaseClientV2Test):
|
||||
|
||||
self.executions.delete(EXEC['id'])
|
||||
|
||||
def test_report_statistics_only(self):
|
||||
url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id'] \
|
||||
+ '/report?statistics_only=True'
|
||||
|
||||
expected_json = {
|
||||
'statistics': {}
|
||||
}
|
||||
|
||||
self.requests_mock.get(url, json=expected_json)
|
||||
|
||||
report = self.executions.get_report(EXEC['id'], statistics_only=True)
|
||||
|
||||
self.assertDictEqual(expected_json, report)
|
||||
|
||||
def test_report(self):
|
||||
url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id'] + '/report'
|
||||
|
||||
|
Reference in New Issue
Block a user