Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
registry_username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
registry_token: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
dockerfile: Dockerfile.daily-tests
tag: "0.8.3"
tag: "0.8.4"
image_name: "upstream-daily-tests"
quay_application_token: ${{ secrets.QUAY_IMAGE_SCLORG_UPDATE_DESC }}
2 changes: 1 addition & 1 deletion Dockerfile.daily-tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM quay.io/fedora/fedora:42

ENV SHARED_DIR="/var/ci-scripts" \
VERSION="42" \
RELEASE_UPSTREAM="0.8.3" \
RELEASE_UPSTREAM="0.8.4" \
UPSTREAM_TMT_REPO="https://github.com/sclorg/sclorg-testing-farm" \
UPSTREAM_TMT_DIR="sclorg-testing-farm" \
HOME="/home/nightly" \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ shellcheck:
./run-shellcheck.sh `git ls-files *.sh`

build_images:
podman build -t quay.io/sclorg/upstream-daily-tests:0.8.3 -f Dockerfile.daily-tests .
podman build -t quay.io/sclorg/upstream-daily-tests:0.8.4 -f Dockerfile.daily-tests .
34 changes: 20 additions & 14 deletions daily_tests/daily_grades.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#!/usr/bin/env python3
import os
import sys
import smtplib
import subprocess
import smtplib

from smtplib import SMTP
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from pathlib import Path
from typing import Dict

from rh_cwt.main import RhelImageRebuilder

default_mails = [
"phracek@redhat.com",
"hhorak@redhat.com",
"pkubat@redhat.com",
"anezbeda@redhat.com",
"rhscl-container-qe@redhat.com",
"oksenzov@redhat.com",
"mzidek@redhat.com",
]

GRADES_OS_DICT = {"RHEL8": "rhel8.yaml", "RHEL9": "rhel9.yaml", "RHEL10": "rhel10.yaml"}

Expand Down Expand Up @@ -134,16 +126,30 @@ def check_grades(self):
)

def send_email(self):
grade_mails = os.getenv("GRADE_MAILS", "")
send_from = "phracek@redhat.com"
self.mime_msg["From"] = send_from
self.mime_msg["To"] = ", ".join(default_mails)
self.mime_msg["To"] = ", ".join(grade_mails)
self.mime_msg[
"Subject"
] = "[CS Image Grading] Container Grades of Apps&Stack images for RHEL8, RHEL9 and RHEL10"
print(f"Sending grades from {send_from} to {grade_mails}")
smtp_server = os.getenv("SMTP_SERVER", "smtp.redhat.com")
smtp_port = int(os.getenv("SMTP_PORT", "25"))
print(f"SMTP server is: {smtp_server} and port: {smtp_port}")
self.mime_msg.attach(MIMEText(self.body, "html"))
smtp = smtplib.SMTP("127.0.0.1")
smtp.sendmail(send_from, default_mails, self.mime_msg.as_string())
smtp.close()
try:
smtp = SMTP(smtp_server, int(smtp_port))
smtp.set_debuglevel(5)
smtp.sendmail(send_from, grade_mails, self.mime_msg.as_string())
except smtplib.SMTPRecipientsRefused as e:
print(f"Error sending email(SMTPRecipientsRefused): {e.strerror}")
except smtplib.SMTPException as e:
print(f"Error sending email(SMTPException): {e}")
except ConnectionRefusedError as e:
print(f"Error sending email(ConnectionRefusedError): {e}")
finally:
smtp.close()
print("Sending email finished")


Expand Down
89 changes: 0 additions & 89 deletions daily_tests/daily_grades.sh

This file was deleted.

9 changes: 5 additions & 4 deletions daily_tests/daily_nightly_tests_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
("c10s-test-pytest", "nightly-c10s", "CentOS Stream 10 PyTest test results:"),
("rhel8-test", "nightly-rhel8", "RHEL-8 test results:"),
("rhel8-test-pytest", "nightly-rhel8", "RHEL-8 PyTest test results:"),
("rhel8-test-openshift-4", "nightly-rhel8", "RHEL-8 OpenShift 4 test results:"),
(
"rhel8-test-openshift-pytest",
"nightly-rhel8",
"RHEL-8 PyTest in OpenShift 4 test results:",
),
("rhel9-test", "nightly-rhel9", "RHEL-9 test results:"),
("rhel9-test-pytest", "nightly-rhel9", "RHEL-9 PyTest test results:"),
("rhel9-test-openshift-4", "nightly-rhel9", "RHEL-9 OpenShift 4 test results:"),
(
"rhel9-test-openshift-pytest",
"nightly-rhel9",
Expand All @@ -45,7 +43,6 @@
("rhel9-helm-charts", "nightly-rhel9", "RHEL-9 Helm Charts test results:"),
("rhel10-test", "nightly-rhel10", "RHEL-10 test results:"),
("rhel10-test-pytest", "nightly-rhel10", "RHEL-10 PyTest test results:"),
("rhel10-test-openshift-4", "nightly-rhel10", "RHEL-10 OpenShift 4 test results:"),
(
"rhel10-test-openshift-pytest",
"nightly-rhel10",
Expand Down Expand Up @@ -297,6 +294,11 @@ def collect_data(self):
self.data_dict["SUCCESS"].append(test_case)
if self.args.upstream_tests:
success_logs = list((path_dir).rglob("*.log"))
print(success_logs)
for suc in success_logs:
self.store_tmt_logs_to_dict(
path_dir=path_dir, test_case=test_case
)
self.data_dict["SUCCESS_DATA"].extend(
[(test_case, str(f), str(f.name)) for f in success_logs]
)
Expand Down Expand Up @@ -367,7 +369,6 @@ def generate_failed_containers(self):

def generate_success_containers(self):
for test_case, cont_path, log_name in self.data_dict["SUCCESS_DATA"]:
print(f"generate_success_containers: {self.data_dict[test_case]}")
if os.path.exists(log_name):
self.body += (
f" <a href='{self.get_pastebin_url(log_name=log_name)}'>See logs</a>"
Expand Down
16 changes: 0 additions & 16 deletions daily_tests/tests/test_daily_grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,3 @@ def test_check_grades_builds_body(report):
assert "php [C] 3 days since grade C!" in report.body
assert "python [D] 2 days last grade change!" in report.body
assert "The rest of images are in grade A." in report.body


def test_send_email_uses_smtp(report, smtp_spy):
report.body = "<b>Report</b>"

report.send_email()

assert smtp_spy
instance = smtp_spy[0]
assert instance.host == "127.0.0.1"
assert instance.closed is True
assert instance.sent
send_from, send_to, msg = instance.sent[0]
assert send_from == "phracek@redhat.com"
assert "Container Grades" in msg
assert ", ".join(send_to) in msg