qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PULL 04/10] tests/functional: Set current time stamp of assets when using them
Date: Thu, 16 Oct 2025 18:25:55 +0200	[thread overview]
Message-ID: <20251016162601.442557-5-thuth@redhat.com> (raw)
In-Reply-To: <20251016162601.442557-1-thuth@redhat.com>

From: Thomas Huth <thuth@redhat.com>

We are going to remove obsolete assets from the cache, so keep
the time stamps of the assets that we use up-to-date to have a way
to detect stale assets later.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251014083424.103202-2-thuth@redhat.com>
---
 tests/functional/qemu_test/asset.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index f666125bfaf..ab3a7bb591d 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -10,6 +10,7 @@
 import os
 import stat
 import sys
+import time
 import unittest
 import urllib.request
 from time import sleep
@@ -113,6 +114,16 @@ def _wait_for_other_download(self, tmp_cache_file):
         self.log.debug("Time out while waiting for %s!", tmp_cache_file)
         raise
 
+    def _save_time_stamp(self):
+        '''
+        Update the time stamp of the asset in the cache. Unfortunately, we
+        cannot use the modification or access time of the asset file itself,
+        since e.g. the functional jobs in the gitlab CI reload the files
+        from the gitlab cache and thus always have recent file time stamps,
+        so we have to save our asset time stamp to a separate file instead.
+        '''
+        self.cache_file.with_suffix(".stamp").write_text(f"{int(time.time())}")
+
     def fetch(self):
         if not self.cache_dir.exists():
             self.cache_dir.mkdir(parents=True, exist_ok=True)
@@ -120,6 +131,7 @@ def fetch(self):
         if self.valid():
             self.log.debug("Using cached asset %s for %s",
                            self.cache_file, self.url)
+            self._save_time_stamp()
             return str(self.cache_file)
 
         if not self.fetchable():
@@ -208,6 +220,7 @@ def fetch(self):
             tmp_cache_file.unlink()
             raise AssetError(self, "Hash does not match %s" % self.hash)
         tmp_cache_file.replace(self.cache_file)
+        self._save_time_stamp()
         # Remove write perms to stop tests accidentally modifying them
         os.chmod(self.cache_file, stat.S_IRUSR | stat.S_IRGRP)
 
-- 
2.51.0



  parent reply	other threads:[~2025-10-16 16:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 16:25 [PULL 00/10] Various testing and s390x patches Thomas Huth
2025-10-16 16:25 ` [PULL 01/10] python/qemu: Replace some remaining "avocados" with "functional tests" Thomas Huth
2025-10-16 16:25 ` [PULL 02/10] tests/functional/aarch64: Drop some sbsaref_alpine tests Thomas Huth
2025-10-16 16:25 ` [PULL 03/10] gitlab: purge msys pacman cache Thomas Huth
2025-10-16 16:25 ` Thomas Huth [this message]
2025-10-16 16:25 ` [PULL 05/10] tests: Evict stale files in the functional download cache after a while Thomas Huth
2025-10-16 16:25 ` [PULL 06/10] tests/functional/alpha: Remove superfluous fetch() line from the clipper test Thomas Huth
2025-10-16 16:25 ` [PULL 07/10] tests/functional: remove use of getLogger in reverse debuging Thomas Huth
2025-10-16 16:25 ` [PULL 08/10] tests/functional: ensure GDB client is stopped on error Thomas Huth
2025-10-16 16:26 ` [PULL 09/10] target/s390x/mmu_helper: Simplify s390_cpu_virt_mem_rw() logic Thomas Huth
2025-10-16 16:26 ` [PULL 10/10] target/s390x/mmu_helper: Do not ignore address_space_rw() errors Thomas Huth
2025-10-17 15:12 ` [PULL 00/10] Various testing and s390x patches Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251016162601.442557-5-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).