Skip to content

Commit 24e0280

Browse files
committed
Get builds based on nightly image
Signed-off-by: SurajGudaji <[email protected]>
1 parent 8f013d5 commit 24e0280

File tree

6 files changed

+200
-70
lines changed

6 files changed

+200
-70
lines changed

CI_DailyBuildUpdates.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ def main():
2020
elif args.job_type == 'z':
2121
config_file = 'z_periodic.json'
2222
elif args.job_type == 'pa':
23-
config_file = 'p_auxillary.json'
23+
config_file = 'p_auxillary.json'
2424

2525
monitor.PROW_URL = monitor.set_prow_url(args.job_type)
2626
config_data = monitor.load_config(config_file)
2727
if args.info_type == "brief":
2828
summary_list = []
2929
for ci_name,ci_link in config_data.items():
30-
summary_list.extend(monitor.get_brief_job_info(ci_name,ci_link,zone=args.zone))
30+
build_list = monitor.get_jobs(ci_link)
31+
summary_list.extend(monitor.get_brief_job_info(build_list,ci_name,zone=args.zone))
3132
print(tabulate(summary_list, headers='keys', tablefmt="pipe", stralign='left'))
3233
elif args.info_type == "detailed":
3334
for ci_name,ci_link in config_data.items():
34-
monitor.get_detailed_job_info(ci_name,ci_link,zone=args.zone)
35+
build_list = monitor.get_jobs(ci_link)
36+
monitor.get_detailed_job_info(build_list,ci_name,zone=args.zone)
3537

3638
if __name__ == "__main__":
3739
main()

CI_JobHistory.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ def get_testcase_names():
235235
tc_list = tc_name.split(",")
236236
return tc_list
237237

238+
239+
238240
def main():
239241
parser = argparse.ArgumentParser(description='Get the job history')
240242
parser.add_argument('--zone', help='specify the lease/zone', type= lambda arg:arg.split(','))
@@ -273,13 +275,15 @@ def main():
273275
if option == '2':
274276
summary_list = []
275277
for ci_name,ci_link in ci_list.items():
276-
summary_list.extend(monitor.get_brief_job_info(ci_name,ci_link,start_date,end_date,zone=args.zone))
278+
spy_links = monitor.get_jobs_with_date(ci_link,start_date,end_date)
279+
summary_list.extend(monitor.get_brief_job_info(spy_links,ci_name,zone=args.zone))
277280
monitor.final_job_list = []
278281
print(tabulate(summary_list, headers='keys', tablefmt="pipe", stralign='left'))
279282

280283
if option == '3':
281284
for ci_name,ci_link in ci_list.items():
282-
monitor.get_detailed_job_info(ci_name,ci_link,start_date,end_date,zone=args.zone)
285+
spy_links = monitor.get_jobs_with_date(ci_link,start_date,end_date)
286+
monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone)
283287
monitor.final_job_list = []
284288

285289
if option == '4':

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,10 @@ Create a virtualenv if required and install required packages using "pip install
7878
1. builds: This argument accepts int value, which will query for failed testcases in "n" latest build run in the CI, default value set is 10.
7979
2. frequency: This argument accepts int value, which specifies the frequency threshold and report the testcases which are failing above the frequency, default value set is 3.
8080
81+
82+
4. **aggregate.py:** The aggregate.py script gets detailed information of all the builds which have run using the provided nightly image.
83+
84+
```python3 tracker.py``` This script requires the following input
85+
86+
1. selected_ci: Jobs from where to fetch the builds.
87+
2. nightly: Name of the Release image.

aggregate.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
from tabulate import tabulate
2+
import re
3+
from datetime import datetime
4+
import monitor
5+
import configparser
6+
import argparse
7+
8+
config_vars = configparser.ConfigParser()
9+
config_vars.read('config.ini')
10+
11+
JENKINS = config_vars.get('Settings', 'JENKINS')
12+
13+
def get_nightly_name():
14+
if JENKINS == "False":
15+
nightly = input("Enter the name of nightly image: ")
16+
return nightly
17+
elif JENKINS == "True":
18+
nightly = config_vars.get('Settings', 'nightly')
19+
return nightly
20+
21+
def get_job_name():
22+
23+
'''
24+
Gets selected CI input.
25+
26+
Returns:
27+
dict: Dictionary of selected job name and job link
28+
'''
29+
30+
parser = argparse.ArgumentParser(description='Get the job history')
31+
parser.add_argument('--job_type', default='p', choices=['p','z','pa'], help= 'Specify the CI job type (Power(p) or s390x(z) or Power Auxillary(pa)), default is p')
32+
33+
args = parser.parse_args()
34+
35+
if args.job_type == 'p':
36+
config_file = 'p_periodic.json'
37+
elif args.job_type == 'z':
38+
config_file = 'z_periodic.json'
39+
elif args.job_type == 'pa':
40+
config_file = 'p_auxillary.json'
41+
42+
monitor.PROW_URL = monitor.set_prow_url(args.job_type)
43+
config_data = monitor.load_config(config_file)
44+
45+
j=0
46+
ci_name_list = []
47+
options_int_list = []
48+
selected_config_data = {}
49+
50+
if JENKINS == "False":
51+
for ci_name in config_data.keys():
52+
j=j+1
53+
ci_name_list.append(ci_name)
54+
print(j,'',ci_name)
55+
option = input("Select the required ci's serial number with a space ")
56+
selected_options = option.split()
57+
for ci in selected_options:
58+
try:
59+
ci_to_int = int(ci)
60+
if 0 < ci_to_int <= len(config_data):
61+
options_int_list.append(ci_to_int)
62+
else:
63+
return_value = "Enter the options in range of 1 to " + str(len(config_data)+1)
64+
print(return_value)
65+
return "ERROR"
66+
except ValueError:
67+
return "Enter valid options"
68+
elif JENKINS == "True":
69+
for ci_name in config_data.keys():
70+
j=j+1
71+
ci_name_list.append(ci_name)
72+
73+
selected_ci = config_vars.get('Settings', 'selected_ci')
74+
options_int_list = [int(value) for value in selected_ci.split(',')]
75+
76+
for i in options_int_list:
77+
config_temp_data = {ci_name_list[i-1]: config_data[ci_name_list[i-1]]}
78+
selected_config_data.update(config_temp_data)
79+
config_temp_data = {}
80+
81+
return selected_config_data
82+
83+
84+
def get_builds_with_same_nightly(job_name,nightly_image):
85+
builds=[]
86+
agg_builds = []
87+
pattern = r'\d{4}-\d{2}-\d{2}'
88+
match = re.search(pattern,nightly_image)
89+
90+
if match != None:
91+
date_str = match.group()
92+
nightly_date = datetime.strptime(date_str,"%Y-%m-%d").date()
93+
current_date = datetime.now().date()
94+
builds=monitor.get_jobs_with_date(job_name,current_date,nightly_date)
95+
for spylink in reversed(builds):
96+
ng = ""
97+
_, ng = monitor.get_quota_and_nightly(spylink)
98+
pattern_1 = r'\d{4}-\d{2}-\d{2}'
99+
match_1 = re.search(pattern_1,ng)
100+
if match_1 != None:
101+
date_str_1 = match_1.group()
102+
ng_date = datetime.strptime(date_str_1,"%Y-%m-%d").date()
103+
if ng_date > nightly_date:
104+
break
105+
else:
106+
if nightly_image in ng:
107+
agg_builds.append(spylink)
108+
else:
109+
continue
110+
return agg_builds
111+
112+
def main():
113+
nightly_image = get_nightly_name()
114+
selected_jobs = get_job_name()
115+
print("****************************************")
116+
print("Payload: ",nightly_image)
117+
print("****************************************")
118+
for job_name,job_link in selected_jobs.items():
119+
build_list = []
120+
build_list = get_builds_with_same_nightly(job_link,nightly_image)
121+
monitor.get_detailed_job_info(build_list,job_name)
122+
123+
if __name__ == "__main__":
124+
main()

config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ before_date = __BDATE__
55
after_date = __ADATE__
66
query_option = __QP__
77
tc_name = __TC__
8+
nightly = __NIGHTLY__

0 commit comments

Comments
 (0)