Skip to content

Commit 55269e2

Browse files
Merge remote-tracking branch 'origin' into Hani/cm-newegg-us-ad
2 parents 42e0a39 + d92e2c7 commit 55269e2

File tree

4 files changed

+64
-23
lines changed

4 files changed

+64
-23
lines changed

.github/workflows/l10n.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,16 @@ jobs:
138138
uses: actions/setup-python@v5
139139
with:
140140
python-version: "3.11"
141+
- name: Set Environment (Scheduled Beta)
142+
if: ${{ inputs.job_to_run == 'L10N-Linux' }}
143+
run: |
144+
echo "TESTRAIL_REPORT='true'" >> "$GITHUB_ENV";
145+
echo "Running report for most recent Beta on Linux";
141146
- name: Install dependencies
142147
id: setup
143148
env:
144149
MANUAL_DOWNLOAD_LINK: ${{ inputs.linux_tarball_link }}
145150
run: |
146-
echo "MANUAL='true'" >> "$GITHUB_ENV";
147151
echo "Running l10n tests on supplied executable";
148152
sudo apt install gnome-screenshot;
149153
uname -m;
@@ -225,7 +229,7 @@ jobs:
225229
New-item -Name .env -Value $env_contents -ItemType File -Force
226230
Write-Host "Running l10n tests on supplied executable"
227231
- name: Set Environment (Scheduled Beta)
228-
if: ${{ inputs.job_to_run == 'Smoke-Windows' }}
232+
if: ${{ inputs.job_to_run == 'L10N-Windows' }}
229233
run: |
230234
$env_contents = @"
231235
TESTRAIL_REPORT='true'

l10n_CM/run_l10n.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
valid_flags = {"--run-headless", "-n", "--reruns", "--fx-executable", "--ci"}
1414
flag_with_parameter = {"-n", "--reruns"}
1515
valid_region = {"US", "CA", "DE", "FR"}
16-
1716
valid_sites = {
1817
"demo",
1918
"amazon",
@@ -26,9 +25,7 @@
2625
"decathlon",
2726
"vans",
2827
"ebay",
29-
"newegg",
3028
}
31-
3229
live_sites = []
3330

3431
LOCALHOST = "127.0.0.1"

modules/testrail.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ def update_test_cases(
391391
testrail_suite_id,
392392
test_case_ids=[],
393393
status="passed",
394+
elapsed=[],
394395
):
395396
"""Given a project id, a run id, and a suite id, for each case given a status,
396397
update the test objects with the correct status code"""
@@ -408,13 +409,19 @@ def update_test_cases(
408409
testrail_project_id, testrail_suite_id
409410
)
410411
]
411-
data = {
412-
"results": [
413-
{"case_id": test_case_id, "status_id": status_key.get(status)}
414-
for test_case_id in test_case_ids
415-
]
416-
}
417-
return self._update_test_run_results(testrail_run_id, data)
412+
413+
results = []
414+
for i in range(len(test_case_ids)):
415+
results.append(
416+
{
417+
"case_id": test_case_ids[i],
418+
"status_id": status_key.get(status),
419+
"elapsed": elapsed[i],
420+
}
421+
)
422+
logging.warning(f"Going to update cases with payload: {results}")
423+
424+
return self._update_test_run_results(testrail_run_id, {"results": results})
418425

419426
# Private Methods
420427

modules/testrail_integration.py

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,21 +246,33 @@ def mark_results(testrail_session: TestRail, test_results):
246246
for result in existing_results[run_id]
247247
}
248248
suite_id = test_results[category][run_id][0].get("suite_id")
249-
all_test_cases = [
250-
result.get("test_case") for result in test_results[category][run_id]
251-
]
249+
250+
all_test_cases = []
251+
all_durations = []
252+
for result in test_results[category][run_id]:
253+
all_test_cases.append(result.get("test_case"))
254+
all_durations.append(result.get("duration"))
252255

253256
# Don't set passed tests to another status.
254-
test_cases = [tc for tc in all_test_cases if current_results.get(tc) != 1]
257+
test_cases_ids = []
258+
durations = []
259+
for i, test_case in enumerate(all_test_cases):
260+
if current_results.get(test_case) != 1:
261+
test_cases_ids.append(test_case)
262+
durations.append(all_durations[i])
263+
logging.warning(
264+
f"Setting the following test cases in run {run_id} to {category}: {test_cases_ids}"
265+
)
255266
logging.warning(
256-
f"Setting the following test cases in run {run_id} to {category}: {test_cases}"
267+
f"Setting the following test cases {test_cases_ids} to duration {durations}"
257268
)
258269
testrail_session.update_test_cases(
259270
test_results.get("project_id"),
260271
testrail_run_id=run_id,
261272
testrail_suite_id=suite_id,
262-
test_case_ids=test_cases,
273+
test_case_ids=test_cases_ids,
263274
status=category,
275+
elapsed=durations,
264276
)
265277

266278

@@ -407,6 +419,7 @@ def organize_entries(testrail_session: TestRail, expected_plan: dict, suite_info
407419
cases_in_suite = suite_info.get("cases")
408420
cases_in_suite = [int(n) for n in cases_in_suite]
409421
results = suite_info.get("results")
422+
durations = suite_info.get("durations")
410423
plan_title = expected_plan.get("name")
411424

412425
suite_entries = [
@@ -502,16 +515,18 @@ def organize_entries(testrail_session: TestRail, expected_plan: dict, suite_info
502515
"skipped": {},
503516
}
504517

505-
for test_case, outcome in results.items():
506-
logging.info(f"{test_case}: {outcome}")
518+
for test_case in results.keys():
519+
outcome = results[test_case]
520+
duration = durations[test_case]
521+
logging.info(f"{test_case}: {outcome} {duration}")
507522
if outcome == "rerun":
508523
logging.info("Rerun result...skipping...")
509524
continue
510525
category = next(status for status in passkey if outcome in passkey.get(status))
511526
if not test_results[category].get(run_id):
512527
test_results[category][run_id] = []
513528
test_results[category][run_id].append(
514-
{"suite_id": suite_id, "test_case": test_case}
529+
{"suite_id": suite_id, "test_case": test_case, "duration": f"{duration}s"}
515530
)
516531

517532
return test_results
@@ -547,7 +562,9 @@ def collect_changes(testrail_session: TestRail, report):
547562

548563
version_str = metadata.get("fx_version")
549564
plan_title = get_plan_title(version_str, channel)
550-
logging.info(plan_title)
565+
logging.warning(
566+
f"Got plan title: {plan_title} from version {version_str} and channel {channel}"
567+
)
551568
plan_match = PLAN_NAME_RE.match(plan_title)
552569
(_, major) = [plan_match[n] for n in range(1, 3)]
553570
config = metadata.get("machine_config")
@@ -628,6 +645,7 @@ def collect_changes(testrail_session: TestRail, report):
628645
last_suite_id = None
629646
last_description = None
630647
results_by_suite = {}
648+
durations_by_suite = {}
631649
full_test_results = {}
632650
tests = [
633651
test
@@ -655,11 +673,22 @@ def collect_changes(testrail_session: TestRail, report):
655673
# Tests reported as rerun are a problem -- we need to know pass/fail
656674
if outcome == "rerun":
657675
outcome = test.get("call").get("outcome")
658-
logging.info(f"TC: {test_case}: {outcome}")
676+
duration = (
677+
test["setup"]["duration"]
678+
+ test["call"]["duration"]
679+
+ test["teardown"]["duration"]
680+
)
681+
logging.info(f"TC: {test_case}: {outcome} using {duration}s ")
659682

660683
if not results_by_suite.get(suite_id):
661684
results_by_suite[suite_id] = {}
685+
durations_by_suite[suite_id] = {}
662686
results_by_suite[suite_id][test_case] = outcome
687+
durations_by_suite[suite_id].setdefault(test_case, 0)
688+
durations_by_suite[suite_id][test_case] = round(
689+
durations_by_suite[suite_id][test_case] + duration, 2
690+
)
691+
663692
if suite_id != last_suite_id:
664693
# When we get the last test_case in a suite, add entry, run, results
665694
if last_suite_id:
@@ -674,6 +703,7 @@ def collect_changes(testrail_session: TestRail, report):
674703
"config_id": config_id,
675704
"cases": cases_in_suite,
676705
"results": results_by_suite[last_suite_id],
706+
"durations": durations_by_suite[last_suite_id],
677707
}
678708

679709
full_test_results = merge_results(
@@ -694,6 +724,7 @@ def collect_changes(testrail_session: TestRail, report):
694724
"config_id": config_id,
695725
"cases": cases_in_suite,
696726
"results": results_by_suite[last_suite_id],
727+
"durations": durations_by_suite[last_suite_id],
697728
}
698729

699730
logging.info(f"n run {last_suite_id}, {last_description}")
@@ -706,6 +737,8 @@ def collect_changes(testrail_session: TestRail, report):
706737
full_test_results = merge_results(
707738
full_test_results, organize_entries(testrail_session, expected_plan, suite_info)
708739
)
740+
logging.warning(f"full test results: {full_test_results}")
741+
709742
return full_test_results
710743

711744

0 commit comments

Comments
 (0)