From 2c6e82c644f57f30d788885218e918c490419a6d Mon Sep 17 00:00:00 2001 From: "igor.udot" Date: Thu, 12 Dec 2024 10:19:04 +0800 Subject: [PATCH] ci: added known failure cases fast link to report --- tools/ci/dynamic_pipelines/report.py | 11 +++++++ .../expected_target_test_report.html | 8 +++++ .../test_report_generator.py | 1 + tools/ci/dynamic_pipelines/utils.py | 33 +++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/tools/ci/dynamic_pipelines/report.py b/tools/ci/dynamic_pipelines/report.py index ca41156462..e7d1e29d26 100644 --- a/tools/ci/dynamic_pipelines/report.py +++ b/tools/ci/dynamic_pipelines/report.py @@ -31,6 +31,7 @@ from .utils import format_permalink from .utils import get_artifacts_url from .utils import get_repository_file_url from .utils import is_url +from .utils import known_failure_issue_jira_fast_link from .utils import load_known_failure_cases @@ -542,6 +543,7 @@ class TargetTestReportGenerator(ReportGenerator): 'Failure Reason', f'Failures on your branch (40 latest testcases)', 'Dut Log URL', + 'Create Known Failure Case Jira', 'Job URL', 'Grafana URL', ], @@ -550,6 +552,10 @@ class TargetTestReportGenerator(ReportGenerator): ( 'Failures on your branch (40 latest testcases)', lambda item: f"{getattr(item, 'latest_failed_count', '')} / {getattr(item, 'latest_total_count', '')}", + ), + ( + 'Create Known Failure Case Jira', + known_failure_issue_jira_fast_link ) ], ) @@ -562,6 +568,7 @@ class TargetTestReportGenerator(ReportGenerator): 'Failure Reason', 'Cases that failed in other branches as well (40 latest testcases)', 'Dut Log URL', + 'Create Known Failure Case Jira', 'Job URL', 'Grafana URL', ], @@ -570,6 +577,10 @@ class TargetTestReportGenerator(ReportGenerator): ( 'Cases that failed in other branches as well (40 latest testcases)', lambda item: f"{getattr(item, 'latest_failed_count', '')} / {getattr(item, 'latest_total_count', '')}", + ), + ( + 'Create Known Failure Case Jira', + known_failure_issue_jira_fast_link ) ], ) diff --git a/tools/ci/dynamic_pipelines/tests/test_report_generator/reports_sample_data/expected_target_test_report.html b/tools/ci/dynamic_pipelines/tests/test_report_generator/reports_sample_data/expected_target_test_report.html index dc63e26152..d7568aa43e 100644 --- a/tools/ci/dynamic_pipelines/tests/test_report_generator/reports_sample_data/expected_target_test_report.html +++ b/tools/ci/dynamic_pipelines/tests/test_report_generator/reports_sample_data/expected_target_test_report.html @@ -63,6 +63,7 @@ Failure Reason Cases that failed in other branches as well (40 latest testcases) Dut Log URL + Create Known Failure Case Jira Job URL Grafana URL @@ -74,6 +75,7 @@ failed on setup with "EOFError" 0 / 40 link + Create Not found link @@ -83,6 +85,7 @@ pexpect.exceptions.TIMEOUT: Not found "Press ENTER to see the list of tests" Bytes in current buffer (color code eliminated): ce710,len:0x2afc entry 0x403cc710 Please check the full log here: /builds/espressif/esp-idf/pytest_embedded/2024-05-17_17-50-04/esp32c3.release.test_esp_timer/dut.txt 0 / 40 link + Create Not found link @@ -92,6 +95,7 @@ pexpect.exceptions.TIMEOUT: Not found "Press ENTER to see the list of tests" Bytes in current buffer (color code eliminated): 0 d4 000 00x0000 x0000x00 000000 0 Please check the full log here: /builds/espressif/esp-idf/pytest_embedded/2024-05-17_17-50-04/esp32c3.default.test_wpa_supplicant_ut/dut.txt 0 / 40 link + Create Not found link @@ -101,6 +105,7 @@ failed on setup with "EOFError" 3 / 40 link + Create Not found link @@ -110,6 +115,7 @@ AssertionError: Unity test failed 3 / 40 link + Create Not found link @@ -119,6 +125,7 @@ pexpect.exceptions.TIMEOUT: Not found "re.compile(b'^[-]+\\s*(\\d+) Tests (\\d+) Failures (\\d+) Ignored\\s*(?POK|FAIL)', re.MULTILINE)" Bytes in current buffer (color code eliminated): Serial port /dev/ttyUSB16 Connecting.... Connecting.... esptool.py v4.7.0 Found 1 serial ports Chip is ESP32-C3 (QFN32) (revision v0.3) Features: WiFi, BLE, Embedded Flash 4MB... (total 6673 bytes) Please check the full log here: /builds/espressif/esp-idf/pytest_embedded/2024-05-17_17-50-04/esp32c3.512safe.test_wear_levelling/dut.txt 3 / 40 link + Create Not found link @@ -128,6 +135,7 @@ pexpect.exceptions.TIMEOUT: Not found "re.compile(b'^[-]+\\s*(\\d+) Tests (\\d+) Failures (\\d+) Ignored\\s*(?POK|FAIL)', re.MULTILINE)" Bytes in current buffer (color code eliminated): Serial port /dev/ttyUSB16 Connecting.... Connecting.... esptool.py v4.7.0 Found 1 serial ports Chip is ESP32-C3 (QFN32) (revision v0.3) Features: WiFi, BLE, Embedded Flash 4MB... (total 24528 bytes) Please check the full log here: /builds/espressif/esp-idf/pytest_embedded/2024-05-17_17-50-04/esp32c3.release.test_wear_levelling/dut.txt 3 / 40 link + Create Not found link diff --git a/tools/ci/dynamic_pipelines/tests/test_report_generator/test_report_generator.py b/tools/ci/dynamic_pipelines/tests/test_report_generator/test_report_generator.py index 81bae786ce..5ab856a8ee 100644 --- a/tools/ci/dynamic_pipelines/tests/test_report_generator/test_report_generator.py +++ b/tools/ci/dynamic_pipelines/tests/test_report_generator/test_report_generator.py @@ -32,6 +32,7 @@ class TestReportGeneration(unittest.TestCase): 'CI_DASHBOARD_HOST': 'https://test_dashboard_host', 'CI_PAGES_URL': 'https://artifacts_path', 'CI_JOB_ID': '1', + 'JIRA_SERVER': 'https://jira.com', }) self.MockGitlab = self.gitlab_patcher.start() diff --git a/tools/ci/dynamic_pipelines/utils.py b/tools/ci/dynamic_pipelines/utils.py index aced43c84f..936d9e15fb 100644 --- a/tools/ci/dynamic_pipelines/utils.py +++ b/tools/ci/dynamic_pipelines/utils.py @@ -5,6 +5,8 @@ import os import re import typing as t import xml.etree.ElementTree as ET +from urllib.parse import quote +from urllib.parse import urlencode from urllib.parse import urlparse import requests @@ -216,3 +218,34 @@ def get_repository_file_url(file_path: str) -> str: :return: The modified URL pointing to the file's path in the repository. """ return f'{CI_PROJECT_URL}/-/raw/{CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}/{file_path}' + + +def known_failure_issue_jira_fast_link(_item: TestCase) -> str: + """ + Generate a JIRA fast link for known issues with relevant test case details. + """ + jira_url = os.getenv('JIRA_SERVER') + jira_pid = os.getenv('JIRA_KNOWN_FAILURE_PID', '10514') + jira_issuetype = os.getenv('JIRA_KNOWN_FAILURE_ISSUETYPE', '10004') + jira_component = os.getenv('JIRA_KNOWN_FAILURE_COMPONENT', '11909') + jira_assignee = os.getenv('JIRA_KNOWN_FAILURE_ASSIGNEE', 'zhangjianwen') + jira_affected_versions = os.getenv('JIRA_KNOWN_FAILURE_VERSIONS', '17602') + jira_priority = os.getenv('JIRA_KNOWN_FAILURE_PRIORITY', '3') + + base_url = f'{jira_url}/secure/CreateIssueDetails!init.jspa?' + params = { + 'pid': jira_pid, + 'issuetype': jira_issuetype, + 'summary': f'[Test Case]{_item.name}', + 'description': ( + f"job_url: {quote(_item.ci_job_url, safe=':/')}\n\n" + f"dut_log_url: {quote(_item.dut_log_url, safe=':/')}\n\n" + f'ci_dashboard_url: {_item.ci_dashboard_url}\n\n' + ), + 'components': jira_component, + 'priority': jira_priority, + 'assignee': jira_assignee, + 'versions': jira_affected_versions + } + query_string = urlencode(params) + return f'Create'