-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAWS_TIMEOUTS
executable file
·85 lines (71 loc) · 2.81 KB
/
AWS_TIMEOUTS
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
import re
import requests
import dateutil.parser
import datetime
MAX_HOURS = 72
def show_durations(lines):
cur_target_name = None
target_started_at = None
whole_duration = datetime.timedelta()
expectation = datetime.timedelta(minutes=10)
for line in lines:
m = re.match(
r"(?P<date>^2\d\d\d-\d\d-\d\d [\d:]+.\d+)\s\|\s\S+\s\|\stask path.*tests/integration/targets/(?P<target>\w+)/tasks",
line,
)
if not m:
continue
fields = m.groupdict()
date = datetime.datetime.strptime(fields["date"], "%Y-%m-%d %H:%M:%S.%f")
target = fields["target"]
if not cur_target_name:
cur_target_name = target
target_started_at = date
elif cur_target_name != target or "RESULT_TIMED_OUT" in line:
duration = date - target_started_at
whole_duration += duration
if duration > expectation:
print(
f" 🎯 {cur_target_name} lasted {int(duration.total_seconds())} seconds, from {target_started_at.strftime('%H:%M:%S')} to {date.strftime('%H:%M:%S')}."
)
if cur_target_name == "setup_remote_tmp_dir":
print("⚠️ setup_remote_tmp_dir is just a wrapper.")
cur_target_name = target
target_started_at = date
else:
continue
print(f" ⌛ All the targets took {whole_duration} to run.")
def iter_builds():
jobs = [
"ansible-test-cloud-integration-aws-py36_0",
"ansible-test-cloud-integration-aws-py36_1",
"ansible-test-cloud-integration-aws-py36_2",
"ansible-test-cloud-integration-aws-py36_3",
"ansible-test-cloud-integration-aws-py36_4",
"ansible-test-cloud-integration-aws-py36_5",
"ansible-test-cloud-integration-aws-py36_6",
"ansible-test-cloud-integration-aws-py36_7",
"ansible-test-cloud-integration-aws-py36_8",
"ansible-test-cloud-integration-aws-py36_9",
]
for job in jobs:
url = f"https://dashboard.zuul.ansible.com/api/tenant/ansible/builds?job_name={job}&limit=30"
r = requests.get(url)
builds = r.json()
for build in builds:
yield build
print(f"Looking for AWS jobs that timeouted during the last {MAX_HOURS} hours...")
for build in iter_builds():
delta = datetime.datetime.now(datetime.timezone.utc) - dateutil.parser.parse(
build["end_time"] + "Z"
)
age = int(delta.total_seconds() / 3600)
if age > MAX_HOURS:
continue
if build["result"] != "TIMED_OUT":
continue
job_output_url = f"{build['log_url']}/job-output.txt"
print(f"🧪 Log URL: {job_output_url}")
r_content = requests.get(job_output_url)
show_durations(r_content.text.split("\n"))