This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfind_latest_passing_test.py
executable file
·85 lines (71 loc) · 2.42 KB
/
find_latest_passing_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Given a bad build, find the latest good one
"""
import argparse
import re
from squad_client.core.api import SquadApi
from squad_client.core.models import Build, Squad
from squad_client.utils import first
def main(args):
# Some configuration, might get parameterized later
SquadApi.configure(args.get("squadapi_url", None))
squad = Squad()
getid = lambda s: int(re.search(r"\d+", s).group()) # noqa
group = squad.group(args.get("group", None))
project = group.project(args.get("project", None))
bad_suite = project.suite(args.get("suite", None))
bad_test = args.get("test", None)
bad_env = project.environment(args.get("arch", None))
kernel_build = args.get("kernel_build", None)
if kernel_build:
bad_build = project.build(kernel_build)
else:
bad_build = first(project.builds(count=1, ordering="-id"))
print(
"Looking at the next good build in %s/%s for build %s"
% (group.slug, project.slug, bad_build.version),
flush=True,
)
tests = squad.tests(
build__created_at__lt=bad_build.created_at,
suite=bad_suite.id,
environment=bad_env.id,
metadata__name=bad_test,
ordering="-build_id",
result=True,
count=1,
)
if len(tests):
test = first(tests)
build = Build(getid(test.build))
print(
"%s: https://qa-reports.linaro.org/%s/%s/build/%s"
% (build.version, group.slug, project.slug, build.version)
)
else:
print("No good build")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--kernel_build",
help="tag or sha, e.g., next-20201204. Defaults to latest build",
)
parser.add_argument("--arch", required=True, help="architecture, e.g., arm64")
parser.add_argument("--group", required=True, help="Group name e.g., lkft")
parser.add_argument(
"--project", required=True, help="Project name e.g., linux-next-master"
)
parser.add_argument("--suite", required=True, help="Suite name e.g., kunit")
parser.add_argument("--test", required=True, help="test name")
parser.add_argument(
"--squadapi_url",
default="https://qa-reports.linaro.org",
help="url to SQUAD server",
)
args = vars(parser.parse_args())
if args:
main(args)
else:
exit(1)