Skip to content

Commit

Permalink
e2e: GH report: rerun tests link update
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk committed Apr 18, 2024
1 parent db501b5 commit a8395e5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
8 changes: 5 additions & 3 deletions test/appium/support/base_test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def save_test(self, test, geth: dict = None):
'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__)
Expand All @@ -75,7 +76,8 @@ def get_all_tests(self):
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):
Expand Down Expand Up @@ -106,7 +108,7 @@ def get_sauce_job_url(self, job_id, first_command=0):
@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'
Expand Down
12 changes: 9 additions & 3 deletions test/appium/support/github_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ def build_tests_table_html(self, tests, run_id, failed_tests=False, xfailed_test
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]))

Expand Down Expand Up @@ -141,7 +147,7 @@ def build_test_row_html(self, index, test, run_id):
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
Expand All @@ -158,8 +164,8 @@ def build_device_sessions_html(self, test_run):
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
7 changes: 4 additions & 3 deletions test/appium/support/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@


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):
Expand All @@ -27,11 +28,11 @@ def __init__(self):
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
10 changes: 7 additions & 3 deletions test/appium/support/testrail_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,14 @@ def add_results(self):
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
Expand Down
8 changes: 6 additions & 2 deletions test/appium/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,17 @@ def catch_error():
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:', ''
final_error = '%s %s' % (error_intro, error)
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__
Expand Down Expand Up @@ -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()


Expand Down
1 change: 1 addition & 0 deletions test/appium/tests/critical/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@pytest.mark.xdist_group(name="new_four_2")
@marks.new_ui_critical
@marks.secured
class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):

def prepare_devices(self):
Expand Down
1 change: 1 addition & 0 deletions test/appium/tests/marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
upgrade = pytest.mark.upgrade
skip = pytest.mark.skip
xfail = pytest.mark.xfail
secured = pytest.mark.secured

0 comments on commit a8395e5

Please sign in to comment.