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
/
squad-list-result-history
executable file
·131 lines (104 loc) · 3.06 KB
/
squad-list-result-history
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
import argparse
import json
import logging
import sys
from squad_client.core.api import SquadApi
from squad_client.core.models import Build, Squad
from squad_client.utils import getid
SquadApi.configure(cache=3600, url="https://qa-reports.linaro.org/")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def arg_parser():
parser = argparse.ArgumentParser(description="List the result history of a test")
parser.add_argument(
"--group",
required=True,
help="squad group",
)
parser.add_argument(
"--project",
required=True,
help="squad project",
)
parser.add_argument(
"--build",
required=True,
help="squad build",
)
parser.add_argument(
"--environment",
required=True,
help="squad environment",
)
parser.add_argument(
"--suite",
required=True,
help="squad suite",
)
parser.add_argument(
"--test",
required=True,
help="squad test",
)
return parser
def run():
args = arg_parser().parse_args()
group = Squad().group(args.group)
if group is None:
logger.error(f"Get group failed. Group not found: '{args.group}'.")
return -1
project = group.project(args.project)
if project is None:
logger.error(f"Get project failed. Project not found: '{args.project}'.")
return -1
build = project.build(args.build)
if build is None:
logger.error(f"Get build failed. Build not found: '{args.build}'.")
return -1
environment = project.environment(args.environment)
if environment is None:
logger.error(
f"Get environment failed. Environment not found: '{args.environment}'."
)
return -1
suite = project.suite(args.suite)
if suite is None:
logger.error(f"Get suite failed. Suite not found: '{args.suite}'.")
return -1
tests = (
Squad()
.tests(
build__created_at__lte=build.created_at,
environment=environment.id,
suite=suite.id,
metadata__name=args.test,
ordering="-build_id",
count=30,
)
.values()
)
if not tests:
logger.error(f"Get tests failed. Tests not found: '{args.test}'.")
return -1
flat = []
for test in tests:
test_build = Build(getid(test.build))
if test_build is None:
logger.error(f"Get build failed. Build not found: '{test.build}'.")
return -1
flat.append(
{
"group": group.slug,
"project": project.slug,
"build": test_build.version,
"environment": environment.slug,
"suite": suite.slug,
"test": test.short_name,
"status": test.status,
"has_known_issues": test.has_known_issues,
}
)
print(json.dumps(flat, indent=2))
if __name__ == "__main__":
sys.exit(run())