From 73caac2c5e22c1fd8d59872fdc39d60bf3c3fdd7 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Tue, 27 Oct 2026 18:25:47 -0300 Subject: [PATCH] Fix flaky test on test_cdn_cache_validation aiohttp.FileResponse replaces Pulp's last modified with the last modified timestamp of the file stats. Not only that, but it rounds to the NEXT second, which caused the last modified to be in the future! This behavior is problematic, so this commits points to a more broad issue about it and applies a workaround to avoid the flaky test. --- .../api/using_plugin/test_cdn_cache_validation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pulpcore/tests/functional/api/using_plugin/test_cdn_cache_validation.py b/pulpcore/tests/functional/api/using_plugin/test_cdn_cache_validation.py index 7edba772c1..9e62ed3f58 100644 --- a/pulpcore/tests/functional/api/using_plugin/test_cdn_cache_validation.py +++ b/pulpcore/tests/functional/api/using_plugin/test_cdn_cache_validation.py @@ -7,6 +7,7 @@ import time from base64 import b64encode +from math import ceil from urllib.parse import urljoin from uuid import uuid4 @@ -26,10 +27,12 @@ def assert_full_download(response): assert response.status_code == 200 assert response.content assert response.headers.get("Cache-Control") == EDGE_CACHE_CONTROL - # Last-Modified must be a real date in the past - never missing, epoch, or in the future + # aiohttp.FileResponse rounds fractional file mtimes up to the next second for Last-Modified. + # See: https://github.com/pulp/pulpcore/issues/8293 + rounded_now = ceil(time.time()) last_modified = response.headers.get("Last-Modified") assert last_modified - assert 0 < parse_http_date(last_modified) <= time.time() + assert 0 < parse_http_date(last_modified) <= rounded_now def assert_not_modified(response):