Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Attempt to debug some issues with allure reporting of workflows. #1183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion planemo/engine/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 19 additions & 6 deletions planemo/reports/allure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import re
import uuid

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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

Expand Down