Skip to content

Commit b2ad452

Browse files
committed
Fix grade calling.
Store logs to results directory. Print more debug information Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
1 parent 78294a9 commit b2ad452

6 files changed

Lines changed: 30 additions & 27 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
registry_username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
2020
registry_token: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
2121
dockerfile: Dockerfile.daily-tests
22-
tag: "0.8.4"
22+
tag: "0.8.5"
2323
image_name: "upstream-daily-tests"
2424
quay_application_token: ${{ secrets.QUAY_IMAGE_SCLORG_UPDATE_DESC }}

Dockerfile.daily-tests

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM quay.io/fedora/fedora:42
22

33
ENV SHARED_DIR="/var/ci-scripts" \
44
VERSION="42" \
5-
RELEASE_UPSTREAM="0.8.4" \
5+
RELEASE_UPSTREAM="0.8.5" \
66
UPSTREAM_TMT_REPO="https://github.com/sclorg/sclorg-testing-farm" \
77
UPSTREAM_TMT_DIR="sclorg-testing-farm" \
88
HOME="/home/nightly" \
@@ -22,8 +22,9 @@ RUN dnf install -y python3.13-pip git nss_wrapper && \
2222
dnf clean all
2323

2424
COPY requirements.sh requirements.txt "${WORK_DIR}"
25-
RUN bash "${WORK_DIR}/requirements.sh" && pip3 install -r "${WORK_DIR}/requirements.txt"
26-
# RUN cd "${WORK_DIR}" && git clone "${UPSTREAM_TMT_REPO}" "${UPSTREAM_TMT_DIR}"
25+
RUN bash "${WORK_DIR}/requirements.sh" && pip3 install -r "${WORK_DIR}/requirements.txt" && \
26+
pip3 install pbincli
27+
2728

2829
COPY . /root/ci-scripts
2930
WORKDIR "${HOME}"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ shellcheck:
77
./run-shellcheck.sh `git ls-files *.sh`
88

99
build_images:
10-
podman build -t quay.io/sclorg/upstream-daily-tests:0.8.4 -f Dockerfile.daily-tests .
10+
podman build -t quay.io/sclorg/upstream-daily-tests:0.8.5 -f Dockerfile.daily-tests .

daily_tests/daily_grades.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ def check_grades(self):
126126
)
127127

128128
def send_email(self):
129-
grade_mails = os.getenv("GRADE_MAILS", "")
129+
grade_mails = os.getenv("GRADE_MAILS", "").split(",")
130130
send_from = "phracek@redhat.com"
131131
self.mime_msg["From"] = send_from
132132
self.mime_msg["To"] = ", ".join(grade_mails)
133133
self.mime_msg[
134134
"Subject"
135135
] = "[CS Image Grading] Container Grades of Apps&Stack images for RHEL8, RHEL9 and RHEL10"
136-
print(f"Sending grades from {send_from} to {grade_mails}")
137136
smtp_server = os.getenv("SMTP_SERVER", "smtp.redhat.com")
138137
smtp_port = int(os.getenv("SMTP_PORT", "25"))
139138
print(f"SMTP server is: {smtp_server} and port: {smtp_port}")
139+
print(f"MIME msg: {self.mime_msg}")
140140
self.mime_msg.attach(MIMEText(self.body, "html"))
141141
try:
142142
smtp = SMTP(smtp_server, int(smtp_port))

daily_tests/daily_nightly_tests_report.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ def send_file_to_pastebin(self, log_path, log_name: Path):
191191
return
192192
cmd = f'{SEND_PASTE_BIN} "{log_path}" "{str(log_name)}"'
193193
print(f"sending logs to pastebin: {cmd}")
194-
for count in range(5):
194+
for _ in range(2):
195195
try:
196196
run_command(cmd)
197197
break
198198
except subprocess.CalledProcessError:
199199
print(f"ERROR: Sending to pastebin by command {cmd} failed")
200200
pass
201-
time.sleep(3)
201+
time.sleep(1)
202202

203203
def get_pastebin_url(self, log_name: str) -> str:
204204
with open(log_name, "r") as f:
@@ -267,10 +267,7 @@ def collect_data(self):
267267
if not path_dir.is_dir():
268268
print(f"The test case {path_dir} does not exist that is weird")
269269
continue
270-
plan_name = self.return_plan_name(plan)
271-
print(
272-
f"Path for test case {test_case} is: {path_dir} and plan name is: {plan_name}"
273-
)
270+
print(f"Path for test case '{test_case}' is: '{path_dir}'")
274271
# It looks like TMT is still running for long time
275272
if (path_dir / "tmt_running").exists():
276273
print(f"tmt tests for case {test_case} is still running.")
@@ -350,6 +347,7 @@ def generate_email_body(self):
350347
print(f"Body to email: {self.body}")
351348

352349
def generate_failed_containers(self):
350+
print("GENERATE FAILED CONTAINERS")
353351
for test_case, plan, msg in self.available_test_case:
354352
if test_case not in self.data_dict:
355353
continue
@@ -368,6 +366,7 @@ def generate_failed_containers(self):
368366
)
369367

370368
def generate_success_containers(self):
369+
print("GENERATE SUCCESS CONTAINERS")
371370
for test_case, cont_path, log_name in self.data_dict["SUCCESS_DATA"]:
372371
if os.path.exists(log_name):
373372
self.body += (

daily_tests/download_logs.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,24 @@ def get_request_id(self) -> bool:
8282
print(f"Request ID: {self.request_id}")
8383
return True
8484

85-
def download_log(self, log_name_url: str, log_name: str = None) -> bool:
85+
def download_log(
86+
self, log_name_url: str, log_name: str = None, is_failed: bool = False
87+
) -> bool:
8688
"""
8789
Download a log from the Testing Farm.
8890
"""
89-
for _ in range(5):
90-
print(f"Downloading log: {log_name_url}")
91+
for _ in range(2):
92+
logfile_dir = self.log_dir / "results" if is_failed else self.log_dir
93+
print(f"Downloading log '{log_name_url}' to '{logfile_dir}'")
9194
response = requests.get(log_name_url, verify=False)
9295
if response.status_code == 200:
93-
with (self.log_dir / log_name).open("wb") as f:
96+
with (logfile_dir / log_name).open("wb") as f:
9497
f.write(response.content)
9598
return True
9699
else:
97-
print(f"Failed to download log: {response.status_code}")
98-
time.sleep(3) # Wait before retrying
100+
time.sleep(2) # Wait before retrying
99101
else:
100-
print("Failed to download log after multiple attempts.")
102+
print(f"Failed to download log {log_name_url} after multiple attempts.")
101103
return False
102104

103105
def download_tmt_logs(self):
@@ -131,15 +133,15 @@ def get_list_of_containers_logs(self, html_content: str):
131133
print(f"Failed to get list of failed containers: {e}")
132134
return False
133135

134-
def download_container_logs(self, failed: bool = False) -> bool:
136+
def download_container_logs(self, is_failed: bool = False) -> bool:
135137
"""
136138
Download the failed container logs from the Testing Farm.
137139
"""
138140
if not self.data_dir_url_link:
139141
print("Data directory URL link not found.")
140142
return False
141143
url_link = self.data_dir_url_link
142-
if failed:
144+
if is_failed:
143145
url_link += "/results"
144146

145147
print(f"Data directory URL link: {url_link}")
@@ -150,7 +152,9 @@ def download_container_logs(self, failed: bool = False) -> bool:
150152
print(f"Failed to download data/results directory: {response.status_code}")
151153
return False
152154
for cont in CONTAINERS:
153-
self.download_log(f"{url_link}/{cont}.log", f"{cont}.log")
155+
self.download_log(
156+
f"{url_link}/{cont}.log", f"{cont}.log", is_failed=is_failed
157+
)
154158
return True
155159

156160
def get_xml_report(self) -> bool:
@@ -162,14 +166,13 @@ def get_xml_report(self) -> bool:
162166
else:
163167
xml_report_url = f"{REPORTS_PRIVATE_URL}/{self.request_id}/results.xml"
164168
print(f"XML Report URL: {xml_report_url}")
165-
for _ in range(5):
169+
for _ in range(2):
166170
response = requests.get(xml_report_url, verify=False)
167171
if response.status_code == 200:
168172
self.xml_dict = xmltodict.parse(response.content)
169173
break
170174
else:
171-
print(f"Failed to download XML report: {response.status_code}")
172-
time.sleep(3) # Wait before retrying
175+
time.sleep(2) # Wait before retrying
173176
else:
174177
print("Failed to download XML report after multiple attempts.")
175178
return False
@@ -194,4 +197,4 @@ def get_xml_report(self) -> bool:
194197
sys.exit(1)
195198
downloader.download_tmt_logs()
196199
downloader.download_container_logs()
197-
downloader.download_container_logs(failed=True)
200+
downloader.download_container_logs(is_failed=True)

0 commit comments

Comments
 (0)