Skip to content

Commit 805d39d

Browse files
authored
Merge pull request #161 from CamilaAlvarez/hardware
Hardware subcommands
2 parents 38b8215 + d9e85c8 commit 805d39d

4 files changed

Lines changed: 119 additions & 11 deletions

File tree

docs/results.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Example:
2828
kci-dev results summary --giturl 'https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git' --branch master --commit d1486dca38afd08ca279ae94eb3a397f10737824
2929
```
3030

31-
### builds
31+
### <a id="result-builds"></a>builds
3232

3333
List builds results.
3434

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

41-
### boots
41+
### <a id="result-boots"></a>boots
4242

4343
List boot results.
4444

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

51-
### tests
51+
### <a id="result-tests"></a>tests
5252

5353
List test results.
5454

@@ -102,6 +102,39 @@ Example:
102102
kci-dev results hardware summary --name mediatek,mt8195 --origin maestro --json
103103
```
104104

105+
#### boots
106+
107+
List boot results for a hardware with `name` list for the last seven days.
108+
It supports the same options as [results boots](#result-boots).
109+
110+
Example:
111+
112+
```sh
113+
kci-dev results hardware boots --name mediatek,mt8195 --origin maestro --json
114+
```
115+
116+
#### builds
117+
118+
List build results for a hardware with `name` list for the last seven days.
119+
It supports the same options as [results builds](#result-builds).
120+
121+
Example:
122+
123+
```sh
124+
kci-dev results hardware builds --name mediatek,mt8195 --origin maestro --json
125+
```
126+
127+
#### tests
128+
129+
List test results for a hardware with `name` list for the last seven days.
130+
It supports the same options as [results tests](#result-tests).
131+
132+
Example:
133+
134+
```sh
135+
kci-dev results hardware tests --name mediatek,mt8195 --origin maestro --json
136+
```
137+
105138
## Common parameters
106139

107140
### --origin

kcidev/libs/dashboard.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ def dashboard_fetch_hardware_list(origin, use_json):
139139
return dashboard_api_fetch("hardware/", params, use_json)
140140

141141

142-
def dashboard_fetch_hardware_summary(name, origin, use_json):
143-
# TODO: add extra filters: Commits, date, filter, origin
142+
def _create_hardware_request_body(origin):
144143
now = datetime.today()
145144
last_week = now - timedelta(days=7)
146145
body = {
@@ -150,6 +149,33 @@ def dashboard_fetch_hardware_summary(name, origin, use_json):
150149
"selectedCommits": {},
151150
"filter": {},
152151
}
152+
return body
153+
154+
155+
def dashboard_fetch_hardware_summary(name, origin, use_json):
156+
# TODO: add extra filters: Commits, date, filter, origin
157+
body = _create_hardware_request_body(origin)
153158
return dashboard_api_post(
154159
f"hardware/{urllib.parse.quote_plus(name)}/summary", {}, use_json, body
155160
)
161+
162+
163+
def dashboard_fetch_hardware_boots(name, origin, use_json):
164+
body = _create_hardware_request_body(origin)
165+
return dashboard_api_post(
166+
f"hardware/{urllib.parse.quote_plus(name)}/boots", {}, use_json, body
167+
)
168+
169+
170+
def dashboard_fetch_hardware_builds(name, origin, use_json):
171+
body = _create_hardware_request_body(origin)
172+
return dashboard_api_post(
173+
f"hardware/{urllib.parse.quote_plus(name)}/builds", {}, use_json, body
174+
)
175+
176+
177+
def dashboard_fetch_hardware_tests(name, origin, use_json):
178+
body = _create_hardware_request_body(origin)
179+
return dashboard_api_post(
180+
f"hardware/{urllib.parse.quote_plus(name)}/tests", {}, use_json, body
181+
)

kcidev/subcommands/results/hardware.py

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1+
from functools import wraps
2+
13
import click
24

35
from kcidev.libs.dashboard import (
6+
dashboard_fetch_hardware_boots,
7+
dashboard_fetch_hardware_builds,
48
dashboard_fetch_hardware_list,
59
dashboard_fetch_hardware_summary,
10+
dashboard_fetch_hardware_tests,
11+
)
12+
from kcidev.subcommands.results.options import (
13+
builds_and_tests_options,
14+
results_display_options,
15+
)
16+
from kcidev.subcommands.results.parser import (
17+
cmd_builds,
18+
cmd_hardware_list,
19+
cmd_summary,
20+
cmd_tests,
621
)
7-
from kcidev.subcommands.results.options import results_display_options
8-
from kcidev.subcommands.results.parser import cmd_hardware_list, cmd_summary
22+
23+
24+
def hardware_common_opt(func):
25+
@click.option("--name", required=True, help="Name of the hardware")
26+
@click.option("--origin", default="maestro", help="Select KCIDB origin")
27+
@wraps(func)
28+
def wrapper(*args, **kwargs):
29+
return func(*args, **kwargs)
30+
31+
return wrapper
932

1033

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

2447

2548
@hardware.command()
26-
@click.option("--name", required=True, help="Name of the hardware")
27-
@click.option("--origin", default="maestro", help="Select KCIDB origin")
49+
@hardware_common_opt
2850
@results_display_options
2951
def summary(name, origin, use_json):
3052
data = dashboard_fetch_hardware_summary(name, origin, use_json)
3153
cmd_summary(data, use_json)
54+
55+
56+
@hardware.command()
57+
@hardware_common_opt
58+
@results_display_options
59+
@builds_and_tests_options
60+
def boots(name, origin, use_json, download_logs, status, filter, count):
61+
data = dashboard_fetch_hardware_boots(name, origin, use_json)
62+
cmd_tests(data["boots"], name, download_logs, status, filter, count, use_json)
63+
64+
65+
@hardware.command()
66+
@hardware_common_opt
67+
@results_display_options
68+
@builds_and_tests_options
69+
def builds(name, origin, use_json, download_logs, status, filter, count):
70+
data = dashboard_fetch_hardware_builds(name, origin, use_json)
71+
cmd_builds(data, name, download_logs, status, count, use_json)
72+
73+
74+
@hardware.command()
75+
@hardware_common_opt
76+
@results_display_options
77+
@builds_and_tests_options
78+
def tests(name, origin, use_json, download_logs, status, filter, count):
79+
data = dashboard_fetch_hardware_tests(name, origin, use_json)
80+
cmd_tests(data["tests"], name, download_logs, status, filter, count, use_json)

kcidev/subcommands/results/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def filter_out_by_test(test, filter_data):
242242
return True
243243

244244

245-
def cmd_tests(data, commit, download_logs, status_filter, filter, count, use_json):
245+
def cmd_tests(data, id, download_logs, status_filter, filter, count, use_json):
246246
filter_data = yaml.safe_load(filter) if filter else None
247247
filtered_tests = 0
248248
tests = []
@@ -263,7 +263,7 @@ def cmd_tests(data, commit, download_logs, status_filter, filter, count, use_jso
263263
if "environment_misc" in test
264264
else "(Unknown platform)"
265265
)
266-
log_file = f"{platform}__{test['path']}__{test['config']}-{test['architecture']}-{test['compiler']}-{commit}.log"
266+
log_file = f"{platform}__{test['path']}__{test['config']}-{test['architecture']}-{test['compiler']}-{id}.log"
267267
log_path = download_logs_to_file(test["log_url"], log_file)
268268
if count:
269269
filtered_tests += 1

0 commit comments

Comments
 (0)