Skip to content
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
26 changes: 26 additions & 0 deletions kcidev/libs/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,29 @@ def dashboard_fetch_issues_extra(issues, use_json):
"""
body = {"issues": issues}
return dashboard_api_post("issue/extras/", {}, use_json, body)


def dashboard_fetch_tree_report(
origin,
git_branch,
git_url,
use_json,
test_path,
group_size,
max_age_in_hours,
min_age_in_hours,
):
"""Get tree report"""
params = [
("origin", origin),
("git_branch", git_branch),
("git_url", git_url),
("group_size", group_size),
("max_age_in_hours", max_age_in_hours),
("min_age_in_hours", min_age_in_hours),
]
for path in test_path:
params.append(("path", path))

logging.info(f"Fetching tree report for origin: {origin}")
return dashboard_api_fetch("tree-report", params, use_json)
62 changes: 61 additions & 1 deletion kcidev/subcommands/results/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import click
from tabulate import tabulate

from kcidev.libs.common import kci_msg_green, kci_msg_red
from kcidev.libs.common import kci_msg_green, kci_msg_json, kci_msg_red
from kcidev.libs.dashboard import (
dashboard_fetch_boot_issues,
dashboard_fetch_boots,
Expand All @@ -18,6 +18,7 @@
dashboard_fetch_summary,
dashboard_fetch_test,
dashboard_fetch_tests,
dashboard_fetch_tree_report,
)
from kcidev.libs.git_repo import get_tree_name, set_giturl_branch_commit
from kcidev.subcommands.results.hardware import hardware
Expand All @@ -37,6 +38,7 @@
cmd_single_test,
cmd_summary,
cmd_tests,
cmd_tree_report,
)


Expand Down Expand Up @@ -694,5 +696,63 @@ def detect(

issues.add_command(detect)


@results.command(
name="tree-report",
help="""Fetch tree report

\b
The command is used to fetch tree report using dashboard API.
The report will consist of build, boot, and tests summary along with regression
and unstable tests information.

\b
Examples:
# Get report by providing url and branch
kci-dev results tree-report --giturl <giturl> --branch <branch>
""",
)
@click.option(
"--origin",
help="Select KCIDB origin",
default="maestro",
)
@click.option(
"--giturl",
help="Git URL of kernel tree ",
required=True,
)
@click.option(
"--branch",
help="Branch to get results for",
required=True,
)
@click.option(
"--path",
multiple=True,
help="A list of test paths to query for. SQL Wildcard can be used.",
)
@click.option(
"--group-size",
default=3,
help="Maximum number of entries to be retrieved in a test history.",
)
@click.option(
"--max-age",
default=24,
help="Maximum age for the queried checkout and related tests in hours",
)
@click.option(
"--min-age", default=0, help="Minimum age of the queried checkout in hours."
)
@results_display_options
def tree_report(origin, giturl, branch, path, group_size, max_age, min_age, use_json):
"""Fetch tree report"""
data = dashboard_fetch_tree_report(
origin, branch, giturl, use_json, path, group_size, max_age, min_age
)
cmd_tree_report(data, use_json)


if __name__ == "__main__":
main_kcidev()
84 changes: 84 additions & 0 deletions kcidev/subcommands/results/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import re
from urllib.parse import urlparse

import requests
import yaml
Expand Down Expand Up @@ -953,3 +954,86 @@ def print_data(data, use_json):
kci_msg_json(data)
else:
kci_msg(data)


def sum_tree_report_inconclusive_results(results):
count = 0
for status in [
"error_count",
"skip_count",
"miss_count",
"done_count",
"null_count",
]:
if status in results.keys():
count += results[status]

return count


def get_tree_report_summary(command_data):
inconclusive_cmd = sum_tree_report_inconclusive_results(command_data)
pass_cmd = command_data["pass_count"] if "pass_count" in command_data.keys() else 0
fail_cmd = command_data["fail_count"] if "fail_count" in command_data.keys() else 0
return inconclusive_cmd, pass_cmd, fail_cmd


def cmd_tree_report(data, use_json):
"""Parse test report and print information"""
if use_json:
kci_msg_json(data)
return

kci_msg_nonl("Tree: ")
kci_msg_bold(data["dashboard_url"])
kci_msg(f"Commit: {data['commit_hash']}")
kci_msg_nonl("Origin: ")
kci_msg_cyan(data["origin"])
kci_msg(f"Checkout start time: {data['checkout_start_time']}")
kci_msg("")

builds = data["build_status_summary"]
inconclusive_builds, pass_builds, fail_builds = get_command_summary(builds)

boots = data["boot_status_summary"]
inconclusive_boots, pass_boots, fail_boots = get_tree_report_summary(boots)

tests = data["test_status_summary"]
inconclusive_tests, pass_tests, fail_tests = get_tree_report_summary(tests)

kci_msg_bold("Summary: (pass/fail/inconclusive)")
print_summary("builds", pass_builds, fail_builds, inconclusive_builds)
print_summary("boots", pass_boots, fail_boots, inconclusive_boots)
print_summary("tests", pass_tests, fail_tests, inconclusive_tests)
kci_msg("")

parsed = urlparse(data["dashboard_url"])
parsed_dashboard_url = f"{parsed.scheme}://{parsed.netloc}"

categories = {
"possible_regressions": "Possible regressions:",
"fixed_regressions": "Fixed regressions:",
"unstable_tests": "Unstable tests:",
}
for category, name in categories.items():
if data[category]:
kci_msg_bold(f"{name}")
for platform, info in data[category].items():
kci_msg_nonl("Platform: ")
kci_msg_cyan(platform)
for config, test_data in info.items():
kci_msg_nonl("- Config: ")
kci_msg_cyan(config)
for path, tests in test_data.items():
kci_msg_nonl(" - Test path: ")
kci_msg_cyan(path)
for test in tests:
kci_msg_nonl(f" · {parsed_dashboard_url}/test/{test['id']}")
kci_msg_nonl(" status:")
if test["status"] == "PASS":
kci_msg_green("PASS")
elif test["status"] == "FAIL":
kci_msg_red("FAIL")
else:
kci_msg_yellow(f"INCONCLUSIVE ({test['status']})")
kci_msg("")