forked from dotnet/performance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetjenkinsstatus.py
executable file
·164 lines (141 loc) · 6.03 KB
/
getjenkinsstatus.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python3
import urllib.request
import sys
import subprocess
import argparse
##########################################################################
# Argument Parser
##########################################################################
description = 'Tool to get job status'
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-os', dest='operatingSystem', default='Windows', choices=['Windows', 'Linux'])
parser.add_argument('-jobType', dest='jobType', default='all', choices=['all','perf','size','e2e','throughput'])
parser.add_argument('-arch', dest='arch', default='all', choices=['all','x86','x64'])
parser.add_argument('-repo', dest='repo', default='', choices=['coreclr','corefx'])
def parseStatusPage(url, job):
source = 'test.txt'
p = subprocess.Popen("powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; [io.file]::WriteAllText(\\\"{}\\\", (Invoke-WebRequest -UseBasicParsing -Uri {}).content)".format(source, url), shell=True)
p.communicate()
failing = False
passing = False
running = False
aborted = False
status = ""
f = open(source, "r")
for line in f.readlines():
if "failing" in line:
status = "failing"
failing = True
if "passing" in line:
status = "passing"
passing = True
if "running" in line:
status = "running"
running = True
if "aborted" in line:
status = "aborted"
aborted = True
print("{}: {}".format(job, status))
return failing or aborted
def main(args):
operatingSystem = args.operatingSystem
jobType = args.jobType
arch = args.arch
repo = args.repo
if operatingSystem == 'Linux':
if not (jobType == 'all' or jobType == 'perf' or jobType == 'throughput'):
raise ValueError('Linux only has perf and throughput jobs. JobType %s is invalid.', jobType)
if not (arch == 'all' or arch == 'x64'):
raise ValueError('Linux only supports x64. Arch %s is invalid.', arch)
urlPrefix = "https://ci2.dot.net/job/"
urlJobPath = "/job/perf/job/master/job/"
urlSuffix = "/lastCompletedBuild/badge/icon"
coreclrJobs = {
'Windows' : {
'size' : {
'x64' : [
'perf_illink_Windows_NT_x64_full_opt_ryujit',
'sizeondisk_x64'
],
'x86' : [
'sizeondisk_x86'
]
},
'perf' : {
'x64' : [
'perf_perflab_Windows_NT_x64_full_opt_ryujit',
'perf_perflab_Windows_NT_x64_min_opt_ryujit'
],
'x86' : [
'perf_perflab_Windows_NT_x86_full_opt_ryujit',
'perf_perflab_Windows_NT_x86_min_opt_ryujit'
]
},
'e2e' : {
'x64' : [
'perf_scenarios_Windows_NT_x64_full_opt_ryujit',
'perf_scenarios_Windows_NT_x64_min_opt_ryujit',
'perf_scenarios_Windows_NT_x64_tiered_ryujit'
],
'x86' : [
'perf_scenarios_Windows_NT_x86_full_opt_ryujit',
'perf_scenarios_Windows_NT_x86_min_opt_ryujit',
'perf_scenarios_Windows_NT_x86_tiered_ryujit'
]
},
'throughput' : {
'x64' : [
'perf_throughput_perflab_Windows_NT_x64_full_opt_ryujit_nopgo',
'perf_throughput_perflab_Windows_NT_x64_full_opt_ryujit_pgo',
'perf_throughput_perflab_Windows_NT_x64_min_opt_ryujit_nopgo',
'perf_throughput_perflab_Windows_NT_x64_min_opt_ryujit_pgo'
],
'x86' : [
'perf_throughput_perflab_Windows_NT_x86_full_opt_ryujit_nopgo',
'perf_throughput_perflab_Windows_NT_x86_full_opt_ryujit_pgo',
'perf_throughput_perflab_Windows_NT_x86_min_opt_ryujit_nopgo',
'perf_throughput_perflab_Windows_NT_x86_min_opt_ryujit_pgo'
]
}
},
'Linux' : {
'perf' : {
'x64': [
'perf_linux_flow'
]
},
'throughput' : {
'x64': [
'perf_throughput_linux_flow'
]
}
}
}
corefxJobs = {
'Windows' : [ 'perf_windows_nt_release'],
'Linux' : ['perf_ubuntu16.04_release']
}
overallStatus = "passing"
if repo == 'coreclr' or repo == '':
urlRepo = 'dotnet_coreclr'
for jobChoice in coreclrJobs[operatingSystem]:
if jobChoice == jobType or jobType == 'all':
for archChoice in coreclrJobs[operatingSystem][jobChoice]:
if archChoice == arch or arch == 'all':
for job in coreclrJobs[operatingSystem][jobChoice][archChoice]:
url = urlPrefix + urlRepo + urlJobPath + job + urlSuffix
if parseStatusPage(url, job):
overallStatus = 'failing'
if repo == 'corefx' or repo == '':
urlRepo = 'dotnet_corefx'
for job in corefxJobs[operatingSystem]:
url = urlPrefix + urlRepo + urlJobPath + job + urlSuffix
if parseStatusPage(url, job):
overallStatus = 'failing'
print('%s %s %s %s jobs are %s' % (repo, operatingSystem, arch, jobType, overallStatus))
if overallStatus == 'failing':
return -1
return 0
if __name__ == "__main__":
Args = parser.parse_args(sys.argv[1:])
sys.exit(main(Args))