From 605e28bbdcbe401f6ae3d307f96577a526a75500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= Date: Wed, 6 Mar 2024 10:00:12 +0100 Subject: [PATCH] src/regression_tracker: collect error code and msg from failed node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo CaƱuelo --- src/regression_tracker.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/regression_tracker.py b/src/regression_tracker.py index e6b49427c..13ba0a4a4 100755 --- a/src/regression_tracker.py +++ b/src/regression_tracker.py @@ -49,6 +49,25 @@ def _collect_logs(self, node): logs = self._collect_logs(parent) return logs + def _collect_errors(self, node): + """Returns a dict containing the 'error_code' and 'error_msg' + data fields of . If doesn't have any info in them, + it searches upwards through parent nodes until it reaches a node + that has them. + """ + if node['data'].get('error_code'): + return { + 'error_code': node['data']['error_code'], + 'error_msg': node['data']['error_msg'] + } + elif node.get('parent'): + parent = self._api.node.get(node['parent']) + return self._collect_errors(parent) + return { + 'error_code': None, + 'error_msg': None + } + def _create_regression(self, failed_node, last_pass_node): """Method to create a regression""" regression = {} @@ -57,6 +76,7 @@ def _create_regression(self, failed_node, last_pass_node): regression['path'] = failed_node['path'] regression['group'] = failed_node['group'] regression['state'] = 'done' + error = self._collect_errors(failed_node) regression['data'] = { 'fail_node': failed_node['id'], 'pass_node': last_pass_node['id'], @@ -66,6 +86,8 @@ def _create_regression(self, failed_node, last_pass_node): 'compiler': failed_node['data'].get('compiler'), 'platform': failed_node['data'].get('platform'), 'failed_kernel_version': failed_node['data'].get('kernel_revision'), # noqa + 'error_code': error['error_code'], + 'error_msg': error['error_msg'], } regression['artifacts'] = self._collect_logs(failed_node) resp = self._api_helper.submit_regression(regression)