Skip to content
Merged
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
39 changes: 36 additions & 3 deletions docs/results.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Example:
kci-dev results summary --giturl 'https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git' --branch master --commit d1486dca38afd08ca279ae94eb3a397f10737824
```

### builds
### <a id="result-builds"></a>builds

List builds results.

Expand All @@ -38,7 +38,7 @@ Example:
kci-dev results builds --giturl 'https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git' --branch master --commit d1486dca38afd08ca279ae94eb3a397f10737824
```

### boots
### <a id="result-boots"></a>boots

List boot results.

Expand All @@ -48,7 +48,7 @@ Example:
kci-dev results boots --giturl 'https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git' --branch master --latest
```

### tests
### <a id="result-tests"></a>tests

List test results.

Expand Down Expand Up @@ -102,6 +102,39 @@ Example:
kci-dev results hardware summary --name mediatek,mt8195 --origin maestro --json
```

#### boots

List boot results for a hardware with `name` list for the last seven days.
It supports the same options as [results boots](#result-boots).

Example:

```sh
kci-dev results hardware boots --name mediatek,mt8195 --origin maestro --json
```

#### builds

List build results for a hardware with `name` list for the last seven days.
It supports the same options as [results builds](#result-builds).

Example:

```sh
kci-dev results hardware builds --name mediatek,mt8195 --origin maestro --json
```

#### tests

List test results for a hardware with `name` list for the last seven days.
It supports the same options as [results tests](#result-tests).

Example:

```sh
kci-dev results hardware tests --name mediatek,mt8195 --origin maestro --json
```

## Common parameters

### --origin
Expand Down
30 changes: 28 additions & 2 deletions kcidev/libs/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ def dashboard_fetch_hardware_list(origin, use_json):
return dashboard_api_fetch("hardware/", params, use_json)


def dashboard_fetch_hardware_summary(name, origin, use_json):
# TODO: add extra filters: Commits, date, filter, origin
def _create_hardware_request_body(origin):
now = datetime.today()
last_week = now - timedelta(days=7)
body = {
Expand All @@ -150,6 +149,33 @@ def dashboard_fetch_hardware_summary(name, origin, use_json):
"selectedCommits": {},
"filter": {},
}
return body


def dashboard_fetch_hardware_summary(name, origin, use_json):
# TODO: add extra filters: Commits, date, filter, origin
body = _create_hardware_request_body(origin)
return dashboard_api_post(
f"hardware/{urllib.parse.quote_plus(name)}/summary", {}, use_json, body
)


def dashboard_fetch_hardware_boots(name, origin, use_json):
body = _create_hardware_request_body(origin)
return dashboard_api_post(
f"hardware/{urllib.parse.quote_plus(name)}/boots", {}, use_json, body
)


def dashboard_fetch_hardware_builds(name, origin, use_json):
body = _create_hardware_request_body(origin)
return dashboard_api_post(
f"hardware/{urllib.parse.quote_plus(name)}/builds", {}, use_json, body
)


def dashboard_fetch_hardware_tests(name, origin, use_json):
body = _create_hardware_request_body(origin)
return dashboard_api_post(
f"hardware/{urllib.parse.quote_plus(name)}/tests", {}, use_json, body
)
57 changes: 53 additions & 4 deletions kcidev/subcommands/results/hardware.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
from functools import wraps

import click

from kcidev.libs.dashboard import (
dashboard_fetch_hardware_boots,
dashboard_fetch_hardware_builds,
dashboard_fetch_hardware_list,
dashboard_fetch_hardware_summary,
dashboard_fetch_hardware_tests,
)
from kcidev.subcommands.results.options import (
builds_and_tests_options,
results_display_options,
)
from kcidev.subcommands.results.parser import (
cmd_builds,
cmd_hardware_list,
cmd_summary,
cmd_tests,
)
from kcidev.subcommands.results.options import results_display_options
from kcidev.subcommands.results.parser import cmd_hardware_list, cmd_summary


def hardware_common_opt(func):
@click.option("--name", required=True, help="Name of the hardware")
@click.option("--origin", default="maestro", help="Select KCIDB origin")
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)

return wrapper


@click.group(chain=True, help="Get hardware related information from the dashboard")
Expand All @@ -23,9 +46,35 @@ def list(origin, use_json):


@hardware.command()
@click.option("--name", required=True, help="Name of the hardware")
@click.option("--origin", default="maestro", help="Select KCIDB origin")
@hardware_common_opt
@results_display_options
def summary(name, origin, use_json):
data = dashboard_fetch_hardware_summary(name, origin, use_json)
cmd_summary(data, use_json)


@hardware.command()
@hardware_common_opt
@results_display_options
@builds_and_tests_options
def boots(name, origin, use_json, download_logs, status, filter, count):
data = dashboard_fetch_hardware_boots(name, origin, use_json)
cmd_tests(data["boots"], name, download_logs, status, filter, count, use_json)


@hardware.command()
@hardware_common_opt
@results_display_options
@builds_and_tests_options
def builds(name, origin, use_json, download_logs, status, filter, count):
data = dashboard_fetch_hardware_builds(name, origin, use_json)
cmd_builds(data, name, download_logs, status, count, use_json)


@hardware.command()
@hardware_common_opt
@results_display_options
@builds_and_tests_options
def tests(name, origin, use_json, download_logs, status, filter, count):
data = dashboard_fetch_hardware_tests(name, origin, use_json)
cmd_tests(data["tests"], name, download_logs, status, filter, count, use_json)
4 changes: 2 additions & 2 deletions kcidev/subcommands/results/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def filter_out_by_test(test, filter_data):
return True


def cmd_tests(data, commit, download_logs, status_filter, filter, count, use_json):
def cmd_tests(data, id, download_logs, status_filter, filter, count, use_json):
filter_data = yaml.safe_load(filter) if filter else None
filtered_tests = 0
tests = []
Expand All @@ -263,7 +263,7 @@ def cmd_tests(data, commit, download_logs, status_filter, filter, count, use_jso
if "environment_misc" in test
else "(Unknown platform)"
)
log_file = f"{platform}__{test['path']}__{test['config']}-{test['architecture']}-{test['compiler']}-{commit}.log"
log_file = f"{platform}__{test['path']}__{test['config']}-{test['architecture']}-{test['compiler']}-{id}.log"
log_path = download_logs_to_file(test["log_url"], log_file)
if count:
filtered_tests += 1
Expand Down