e2e: GH report: rerun tests link update

This commit is contained in:
Yevheniia Berdnyk 2024-04-17 03:46:59 +03:00
parent db501b5efd
commit a8395e51a4
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
7 changed files with 33 additions and 14 deletions

View File

@ -51,7 +51,8 @@ class BaseTestReport:
'name': test.name,
'geth_paths': geth_paths,
'testruns': list(),
'group_name': test.group_name
'group_name': test.group_name,
'secured': test.secured
}
for testrun in test.testruns:
test_dict['testruns'].append(testrun.__dict__)
@ -75,7 +76,8 @@ class BaseTestReport:
geth_paths=test_data['geth_paths'],
testruns=testruns,
testrail_case_id=test_data['testrail_case_id'],
grop_name=test_data['group_name']))
grop_name=test_data['group_name'],
secured=test_data['secured']))
return tests
def get_tests_by_status(self):
@ -106,7 +108,7 @@ class BaseTestReport:
@staticmethod
def get_jenkins_link_to_rerun_e2e(branch_name="develop", pr_id="", tr_case_ids=""):
return 'https://ci.status.im/job/status-mobile/job/e2e/job/status-app-prs-rerun/parambuild/' \
'?BRANCH_NAME=%s&PR_ID=%s&TR_CASE_IDS=%s' % (branch_name, pr_id, tr_case_ids)
'?BRANCH_NAME=%s&PR_ID=%s&APK_URL=%s.apk&TR_CASE_IDS=%s' % (branch_name, pr_id, pr_id, tr_case_ids)
def get_sauce_final_screenshot_url(self, job_id):
return 'https://media.giphy.com/media/9M5jK4GXmD5o1irGrF/giphy.gif'

View File

@ -76,13 +76,19 @@ class GithubHtmlReport(BaseTestReport):
from tests import pytest_config_global
pr_id = pytest_config_global['pr_number']
from github import Github
from conftest import github_token
branch_name = Github(github_token).get_user('status-im').get_repo('status-mobile').get_pull(int(pr_id)).head.ref
if not_executed_tests:
html += "<li><a href=\"%s\">Rerun not executed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e(
branch_name=branch_name,
pr_id=pr_id,
tr_case_ids=','.join([str(i) for i in tests]))
if failed_tests:
html += "<li><a href=\"%s\">Rerun failed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e(
branch_name=branch_name,
pr_id=pr_id,
tr_case_ids=','.join([str(test.testrail_case_id) for test in tests]))
@ -141,7 +147,7 @@ class GithubHtmlReport(BaseTestReport):
else:
html += "\n\n```\n%s\n```\n\n" % error.replace("[[", "<b>[[").replace("]]", "]]</b>")
html += "<br/><br/>"
if last_testrun.jobs:
if last_testrun.jobs and not test.secured:
html += self.build_device_sessions_html(last_testrun)
html += "</td></tr>"
return html
@ -158,8 +164,8 @@ class GithubHtmlReport(BaseTestReport):
self.get_sauce_job_url(job_id, test_run.first_commands[job_id])
else:
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % self.get_sauce_job_url(job_id)
if test_run.error:
html += "<li><a href=\"%s\">Failure screenshot</a></li>" % self.get_sauce_final_screenshot_url(job_id)
# if test_run.error:
# html += "<li><a href=\"%s\">Failure screenshot</a></li>" % self.get_sauce_final_screenshot_url(job_id)
html += "</ul></p>"
html += "</ul></p>"
return html

View File

@ -2,12 +2,13 @@ from typing import Dict
class SingleTestData(object):
def __init__(self, name, testruns, testrail_case_id, geth_paths, grop_name):
def __init__(self, name, testruns, testrail_case_id, geth_paths, grop_name, secured):
self.testrail_case_id = testrail_case_id
self.name = name
self.testruns = testruns
self.geth_paths = geth_paths
self.group_name = grop_name
self.secured = secured
class TestRunData(object):
def __init__(self, steps, jobs, error, first_commands: Dict[str, int], xfail):
@ -27,11 +28,11 @@ class TestSuiteData(object):
self.current_test = None
self.tests = list()
def set_current_test(self, test_name, testrail_case_id):
def set_current_test(self, test_name, testrail_case_id, secured):
existing_test = next((test for test in self.tests if test.name == test_name), None)
if existing_test:
self.current_test = existing_test
else:
test = SingleTestData(test_name, list(), testrail_case_id, list(), None)
test = SingleTestData(test_name, list(), testrail_case_id, list(), None, secured)
self.tests.append(test)
self.current_test = test

View File

@ -187,10 +187,14 @@ class TestrailReport(BaseTestReport):
test_steps += step + "\n"
for i, device in enumerate(last_testrun.jobs):
if last_testrun.first_commands:
devices += "# [Device %d](%s) \n" % (
i + 1, self.get_sauce_job_url(job_id=device, first_command=last_testrun.first_commands[device]))
first_command = last_testrun.first_commands[device]
else:
devices += "# [Device %d](%s) \n" % (i + 1, self.get_sauce_job_url(job_id=device))
first_command = 0
try:
devices += "# [Device %d](%s) \n" % (i + 1, self.get_sauce_job_url(job_id=device,
first_command=first_command))
except KeyError:
devices += "# Device %s: SauceLabs session was not found \n" % (i + 1)
comment = str()
if test.group_name:
comment += "# Class: %s \n" % test.group_name

View File

@ -338,6 +338,8 @@ def pytest_runtest_makereport(item, call):
error = error.replace(re.findall(failure_pattern, report.longreprtext)[0], '')
return error
secured_test = "secured" in item.keywords._markers or "secured" in item.parent.keywords._markers
if report.when == 'setup':
is_group = "xdist_group" in item.keywords._markers or "xdist_group" in item.parent.keywords._markers
error_intro, error = 'Test setup failed:', ''
@ -345,7 +347,8 @@ def pytest_runtest_makereport(item, call):
if (hasattr(report, 'wasxfail') and not case_ids_set) or (hasattr(report, 'wasxfail') and (
str([mark.args[0] for mark in item.iter_markers(name='testrail_id')][0]) in str(case_ids_set))):
if '[NOTRUN]' in report.wasxfail:
test_suite_data.set_current_test(item.name, testrail_case_id=get_testrail_case_id(item))
test_suite_data.set_current_test(test_name=item.name, testrail_case_id=get_testrail_case_id(item),
secured=secured_test)
test_suite_data.current_test.create_new_testrun()
if is_group:
test_suite_data.current_test.group_name = item.instance.__class__.__name__
@ -429,7 +432,8 @@ def pytest_runtest_setup(item):
if run_testrail_ids:
if str(testrail_id) not in list(run_testrail_ids.split(",")):
pytest.skip("test requires testrail case id %s" % testrail_id)
test_suite_data.set_current_test(item.name, testrail_case_id=get_testrail_case_id(item))
secured = bool([mark for mark in item.iter_markers(name='secured')])
test_suite_data.set_current_test(test_name=item.name, testrail_case_id=get_testrail_case_id(item), secured=secured)
test_suite_data.current_test.create_new_testrun()

View File

@ -13,6 +13,7 @@ from views.sign_in_view import SignInView
@pytest.mark.xdist_group(name="new_four_2")
@marks.new_ui_critical
@marks.secured
class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
def prepare_devices(self):

View File

@ -12,3 +12,4 @@ flaky = pytest.mark.flaky
upgrade = pytest.mark.upgrade
skip = pytest.mark.skip
xfail = pytest.mark.xfail
secured = pytest.mark.secured