Skip to content

Commit c8c00e6

Browse files
author
Jeny Sadadia
committed
Implement command to validate builds
Get builds from dashboard and validate it with maestro result. Signed-off-by: Jeny Sadadia <[email protected]>
1 parent 6876c03 commit c8c00e6

File tree

4 files changed

+84
-10
lines changed

4 files changed

+84
-10
lines changed

kcidev/libs/maestro_common.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,29 @@ def maestro_get_node(url, nodeid):
6262
return response.json()
6363

6464

65-
def maestro_get_nodes(url, limit, offset, filter):
65+
def maestro_get_nodes(url, limit, offset, filter, paginate):
6666
headers = {
6767
"Content-Type": "application/json; charset=utf-8",
6868
}
69-
url = url + "latest/nodes/fast?limit=" + str(limit) + "&offset=" + str(offset)
70-
maestro_print_api_call(url)
71-
if filter:
72-
for f in filter:
73-
# TBD: We need to add translate filter to API
74-
# if we need anything more complex than eq(=)
75-
url = url + "&" + f
7669

70+
if paginate:
71+
url = url + "latest/nodes/fast?limit=" + str(limit) + "&offset=" + str(offset)
72+
if filter:
73+
for f in filter:
74+
# TBD: We need to add translate filter to API
75+
# if we need anything more complex than eq(=)
76+
url = url + "&" + f
77+
78+
else:
79+
url = url + "latest/nodes/fast"
80+
if filter:
81+
url = url + "?"
82+
for f in filter:
83+
# TBD: We need to add translate filter to API
84+
# if we need anything more complex than eq(=)
85+
url = url + "&" + f
86+
87+
maestro_print_api_call(url)
7788
response = requests.get(url, headers=headers)
7889
try:
7990
response.raise_for_status()

kcidev/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
results,
1717
testretry,
1818
watch,
19+
validate_builds,
1920
)
2021

2122

@@ -66,6 +67,7 @@ def run():
6667
cli.add_command(testretry.testretry)
6768
cli.add_command(results.results)
6869
cli.add_command(watch.watch)
70+
cli.add_command(validate_builds.validate_builds)
6971
cli()
7072

7173

kcidev/subcommands/maestro_results.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,21 @@
4444
multiple=True,
4545
help="Print only particular field(s) from node data",
4646
)
47+
@click.option(
48+
"--count",
49+
is_flag=True,
50+
required=False,
51+
help="Print only count of nodes",
52+
)
53+
@click.option(
54+
"--paginate",
55+
is_flag=True,
56+
required=False,
57+
default=True,
58+
help="Set True if pagination is required in the output. Default is True",
59+
)
4760
@click.pass_context
48-
def maestro_results(ctx, nodeid, nodes, limit, offset, filter, field):
61+
def maestro_results(ctx, nodeid, nodes, limit, offset, filter, field, count, paginate):
4962
config = ctx.obj.get("CFG")
5063
instance = ctx.obj.get("INSTANCE")
5164
url = config[instance]["api"]
@@ -55,7 +68,10 @@ def maestro_results(ctx, nodeid, nodes, limit, offset, filter, field):
5568
if nodeid:
5669
results = maestro_get_node(url, nodeid)
5770
if nodes:
58-
results = maestro_get_nodes(url, limit, offset, filter)
71+
results = maestro_get_nodes(url, limit, offset, filter, paginate)
72+
if count:
73+
print("Total nodes found: ", len(results))
74+
return
5975
maestro_print_nodes(results, field)
6076

6177

kcidev/subcommands/validate_builds.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import click
5+
from click.testing import CliRunner
6+
7+
from kcidev.libs.common import *
8+
from kcidev.libs.maestro_common import *
9+
from .results import builds
10+
from .maestro_results import maestro_results
11+
12+
13+
runner = CliRunner()
14+
15+
@click.command(help="Validate builds from dashboard and maestro")
16+
@click.option(
17+
"--giturl",
18+
help="Git URL of kernel tree ",
19+
)
20+
@click.option(
21+
"--branch",
22+
help="Branch to get results for",
23+
)
24+
@click.option(
25+
"--commit",
26+
help="Commit or tag to get results for",
27+
)
28+
@click.option("--arch", help="Filter by arch")
29+
@click.pass_context
30+
def validate_builds(ctx, giturl, branch, commit, arch):
31+
print("Validate builds called----")
32+
ret = ctx.forward(builds, count=True)
33+
ret = ctx.invoke(maestro_results,
34+
count=True, nodes=True,
35+
filter=("kind=kbuild",
36+
"data.kernel_revision.url="+giturl,
37+
"data.kernel_revision.branch="+branch,
38+
"data.kernel_revision.commit="+commit
39+
),
40+
paginate=False,
41+
)
42+
43+
44+
if __name__ == "__main__":
45+
main_kcidev()

0 commit comments

Comments
 (0)