From 4bf24fea2cd8f6529487132843f4f88bcded84b5 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 28 Jul 2021 11:22:41 -0400 Subject: [PATCH] Attempt to debug some issues with allure reporting of workflows. --- planemo/engine/galaxy.py | 3 ++- planemo/reports/allure.py | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/planemo/engine/galaxy.py b/planemo/engine/galaxy.py index 118f42dae..8e52a552e 100644 --- a/planemo/engine/galaxy.py +++ b/planemo/engine/galaxy.py @@ -49,7 +49,8 @@ def _run_test_case(self, test_case): # Simple file-based job path. return super(GalaxyEngine, self)._run_test_case(test_case) else: - with self.ensure_runnables_served([test_case.runnable]) as config: + runnable = test_case.runnable + with self.ensure_runnables_served([runnable]) as config: galaxy_interactor_kwds = { "galaxy_url": config.galaxy_url, "master_api_key": config.master_api_key, diff --git a/planemo/reports/allure.py b/planemo/reports/allure.py index 8abf581dd..68101d105 100644 --- a/planemo/reports/allure.py +++ b/planemo/reports/allure.py @@ -1,4 +1,5 @@ import json +import os import re import uuid @@ -26,6 +27,9 @@ JSON_INDENT = 2 WORKFLOW_INDEX_MATCH = re.compile(r"(.*)\_([\d+])") +ALLURE_RECORD_DEBUG_DATA = os.environ.get("ALLURE_RECORD_DEBUG_DATA", "0") == "1" +ALLURE_RANDOM_HISTORY_ID = os.environ.get("ALLURE_RANDOM_HISTORY_ID", "1") == "1" + class AllureListener(object): def __init__(self, lifecycle): @@ -61,11 +65,14 @@ def process_test_case(self, test_case, file_modication_datetime=None): test_result.fullName = test_index test_result.testCaseId = md5(test_index) - # Maybe an option to swap this - seems like it is causing all runs to seem like - # retries instead of history proper? - # test_result.historyId = md5(test_index) - test_result.historyId = md5(str(uuid.uuid4())) + # TODO: figure out what this ought to be for workflows and tools - might be different I suppose. + if ALLURE_RANDOM_HISTORY_ID: + test_result.historyId = md5(str(uuid.uuid4())) + else: + test_result.historyId = md5(test_index) tool_id = self._record_suite_labels(test_result, test_index, test_data, job) + if ALLURE_RECORD_DEBUG_DATA: + self._attach_data("test_case", json.dumps(test_case, indent=JSON_INDENT), attachment_type=AttachmentType.JSON) self._attach_data("test_data", json.dumps(test_data, indent=JSON_INDENT), attachment_type=AttachmentType.JSON) for key in ["stderr", "stdout", "command_line", "external_id", "job_messages"]: @@ -157,10 +164,16 @@ def _record_suite_labels(self, test_result, test_index, test_data, job): elif "tool_version" in job: test_result.labels.append(Label(name=LabelType.SUITE, value=job["tool_version"])) + def subsuite_name(index: str): + if index.isdigit(): + return f"Test Case #{int(index) + 1}" + else: + return index + if "test_index" in test_data: - test_result.labels.append(Label(name=LabelType.SUB_SUITE, value=str(test_data["test_index"]))) + test_result.labels.append(Label(name=LabelType.SUB_SUITE, value=subsuite_name(str(test_data["test_index"])))) elif index_match: - test_result.labels.append(Label(name=LabelType.SUB_SUITE, value=index_match.group(2))) + test_result.labels.append(Label(name=LabelType.SUB_SUITE, value=subsuite_name(index_match.group(2)))) return tool_id