Skip to content
Draft
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
25 changes: 23 additions & 2 deletions src/csm_testing/tests/sat_functional/bootprep/test_bootprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import subprocess
import tempfile
from typing import List
from datetime import datetime
import unittest

import requests
Expand Down Expand Up @@ -686,8 +687,8 @@ def delete_all_ims_jobs_matching_prefix(cls):
for job in jobs_json:
archive_name = job.get('image_root_archive_name', '')
if archive_name.startswith(cls.test_prefix):
if job.get('status') == 'error':
logging.warning('Skipping deletion of IMS job with ID %s, to allow for debugging', job.get('id'))
if job.get('status') == 'error' and cls.days_since(job.get('created')) <= 7:
logging.warning('Skipping deletion of IMS job with ID %s, to allow for potential debugging, this job will be cleaned up by a subequent test run after 7 days.', job.get('id'))
continue
try:
found_job_ids.append(job['id'])
Expand Down Expand Up @@ -988,6 +989,26 @@ def copy_to_tmp_dir(cls, bootprep_file, dest_folder):
tmp_bootprep_file_path = os.path.join(cls.temp_dir.name, dest_folder, os.path.basename(bootprep_file))
shutil.copy(src_bootprep_file_path, tmp_bootprep_file_path)

@staticmethod
def days_since(date_str):
"""Returns number of days since a given date string

Args:
date_str: date string in the format "2025-12-13T23:37:58.357683"

Returns:
int: number of days since the given date_str or 0 if unable to parse.
"""

try:
date = datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S.%f').date()
current_date = datetime.today().date()
except ValueError as e:
logging.warning("Unable to parse date string: %s, with error %s returning 0", date_str, e)
return 0

return (current_date - date).days

@classmethod
def check_sle_products_availability(cls):
"""Check if the required SLE products are available in the product catalog.
Expand Down