Skip to content

Commit

Permalink
kcidb/oo/__init__: methods for getting fluster tests stats
Browse files Browse the repository at this point in the history
Add `Node.sort_fluster_tests_by_platform` to create a sorted
dictionary by platform with its associated passed and failed tests.
Add `Node.get_fluster_stats` for getting number of passed and failed
tests for all enabled fluster tests per platform.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia committed Aug 28, 2024
1 parent ac269d4 commit 188b903
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions kcidb/oo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,74 @@ def waived_status_tests(self):
waived_status_tests[test.waived][test.status].append(test)
return waived_status_tests

def sort_fluster_tests_by_platform(self, passed_tests, failed_tests):
"""
Create a sorted dictionary by platform with its associated passed
and failed tests
Arguments:
(passed_tests) A list with platform and passed tests for that
platform with the format: [<platform>, <passed-tests-list>]
(failed_tests) A list with platform and failed tests for that
platform with the format: [<platform>, <failed-tests-list>]
Returns: (sorted_tests) A dictionary with key as a
platform and value as a list consists of passed and failed tests
in a format as the below:
{<platform>: [<passed-tests-list>, <failed-tests-list>]}
"""
sorted_tests = {}
for platform, tests in passed_tests:
sorted_tests[platform] = tests

for platform, tests in failed_tests:
if platform in sorted_tests.keys():
sorted_tests[platform] = [sorted_tests[platform], tests]
else:
sorted_tests[platform] = [[], tests]
return sorted_tests

def get_fluster_stats(self, sorted_tests_by_platform):
"""
Get number of passed and failed tests for all enabled fluster tests
Argument: (sorted_tests_by_platform) A dictionary with key as a
platform and value as a list consists of passed and failed tests
in a format as the below:
{<platform>: [<passed-tests-list>, <failed-tests-list>]}
Returns: (final_stats) A dictionary with key as a platform and value
as a list consists of flutser tests stats in a format as the below:
{<platform>: [<fluster-test-name>, <passed-tests-count>,
<failed-tests-count>]}
"""
fluster_tests_mapping = {
"fluster.v4l2.gstreamer_av1": "v4l2-decoder-conformance-av1",
"fluster.v4l2.gstreamer_av1_chromium":
"v4l2-decoder-conformance-av1-chromium-10bit",
"fluster.v4l2.gstreamer_h264": "v4l2-decoder-conformance-h264",
"fluster.v4l2.gstreamer_h264_frext":
"v4l2-decoder-conformance-h264-frext",
"fluster.v4l2.gstreamer_h265": "v4l2-decoder-conformance-h265",
"fluster.v4l2.gstreamer_vp8": "v4l2-decoder-conformance-vp8",
"fluster.v4l2.gstreamer_vp9": "v4l2-decoder-conformance-vp9"
}
final_stats = {}
for platform, tests in sorted_tests_by_platform.items():
stats = []
passed = tests[0]
failed = tests[1]
for key, value in fluster_tests_mapping.items():
matched_passed = [t.path for t in passed
if key in t.path and t.path != key and
t.path != f"{key}.validate-fluster-results"]
matched_failed = [t.path for t in failed
if key in t.path and t.path != key and
t.path != f"{key}.validate-fluster-results"]
stats.append([value, len(matched_passed), len(matched_failed)])
final_stats[platform] = stats
return final_stats

def __getitem__(self, name):
assert isinstance(name, (str, type(None)))
return Node(self, name)
Expand Down

0 comments on commit 188b903

Please sign in to comment.