diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index e623ecb..6c7ede9 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -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.4" + tag: "0.8.5" image_name: "upstream-daily-tests" quay_application_token: ${{ secrets.QUAY_IMAGE_SCLORG_UPDATE_DESC }} diff --git a/Dockerfile.daily-tests b/Dockerfile.daily-tests index 82ac401..7a64c53 100644 --- a/Dockerfile.daily-tests +++ b/Dockerfile.daily-tests @@ -2,7 +2,7 @@ FROM quay.io/fedora/fedora:42 ENV SHARED_DIR="/var/ci-scripts" \ VERSION="42" \ - RELEASE_UPSTREAM="0.8.4" \ + RELEASE_UPSTREAM="0.8.5" \ UPSTREAM_TMT_REPO="https://github.com/sclorg/sclorg-testing-farm" \ UPSTREAM_TMT_DIR="sclorg-testing-farm" \ HOME="/home/nightly" \ @@ -22,8 +22,9 @@ RUN dnf install -y python3.13-pip git nss_wrapper && \ dnf clean all COPY requirements.sh requirements.txt "${WORK_DIR}" -RUN bash "${WORK_DIR}/requirements.sh" && pip3 install -r "${WORK_DIR}/requirements.txt" -# RUN cd "${WORK_DIR}" && git clone "${UPSTREAM_TMT_REPO}" "${UPSTREAM_TMT_DIR}" +RUN bash "${WORK_DIR}/requirements.sh" && pip3 install -r "${WORK_DIR}/requirements.txt" && \ + pip3 install pbincli + COPY . /root/ci-scripts WORKDIR "${HOME}" diff --git a/Makefile b/Makefile index 59ddc73..2b36540 100644 --- a/Makefile +++ b/Makefile @@ -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.4 -f Dockerfile.daily-tests . + podman build -t quay.io/sclorg/upstream-daily-tests:0.8.5 -f Dockerfile.daily-tests . diff --git a/daily_tests/daily_grades.py b/daily_tests/daily_grades.py index d02c9e3..b1f2ce8 100755 --- a/daily_tests/daily_grades.py +++ b/daily_tests/daily_grades.py @@ -126,17 +126,17 @@ def check_grades(self): ) def send_email(self): - grade_mails = os.getenv("GRADE_MAILS", "") + grade_mails = os.getenv("GRADE_MAILS", "").split(",") send_from = "phracek@redhat.com" self.mime_msg["From"] = send_from 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}") + print(f"MIME msg: {self.mime_msg}") self.mime_msg.attach(MIMEText(self.body, "html")) try: smtp = SMTP(smtp_server, int(smtp_port)) diff --git a/daily_tests/daily_nightly_tests_report.py b/daily_tests/daily_nightly_tests_report.py index 2390e11..8109fc3 100755 --- a/daily_tests/daily_nightly_tests_report.py +++ b/daily_tests/daily_nightly_tests_report.py @@ -191,14 +191,14 @@ def send_file_to_pastebin(self, log_path, log_name: Path): return cmd = f'{SEND_PASTE_BIN} "{log_path}" "{str(log_name)}"' print(f"sending logs to pastebin: {cmd}") - for count in range(5): + for _ in range(2): try: run_command(cmd) break except subprocess.CalledProcessError: print(f"ERROR: Sending to pastebin by command {cmd} failed") pass - time.sleep(3) + time.sleep(1) def get_pastebin_url(self, log_name: str) -> str: with open(log_name, "r") as f: @@ -267,10 +267,7 @@ def collect_data(self): if not path_dir.is_dir(): print(f"The test case {path_dir} does not exist that is weird") continue - plan_name = self.return_plan_name(plan) - print( - f"Path for test case {test_case} is: {path_dir} and plan name is: {plan_name}" - ) + print(f"Path for test case '{test_case}' is: '{path_dir}'") # It looks like TMT is still running for long time if (path_dir / "tmt_running").exists(): print(f"tmt tests for case {test_case} is still running.") @@ -350,6 +347,7 @@ def generate_email_body(self): print(f"Body to email: {self.body}") def generate_failed_containers(self): + print("GENERATE FAILED CONTAINERS") for test_case, plan, msg in self.available_test_case: if test_case not in self.data_dict: continue @@ -368,6 +366,7 @@ def generate_failed_containers(self): ) def generate_success_containers(self): + print("GENERATE SUCCESS CONTAINERS") for test_case, cont_path, log_name in self.data_dict["SUCCESS_DATA"]: if os.path.exists(log_name): self.body += ( diff --git a/daily_tests/download_logs.py b/daily_tests/download_logs.py index 18a9a80..e6fe2ef 100755 --- a/daily_tests/download_logs.py +++ b/daily_tests/download_logs.py @@ -82,22 +82,24 @@ def get_request_id(self) -> bool: print(f"Request ID: {self.request_id}") return True - def download_log(self, log_name_url: str, log_name: str = None) -> bool: + def download_log( + self, log_name_url: str, log_name: str = None, is_failed: bool = False + ) -> bool: """ Download a log from the Testing Farm. """ - for _ in range(5): - print(f"Downloading log: {log_name_url}") + for _ in range(2): + logfile_dir = self.log_dir / "results" if is_failed else self.log_dir + print(f"Downloading log '{log_name_url}' to '{logfile_dir}'") response = requests.get(log_name_url, verify=False) if response.status_code == 200: - with (self.log_dir / log_name).open("wb") as f: + with (logfile_dir / log_name).open("wb") as f: f.write(response.content) return True else: - print(f"Failed to download log: {response.status_code}") - time.sleep(3) # Wait before retrying + time.sleep(2) # Wait before retrying else: - print("Failed to download log after multiple attempts.") + print(f"Failed to download log {log_name_url} after multiple attempts.") return False def download_tmt_logs(self): @@ -131,7 +133,7 @@ def get_list_of_containers_logs(self, html_content: str): print(f"Failed to get list of failed containers: {e}") return False - def download_container_logs(self, failed: bool = False) -> bool: + def download_container_logs(self, is_failed: bool = False) -> bool: """ Download the failed container logs from the Testing Farm. """ @@ -139,7 +141,7 @@ def download_container_logs(self, failed: bool = False) -> bool: print("Data directory URL link not found.") return False url_link = self.data_dir_url_link - if failed: + if is_failed: url_link += "/results" print(f"Data directory URL link: {url_link}") @@ -150,7 +152,9 @@ def download_container_logs(self, failed: bool = False) -> bool: print(f"Failed to download data/results directory: {response.status_code}") return False for cont in CONTAINERS: - self.download_log(f"{url_link}/{cont}.log", f"{cont}.log") + self.download_log( + f"{url_link}/{cont}.log", f"{cont}.log", is_failed=is_failed + ) return True def get_xml_report(self) -> bool: @@ -162,14 +166,13 @@ def get_xml_report(self) -> bool: else: xml_report_url = f"{REPORTS_PRIVATE_URL}/{self.request_id}/results.xml" print(f"XML Report URL: {xml_report_url}") - for _ in range(5): + for _ in range(2): response = requests.get(xml_report_url, verify=False) if response.status_code == 200: self.xml_dict = xmltodict.parse(response.content) break else: - print(f"Failed to download XML report: {response.status_code}") - time.sleep(3) # Wait before retrying + time.sleep(2) # Wait before retrying else: print("Failed to download XML report after multiple attempts.") return False @@ -194,4 +197,4 @@ def get_xml_report(self) -> bool: sys.exit(1) downloader.download_tmt_logs() downloader.download_container_logs() - downloader.download_container_logs(failed=True) + downloader.download_container_logs(is_failed=True)