Skip to contentSkip to conversation

tests/functional: misc fixes to functional test suite

PATCH In review Daniel P. Berrangé 6 participants 22 messages Nov 20 – Nov 23

lore
Share & tools
lore
#0 lore raw

cover tests/functional: misc fixes to functional test suite

The first 4 patches fix failures to download a number of assets whose URLs have been deleted, or moved, content regenerated, or put behind anubis.

They will need to go to the pending 11.2 release and stable branches too.

The remaining patches are bug fixes except for the very last patch. Those can likely all wait until 12.0, but cherry-picking some of them into stable would be reasonable if desired.

After this series is applied we have one unresolvable problem with assets for MIPS, the yamon-bin-02.22.zip file hosted on AWS is throwing an error about using the wrong endpoint, but I can't figure out what the right one is (if any).

Daniel P. Berrangé (12):
tests/functional: update to newer sunxi kernel package tests/functional: update sha digests for tuxrun kernels tests/functional: update URL to rs6000 firmware tests/functional: add Accept header when downloading assets tests/functional: check if we are served an Anubis challenge tests/functional: don't write timestamp unless successful tests/functional: delete tmp file on interrupt tests/functional: honour make jobs in precache tests/functional: don't display stack trace on download fail tests/functional: always raise AssetError when download fails tests/functional: only run pre-cache once per class tests/functional: optionally display download progress

 docs/devel/testing/functional.rst       |  6 ++
 tests/Makefile.include                  |  2 +-
 tests/functional/aarch64/test_tuxrun.py |  4 +-
 tests/functional/arm/test_bpim2u.py     | 19 +++---
 tests/functional/arm/test_cubieboard.py | 15 ++---
 tests/functional/arm/test_orangepi.py   | 19 +++---
 tests/functional/arm/test_replay.py     | 12 ++--
 tests/functional/ppc/test_40p.py        |  3 +-
 tests/functional/qemu_test/asset.py     | 83 ++++++++++++++++++++-----
 tests/functional/qemu_test/testcase.py  |  8 ++-
 tests/functional/s390x/test_tuxrun.py   |  4 +-
 tests/functional/x86_64/test_tuxrun.py  |  4 +-
 12 files changed, 123 insertions(+), 56 deletions(-)
Signature · 1 line
2.56.1
#1 lore raw

PATCH 1/12 tests/functional: update to newer sunxi kernel package

The version we currently reference has been deleted from the the apt.armbian.com host. 6.6.44 is the next oldest build that is available.

---
 tests/functional/arm/test_bpim2u.py     | 19 ++++++++++---------
 tests/functional/arm/test_cubieboard.py | 15 ++++++++-------
 tests/functional/arm/test_orangepi.py   | 19 ++++++++++---------
 tests/functional/arm/test_replay.py     | 12 ++++++------
 4 files changed, 34 insertions(+), 31 deletions(-)
tests/functional/arm/test_bpim2u.py +10 -9
index 9192a2fbec4..e6fd80ae9d0 100755
@@ -14,9 +14,10 @@
 class BananaPiMachine(LinuxKernelTest):
 
     ASSET_DEB = Asset(
-        ('https://apt.armbian.com/pool/main/l/linux-6.6.16/'
-         'linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb'),
-        '3d968c15b121ede871dce49d13ee7644d6f74b6b121b84c9a40f51b0c80d6d22')
+        ('https://apt.armbian.com/pool/main/l/linux-6.6.44/'
+         'linux-image-current-sunxi_24.8.2_armhf__6.6.44-'
+         'S7213-D53de-P4ceb-C697eH5c21-HK01ba-V014b-B58e9-R448a.deb'),
+        'd960131bed01a8bf48882ff133a37826dfdce84138f9a82e0bea331ba795fe78')
 
     ASSET_INITRD = Asset(
         ('https://github.com/groeck/linux-build-test/raw/'
@@ -37,8 +38,8 @@ class BananaPiMachine(LinuxKernelTest):
     def test_arm_bpim2u(self):
         self.set_machine('bpim2u')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/'
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/'
                     'sun8i-r40-bananapi-m2-ultra.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
 
@@ -56,8 +57,8 @@ def test_arm_bpim2u(self):
     def test_arm_bpim2u_initrd(self):
         self.set_machine('bpim2u')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/'
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/'
                     'sun8i-r40-bananapi-m2-ultra.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
         initrd_path = self.uncompress(self.ASSET_INITRD)
@@ -89,8 +90,8 @@ def test_arm_bpim2u_gmac(self):
 
         deb_path = self.ASSET_DEB.fetch()
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/'
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/'
                     'sun8i-r40-bananapi-m2-ultra.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
         rootfs_path = self.uncompress(self.ASSET_ROOTFS)
tests/functional/arm/test_cubieboard.py +8 -7
index b536c2f77a0..eeafc26f90d 100755
@@ -13,9 +13,10 @@
 class CubieboardMachine(LinuxKernelTest):
 
     ASSET_DEB = Asset(
-        ('https://apt.armbian.com/pool/main/l/linux-6.6.16/'
-         'linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb'),
-        '3d968c15b121ede871dce49d13ee7644d6f74b6b121b84c9a40f51b0c80d6d22')
+        ('https://apt.armbian.com/pool/main/l/linux-6.6.44/'
+         'linux-image-current-sunxi_24.8.2_armhf__6.6.44-'
+         'S7213-D53de-P4ceb-C697eH5c21-HK01ba-V014b-B58e9-R448a.deb'),
+        'd960131bed01a8bf48882ff133a37826dfdce84138f9a82e0bea331ba795fe78')
 
     ASSET_INITRD = Asset(
         ('https://github.com/groeck/linux-build-test/raw/'
@@ -37,8 +38,8 @@ class CubieboardMachine(LinuxKernelTest):
     def test_arm_cubieboard_initrd(self):
         self.set_machine('cubieboard')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/' +
                     'sun4i-a10-cubieboard.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
         initrd_path = self.uncompress(self.ASSET_INITRD)
@@ -68,8 +69,8 @@ def test_arm_cubieboard_initrd(self):
     def test_arm_cubieboard_sata(self):
         self.set_machine('cubieboard')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/' +
                     'sun4i-a10-cubieboard.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
 
tests/functional/arm/test_orangepi.py +10 -9
index 09780236553..c9cfdbd67aa 100755
@@ -16,9 +16,10 @@
 class OrangePiMachine(LinuxKernelTest):
 
     ASSET_DEB = Asset(
-        ('https://apt.armbian.com/pool/main/l/linux-6.6.16/'
-         'linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb'),
-        '3d968c15b121ede871dce49d13ee7644d6f74b6b121b84c9a40f51b0c80d6d22')
+        ('https://apt.armbian.com/pool/main/l/linux-6.6.44/'
+         'linux-image-current-sunxi_24.8.2_armhf__6.6.44-'
+         'S7213-D53de-P4ceb-C697eH5c21-HK01ba-V014b-B58e9-R448a.deb'),
+        'd960131bed01a8bf48882ff133a37826dfdce84138f9a82e0bea331ba795fe78')
 
     ASSET_INITRD = Asset(
         ('https://github.com/groeck/linux-build-test/raw/'
@@ -49,8 +50,8 @@ class OrangePiMachine(LinuxKernelTest):
     def test_arm_orangepi(self):
         self.set_machine('orangepi-pc')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/' +
                     'sun8i-h3-orangepi-pc.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
 
@@ -68,8 +69,8 @@ def test_arm_orangepi(self):
     def test_arm_orangepi_initrd(self):
         self.set_machine('orangepi-pc')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/' +
                     'sun8i-h3-orangepi-pc.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
         initrd_path = self.uncompress(self.ASSET_INITRD)
@@ -99,8 +100,8 @@ def test_arm_orangepi_sd(self):
         self.set_machine('orangepi-pc')
         self.require_netdev('user')
         kernel_path = self.archive_extract(
-            self.ASSET_DEB, member='boot/vmlinuz-6.6.16-current-sunxi')
-        dtb_path = ('usr/lib/linux-image-6.6.16-current-sunxi/' +
+            self.ASSET_DEB, member='boot/vmlinuz-6.6.44-current-sunxi')
+        dtb_path = ('usr/lib/linux-image-6.6.44-current-sunxi/' +
                     'sun8i-h3-orangepi-pc.dtb')
         dtb_path = self.archive_extract(self.ASSET_DEB, member=dtb_path)
         rootfs_path = self.uncompress(self.ASSET_ROOTFS)
tests/functional/arm/test_replay.py +6 -6
index e002e6a2647..ee61f475930 100755
@@ -24,10 +24,10 @@ def test_virt(self):
         self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
 
     ASSET_CUBIE_KERNEL = Asset(
-        ('https://apt.armbian.com/pool/main/l/linux-6.6.16/'
-         'linux-image-current-sunxi_24.2.1_armhf_'
-         '_6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb'),
-        '3d968c15b121ede871dce49d13ee7644d6f74b6b121b84c9a40f51b0c80d6d22')
+        ('https://apt.armbian.com/pool/main/l/linux-6.6.44/'
+         'linux-image-current-sunxi_24.8.2_armhf__6.6.44-'
+         'S7213-D53de-P4ceb-C697eH5c21-HK01ba-V014b-B58e9-R448a.deb'),
+        'd960131bed01a8bf48882ff133a37826dfdce84138f9a82e0bea331ba795fe78')
 
     ASSET_CUBIE_INITRD = Asset(
         ('https://github.com/groeck/linux-build-test/raw/'
@@ -37,9 +37,9 @@ def test_virt(self):
     def test_cubieboard(self):
         self.set_machine('cubieboard')
         kernel_path = self.archive_extract(self.ASSET_CUBIE_KERNEL,
-            member='boot/vmlinuz-6.6.16-current-sunxi')
+            member='boot/vmlinuz-6.6.44-current-sunxi')
         dtb_path = self.archive_extract(self.ASSET_CUBIE_KERNEL,
-            member='usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb')
+            member='usr/lib/linux-image-6.6.44-current-sunxi/sun4i-a10-cubieboard.dtb')
         initrd_path = self.uncompress(self.ASSET_CUBIE_INITRD)
 
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
Signature · 1 line
2.56.1
#7 lore raw

PATCH 3/12 tests/functional: update URL to rs6000 firmware

In reply to Daniel P. Berrangé

The current mirror URL is throwing permission denied errors, so switch to an alternate site discoverd via Google.

---
 tests/functional/ppc/test_40p.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/functional/ppc/test_40p.py +1 -2
index 4c1c9bad6ec..084fe4c4e54 100755
@@ -17,8 +17,7 @@ class IbmPrep40pMachine(QemuSystemTest):
     timeout = 60
 
     ASSET_BIOS = Asset(
-        ('http://ftpmirror.your.org/pub/misc/'
-         'ftp.software.ibm.com/rs6000/firmware/'
+        ('https://public.dhe.ibm.com/eserver/pseries/firmware/'
          '7020-40p/P12H0456.IMG'),
         'd957f79c73f760d1455d2286fcd901ed6d06167320eb73511b478a939be25b3f')
     ASSET_NETBSD40 = Asset(
Signature · 1 line
2.56.1
#3 lore raw

PATCH 2/12 tests/functional: update sha digests for tuxrun kernels

In reply to Daniel P. Berrangé

The images appear to have been regenerated since the recorded digests no longer match

---
 tests/functional/aarch64/test_tuxrun.py | 4 ++--
 tests/functional/s390x/test_tuxrun.py   | 4 ++--
 tests/functional/x86_64/test_tuxrun.py  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
tests/functional/aarch64/test_tuxrun.py +2 -2
index 2ff321582d3..6c4367c8a20 100755
@@ -18,10 +18,10 @@ class TuxRunAarch64Test(TuxRunBaselineTest):
 
     ASSET_ARM64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/arm64/Image.gz',
-        '39f4633bbcb444267d4d829bd28d8868a287c4c160cda64b0fd23fb090571c4e')
+        'e297f12682af7e88735a0aae38e6fbd137192b516ab5f0fc1a81c4bcc3992e80')
     ASSET_ARM64_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/arm64/vmlinux.xz',
-        '6487eb113ef6e841aedab6cb6fa704006377d68f64dd544570aa42f462a52b85')
+        'aa9b984337e975528162ed873cf18a072b27be8e4f48e6cf0723e9b490c63171')
     ASSET_ARM64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/arm64/rootfs.ext4.zst',
         '4ab8cec9d1e17dbb1abdf2ae1939ad4f9d0dc2466230f6a119a7c1845cdef0b1')
tests/functional/s390x/test_tuxrun.py +2 -2
index 1dd662aaaf0..be38fcded2e 100755
@@ -18,10 +18,10 @@ class TuxRunS390xTest(TuxRunBaselineTest):
 
     ASSET_S390X_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/s390/bzImage',
-        '5efeb31754b211440e1595ab11355bb006fe78a2c0604ed0a8c55c4598b71aec')
+        'b5022f97e243b8ecd51fc7ce4290a15806ecc51a41edbe777fc0fcdda567269e')
     ASSET_S390X_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/s390/vmlinux.xz',
-        '5bbd4d34e0950f88053a9bfd16078896df4b1ee1696fc2ad62488e681a6bdd8e')
+        'cd70050ddb638e81c2f1b96a4629c224aedd36bf8ae3b56b264b070e94642e25')
     ASSET_S390X_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/s390/rootfs.ext4.zst',
         '5ba18c4d18831c50a0c743990f7bdee1d3b520629d423c55b668d8fbbac9c6f5')
tests/functional/x86_64/test_tuxrun.py +2 -2
index 1a1138d16ae..efe907bed82 100755
@@ -18,10 +18,10 @@ class TuxRunX86Test(TuxRunBaselineTest):
 
     ASSET_X86_64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/x86_64/bzImage',
-        '24a3ade610c2cc426ff821050de8a35930b0371357d94cc2c334abac6658552b')
+        'ba98a8a07d5f3f3e20119341059c0f0096fda499d30e30049c1ea64553b7e7c2')
     ASSET_X86_64_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/x86_64/vmlinux.xz',
-        '77bf44cca48c9c1b9c142e16a2311d58b8ae3462b61bce44bcaf9243b5f26628')
+        'bc8af37608753c6ba47c6fe85f4034188b5f15bb757a0cbd79672c65122278ab')
     ASSET_X86_64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/x86_64/rootfs.ext4.zst',
         '8e310455b0244414ccff29c507f7ccfd4032e3587cc405e49ab0322738e3e27c')
Signature · 1 line
2.56.1
#9 lore raw

PATCH 4/12 tests/functional: add Accept header when downloading assets

In reply to Daniel P. Berrangé

elinux.org is currently triggering an Anubis challenge for requests to download assets. After comparing the headers that curl sends, it was narrowed down to the omission of an "Accept" header.

A missing "Accept" header is a rule that Anubis added a year ago which is known to hit python's urllib:

https://github.com/TecharoHQ/anubis/issues/1346

the bug indicates the rule was removed by default at that time, however, rules have evolved further since then and look like they are hitting our downloads. Adding the header is simple & harmless.

---
 tests/functional/qemu_test/asset.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/functional/qemu_test/asset.py +10 -1
index 0abd89e0a38..ffa01aba2fb 100644
@@ -137,7 +137,16 @@ def _try_to_fetch(self, tmp_cache_file):
         for _retries in range(3):
             try:
                 with tmp_cache_file.open("xb") as dst:
-                    with urllib.request.urlopen(self.url) as resp:
+                    req = urllib.request.Request(
+                        self.url,
+                        headers={
+                            # Workaround Anubis challenge which some sites
+                            # trigger when Accept is missing:
+                            #  https://github.com/TecharoHQ/anubis/issues/1346
+                            "Accept": "*/*",
+                        }
+                    )
+                    with urllib.request.urlopen(req) as resp:
                         copyfileobj(resp, dst)
                         length_hdr = resp.getheader("Content-Length")
 
Signature · 1 line
2.56.1
#11 lore raw

PATCH 5/12 tests/functional: check if we are served an Anubis challenge

In reply to Daniel P. Berrangé

If we get an Anubis challenge, we'll detect the problem as a mismatched sha256 digest, however, it is difficult to diagnose that Anubis was the root cause. Add a crude check to detect the challenge and give a clear message in the logs when the download fails.

---
 tests/functional/qemu_test/asset.py | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/functional/qemu_test/asset.py +9 -0
index ffa01aba2fb..bb7c7d5bb8f 100644
@@ -244,6 +244,15 @@ def fetch(self):
             self.log.debug("Unable to set xattr on %s: %s", tmp_cache_file, e)
 
         if not self._check(tmp_cache_file):
+            # Open in binary mode in case the file is binary
+            # content that can't decode as valid utf-8
+            with open(tmp_cache_file, mode='rb') as fh:
+                f = fh.read(10*1024)
+                if "anubis".encode() in f:
+                    tmp_cache_file.unlink()
+                    raise AssetError(self,
+                                     f"Got Anubis challenge instead of content",
+                                     transient=True)
             tmp_cache_file.unlink()
             raise AssetError(self, f"Hash does not match {self.hash}")
         tmp_cache_file.replace(self.cache_file)
Signature · 1 line
2.56.1
#19 lore raw

PATCH 11/12 tests/functional: only run pre-cache once per class

In reply to Daniel P. Berrangé

When precaching assets, we iterate over test cases, downloading all assets in the class containing the test suite. This often results in iterating over assets in the class multiple times.

If we fail to download an asset from a non-transient problem, it will not end up in the cache, and so the subsequent iterations will retry the failed download again wasting time, as well as making the logs more verbose.

---
 tests/functional/qemu_test/asset.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/functional/qemu_test/asset.py +8 -5
index 313efcf7626..7bebdd4d481 100644
@@ -273,11 +273,13 @@ def fetch(self):
         return str(self.cache_file)
 
     @staticmethod
-    def precache_test(test):
+    def precache_test(test, done):
         '''
         Look for variables starting with "ASSET_" and try to fetch the asset
         that is specified there.
         '''
+        if test.__class__ in done:
+            return
         log = logging.getLogger('qemu-test')
         log.setLevel(logging.DEBUG)
         handler = logging.StreamHandler(sys.stdout)
@@ -295,18 +297,19 @@ def precache_test(test):
                         raise
                     log.error("%s: skipping asset precache", e)
 
+        done[test.__class__] = True
         log.removeHandler(handler)
 
     @staticmethod
-    def precache_suite(suite):
+    def precache_suite(suite, done):
         '''
         Iterate through all tests/suites in a suite and precache their assets
         '''
         for test in suite:
             if isinstance(test, unittest.TestSuite):
-                Asset.precache_suite(test)
+                Asset.precache_suite(test, done)
             elif isinstance(test, unittest.TestCase):
-                Asset.precache_test(test)
+                Asset.precache_test(test, done)
 
     @staticmethod
     def precache_suites(path, cache_tstamp):
@@ -316,5 +319,5 @@ def precache_suites(path, cache_tstamp):
         loader = unittest.loader.defaultTestLoader
         tests = loader.loadTestsFromNames([path], None)
 
-        Asset.precache_suite(tests)
+        Asset.precache_suite(tests, {})
         Path(cache_tstamp).touch()
Signature · 1 line
2.56.1
#17 lore raw

PATCH 9/12 tests/functional: don't display stack trace on download fail

In reply to Daniel P. Berrangé

Just display the short error message which is sufficient to diagnose the problem and makes the logs far easier to read.

---
 tests/functional/qemu_test/testcase.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/functional/qemu_test/testcase.py +6 -2
index d4aee359517..8fa0af5a698 100644
@@ -28,7 +28,7 @@
 from qemu.utils import hvf_available, kvm_available, tcg_available
 
 from .archive import archive_extract
-from .asset import Asset
+from .asset import Asset, AssetError
 from .config import BUILD_DIR, dso_suffix
 from .uncompress import uncompress
 
@@ -256,7 +256,11 @@ def main():
 
         cache = os.environ.get("QEMU_TEST_PRECACHE", None)
         if cache is not None:
-            Asset.precache_suites(test_module, cache)
+            try:
+                Asset.precache_suites(test_module, cache)
+            except AssetError as e:
+                print(f"ERROR: {e}")
+                sys.exit(1)
             return
 
         tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError,
Signature · 1 line
2.56.1
#18 lore raw

PATCH 10/12 tests/functional: always raise AssetError when download fails

In reply to Daniel P. Berrangé

If two processes are downloading the same file, the second will wait for the first to finish. The second may encounter problems, however, and raise FileNotFoundError or TimeoutError. The layers up the stack, however, only expect/handle AssetError.

---
 tests/functional/qemu_test/asset.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
tests/functional/qemu_test/asset.py +8 -3
index 5a9a0f37e9a..313efcf7626 100644
@@ -103,7 +103,9 @@ def _wait_for_other_download(self, tmp_cache_file):
         except:
             if os.path.exists(self.cache_file):
                 return True
-            raise
+            raise AssetError(
+                self, f"Other thread failed download to {tmp_cache_file}",
+                transient=True)
         waittime = lastchange = 600
         while waittime > 0:
             sleep(1)
@@ -113,7 +115,9 @@ def _wait_for_other_download(self, tmp_cache_file):
             except:
                 if os.path.exists(self.cache_file):
                     return True
-                raise
+                raise AssetError(
+                    self, f"Other thread failed download to {tmp_cache_file}",
+                    transient=True)
             if new_size != current_size:
                 lastchange = waittime
                 current_size = new_size
@@ -121,7 +125,8 @@ def _wait_for_other_download(self, tmp_cache_file):
                 return False
 
         self.log.debug("Time out while waiting for %s!", tmp_cache_file)
-        raise TimeoutError(f"Time out while waiting for {tmp_cache_file}")
+        raise AssetError(f"Time out while waiting for {tmp_cache_file}",
+                         transient=True)
 
     def _save_time_stamp(self):
         '''
Signature · 1 line
2.56.1
#15 lore raw

PATCH 7/12 tests/functional: delete tmp file on interrupt

In reply to Daniel P. Berrangé

If the user interrupts the download, delete the temporary file so we don't get a long timeout waiting on a stale download when re-running.

---
 tests/functional/qemu_test/asset.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +6 -2
index 51c76993d07..5a9a0f37e9a 100644
@@ -225,8 +225,12 @@ def fetch(self):
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)
         tmp_cache_file = self.cache_file.with_suffix(".download")
 
-        if self._try_to_fetch(tmp_cache_file):
-            return str(self.cache_file)
+        try:
+            if self._try_to_fetch(tmp_cache_file):
+                return str(self.cache_file)
+        except KeyboardInterrupt:
+            tmp_cache_file.unlink()
+            raise
 
         if not os.path.exists(tmp_cache_file):
             raise AssetError(self, "Download retries exceeded", transient=True)
Signature · 1 line
2.56.1
#20 lore raw

PATCH 12/12 tests/functional: optionally display download progress

In reply to Daniel P. Berrangé

If "QEMU_TEST_VERBOSE=1" is set then display the file download progress. This is not enabled by default since meson buffers output, but if running the test file directly it can be helpful to see. This requires the 'tqdm' python package to be present on the system and will have no effect if missing.

---
 docs/devel/testing/functional.rst   |  6 ++++++
 tests/functional/qemu_test/asset.py | 29 +++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
docs/devel/testing/functional.rst +6 -0
index 60a427d175d..8aac3ef9508 100644
@@ -329,6 +329,12 @@ default, but the location can be changed by setting the
 To force the test suite to re-download the cache, even if still valid,
 set the ``QEMU_TEST_REFRESH_CACHE`` environment variable.
 
+To see progress information during the downloads, set ``QEMU_TEST_VERBOSE``
+to ``1``. Since meson buffers output and only display it on completion,
+this is only suitable if running the test precaching directly::
+
+    QEMU_TEST_VERBOSE=1 ./run tests/functional/mips/test_malta.py
+
 Skipping tests
 --------------
 
tests/functional/qemu_test/asset.py +27 -2
index 7bebdd4d481..aa071ea1960 100644
@@ -18,9 +18,13 @@
 import urllib.request
 from time import sleep
 from pathlib import Path
-from shutil import copyfileobj
 from urllib.error import HTTPError, URLError
 
+try:
+    from tqdm import tqdm
+except:
+    tqdm = None
+
 
 class AssetError(Exception):
     '''This exception will be raised if an asset is not usable'''
@@ -139,6 +143,14 @@ def _save_time_stamp(self):
         self.cache_file.with_suffix(".stamp").write_text(f"{int(time.time())}")
 
     def _try_to_fetch(self, tmp_cache_file):
+        def copyfileprog(prg, src, dst):
+            rd = src.read
+            wr = dst.write
+            while buf := rd(256 * 1024):
+                wr(buf)
+                if prg is not None:
+                    prg.update(len(buf))
+
         for _retries in range(3):
             try:
                 with tmp_cache_file.open("xb") as dst:
@@ -152,8 +164,21 @@ def _try_to_fetch(self, tmp_cache_file):
                         }
                     )
                     with urllib.request.urlopen(req) as resp:
-                        copyfileobj(resp, dst)
                         length_hdr = resp.getheader("Content-Length")
+                        verbose = os.environ.get("QEMU_TEST_VERBOSE", False)
+                        if tqdm is not None and verbose:
+                            args = {
+                                "desc": os.path.basename(self.url)
+                            }
+                            if length_hdr is not None:
+                                args["total"] = int(length_hdr)
+                            prg = tqdm(**args)
+                            try:
+                                copyfileprog(prg, resp, dst)
+                            finally:
+                                prg.close()
+                        else:
+                            copyfileprog(None, resp, dst)
 
                 # Verify downloaded file size against length metadata, if
                 # available.
Signature · 1 line
2.56.1
#14 lore raw

PATCH 6/12 tests/functional: don't write timestamp unless successful

In reply to Daniel P. Berrangé

The current code creates the timestamp file before running the precache operation, so it remains on disk even after a download error. This prevents re-trying of downloads to get the missing files.

---
 tests/functional/qemu_test/asset.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +2 -2
index bb7c7d5bb8f..51c76993d07 100644
@@ -307,5 +307,5 @@ def precache_suites(path, cache_tstamp):
         loader = unittest.loader.defaultTestLoader
         tests = loader.loadTestsFromNames([path], None)
 
-        with open(cache_tstamp, "w", encoding='utf-8'):
-            Asset.precache_suite(tests)
+        Asset.precache_suite(tests)
+        Path(cache_tstamp).touch()
Signature · 1 line
2.56.1
#16 lore raw

PATCH 8/12 tests/functional: honour make jobs in precache

In reply to Daniel P. Berrangé

Pass $(NINJAFLAGS) when running precache so that it does not run in parallel until the user requested a parallel make.

---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.include +1 -1
index a1f60802b9b..f983b1ae2dd 100644
@@ -49,7 +49,7 @@ $(FUNCTIONAL_TARGETS):
 
 .PHONY: check-functional-precache
 check-functional-precache:
-	@$(NINJA) precache-functional
+	@$(NINJA) $(NINJAFLAGS) precache-functional
 	@$(PYTHON) $(SRC_PATH)/scripts/clean_functional_cache.py
 
 .PHONY: check-functional
Signature · 1 line
2.56.1
#4 lore raw

Re: [PATCH 02/12] tests/functional: update sha digests for tuxrun kernels

In reply to Daniel P. Berrangé
Quoted 5 lines · Daniel P. Berrangé

The images appear to have been regenerated since the recorded digests no longer match

See also
https://patchew.org/QEMU/[email protected]/

Quoted 61 lines
---
 tests/functional/aarch64/test_tuxrun.py | 4 ++--
 tests/functional/s390x/test_tuxrun.py   | 4 ++--
 tests/functional/x86_64/test_tuxrun.py  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
tests/functional/aarch64/test_tuxrun.py +2 -2
index 2ff321582d3..6c4367c8a20 100755
@@ -18,10 +18,10 @@ class TuxRunAarch64Test(TuxRunBaselineTest):
 
     ASSET_ARM64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/arm64/Image.gz',
-        '39f4633bbcb444267d4d829bd28d8868a287c4c160cda64b0fd23fb090571c4e')
+        'e297f12682af7e88735a0aae38e6fbd137192b516ab5f0fc1a81c4bcc3992e80')
     ASSET_ARM64_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/arm64/vmlinux.xz',
-        '6487eb113ef6e841aedab6cb6fa704006377d68f64dd544570aa42f462a52b85')
+        'aa9b984337e975528162ed873cf18a072b27be8e4f48e6cf0723e9b490c63171')
     ASSET_ARM64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/arm64/rootfs.ext4.zst',
         '4ab8cec9d1e17dbb1abdf2ae1939ad4f9d0dc2466230f6a119a7c1845cdef0b1')
tests/functional/s390x/test_tuxrun.py +2 -2
index 1dd662aaaf0..be38fcded2e 100755
@@ -18,10 +18,10 @@ class TuxRunS390xTest(TuxRunBaselineTest):
 
     ASSET_S390X_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/s390/bzImage',
-        '5efeb31754b211440e1595ab11355bb006fe78a2c0604ed0a8c55c4598b71aec')
+        'b5022f97e243b8ecd51fc7ce4290a15806ecc51a41edbe777fc0fcdda567269e')
     ASSET_S390X_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/s390/vmlinux.xz',
-        '5bbd4d34e0950f88053a9bfd16078896df4b1ee1696fc2ad62488e681a6bdd8e')
+        'cd70050ddb638e81c2f1b96a4629c224aedd36bf8ae3b56b264b070e94642e25')
     ASSET_S390X_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/s390/rootfs.ext4.zst',
         '5ba18c4d18831c50a0c743990f7bdee1d3b520629d423c55b668d8fbbac9c6f5')
tests/functional/x86_64/test_tuxrun.py +2 -3
index 1a1138d16ae..efe907bed82 100755
@@ -18,10 +18,10 @@ class TuxRunX86Test(TuxRunBaselineTest):
 
     ASSET_X86_64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/x86_64/bzImage',
-        '24a3ade610c2cc426ff821050de8a35930b0371357d94cc2c334abac6658552b')
+        'ba98a8a07d5f3f3e20119341059c0f0096fda499d30e30049c1ea64553b7e7c2')
     ASSET_X86_64_VMLINUX = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/x86_64/vmlinux.xz',
-        '77bf44cca48c9c1b9c142e16a2311d58b8ae3462b61bce44bcaf9243b5f26628')
+        'bc8af37608753c6ba47c6fe85f4034188b5f15bb757a0cbd79672c65122278ab')
     ASSET_X86_64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/x86_64/rootfs.ext4.zst',
         '8e310455b0244414ccff29c507f7ccfd4032e3587cc405e49ab0322738e3e27c')
--

2.56.1

Signature · 1 line
Marc-André Lureau
#12 lore raw

Re: [PATCH 05/12] tests/functional: check if we are served an Anubis challenge

In reply to Daniel P. Berrangé
Quoted 18 lines · Daniel P. Berrangé

If we get an Anubis challenge, we'll detect the problem as a mismatched sha256 digest, however, it is difficult to diagnose that Anubis was the root cause. Add a crude check to detect the challenge and give a clear message in the logs when the download fails.

---
tests/functional/qemu_test/asset.py | 9 +++++++++

1 file changed, 9 insertions(+)
tests/functional/qemu_test/asset.py +0 -0
index ffa01aba2fb..bb7c7d5bb8f 100644
@@ -244,6 +244,15 @@ def fetch(self):
            self.log.debug("Unable to set xattr on %s: %s", tmp_cache_file, e)
 
        if not self._check(tmp_cache_file):

tests/functional/qemu_test/asset.py def fetch(self): · line 256

Quoted 10 lines
tests/functional/qemu_test/asset.py +9 -0
+            # Open in binary mode in case the file is binary
+            # content that can't decode as valid utf-8
+            with open(tmp_cache_file, mode='rb') as fh:
+                f = fh.read(10*1024)
+                if "anubis".encode() in f:
+                    tmp_cache_file.unlink()
+                    raise AssetError(self,
+                                     f"Got Anubis challenge instead of content",
+                                     transient=True)
            tmp_cache_file.unlink()

I don't know python but there's already tmp_cache_file.unlink() here. Is the one above needed too?

Regards,
BALATON Zoltan

Quoted 3 lines
tests/functional/qemu_test/asset.py +0 -0
            raise AssetError(self, f"Hash does not match {self.hash}")
        tmp_cache_file.replace(self.cache_file)
#13 lore raw

Re: [PATCH 05/12] tests/functional: check if we are served an Anubis challenge

Quoted 19 lines · BALATON Zoltan
Quoted 18 lines · Daniel P. Berrangé

If we get an Anubis challenge, we'll detect the problem as a mismatched sha256 digest, however, it is difficult to diagnose that Anubis was the root cause. Add a crude check to detect the challenge and give a clear message in the logs when the download fails.

---
tests/functional/qemu_test/asset.py | 9 +++++++++

1 file changed, 9 insertions(+)
tests/functional/qemu_test/asset.py +0 -0
index ffa01aba2fb..bb7c7d5bb8f 100644
@@ -244,6 +244,15 @@ def fetch(self):
            self.log.debug("Unable to set xattr on %s: %s", tmp_cache_file, 
 e)
 
Quoted 14 lines

tests/functional/qemu_test/asset.py def fetch(self): · line 256

Quoted 12 lines
tests/functional/qemu_test/asset.py +9 -0
        if not self._check(tmp_cache_file):
+            # Open in binary mode in case the file is binary
+            # content that can't decode as valid utf-8
+            with open(tmp_cache_file, mode='rb') as fh:
+                f = fh.read(10*1024)
+                if "anubis".encode() in f:
+                    tmp_cache_file.unlink()
+                    raise AssetError(self,
+                                     f"Got Anubis challenge instead of 
 content",
+                                     transient=True)
            tmp_cache_file.unlink()

I don't know python but there's already tmp_cache_file.unlink() here. Is the one above needed too?

I got it, raise exits so need to unlink before.

Regards,
BALATON Zoltan

Quoted 3 lines
Quoted 2 lines

raise AssetError(self, f"Hash does not match {self.hash}")
tmp_cache_file.replace(self.cache_file)

Reviewed-by on v1 1/12
#2 lore raw

Re: [PATCH 01/12] tests/functional: update to newer sunxi kernel package

In reply to Daniel P. Berrangé

Am 20.11.26 um 13:14 schrieb Daniel P. Berrangé:

Quoted 11 lines

The version we currently reference has been deleted from the the apt.armbian.com host. 6.6.44 is the next oldest build that is available.

---
  tests/functional/arm/test_bpim2u.py     | 19 ++++++++++---------
  tests/functional/arm/test_cubieboard.py | 15 ++++++++-------
  tests/functional/arm/test_orangepi.py   | 19 ++++++++++---------
  tests/functional/arm/test_replay.py     | 12 ++++++------
  4 files changed, 34 insertions(+), 31 deletions(-)
Tested-by on v1 3/12
#8 lore raw

Re: [PATCH 03/12] tests/functional: update URL to rs6000 firmware

In reply to Daniel P. Berrangé

Am 20.11.26 um 13:14 schrieb Daniel P. Berrangé:

Quoted 13 lines

The current mirror URL is throwing permission denied errors, so switch to an alternate site discoverd via Google.

---
  tests/functional/ppc/test_40p.py | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tests/functional/ppc/test_40p.py +0 -0
index 4c1c9bad6ec..084fe4c4e54 100755

tests/functional/ppc/test_40p.py class IbmPrep40pMachine(QemuSystemTest): · line 23

Quoted 9 lines
tests/functional/ppc/test_40p.py +1 -2
@@ -17,8 +17,7 @@ class IbmPrep40pMachine(QemuSystemTest):
      timeout = 60
 
      ASSET_BIOS = Asset(
-        ('http://ftpmirror.your.org/pub/misc/'
-         'ftp.software.ibm.com/rs6000/firmware/'
+        ('https://public.dhe.ibm.com/eserver/pseries/firmware/'
           '7020-40p/P12H0456.IMG'),
          'd957f79c73f760d1455d2286fcd901ed6d06167320eb73511b478a939be25b3f')
      ASSET_NETBSD40 = Asset(
Reviewed-by on v1 4/12
#10 lore raw

Re: [PATCH 04/12] tests/functional: add Accept header when downloading assets

In reply to Daniel P. Berrangé

Am 20.11.26 um 13:14 schrieb Daniel P. Berrangé:

Quoted 9 lines

elinux.org is currently triggering an Anubis challenge for requests to download assets. After comparing the headers that curl sends, it was narrowed down to the omission of an "Accept" header.

A missing "Accept" header is a rule that Anubis added a year ago which is known to hit python's urllib:

   https://github.com/TecharoHQ/anubis/issues/1346
Quoted 8 lines

the bug indicates the rule was removed by default at that time, however, rules have evolved further since then and look like they are hitting our downloads. Adding the header is simple & harmless.

---
  tests/functional/qemu_test/asset.py | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
#5 lore raw

Re: [PATCH 02/12] tests/functional: update sha digests for tuxrun kernels

In reply to Marc-André Lureau
Quoted 9 lines · Marc-André Lureau
Quoted 5 lines · Daniel P. Berrangé

The images appear to have been regenerated since the recorded digests no longer match

See also
https://patchew.org/QEMU/[email protected]/

Indeed, Marc's use of dated urls should avoid some of the issues, until the url is removed due to age.

r~

#6 lore raw

Re: [PATCH 02/12] tests/functional: update sha digests for tuxrun kernels

Quoted 6 lines · Richard Henderson
Quoted 5 lines · Marc-André Lureau
Quoted 4 lines · Daniel P. Berrangé

The images appear to have been regenerated since the recorded digests no longer match

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

See also
https://patchew.org/QEMU/[email protected]/

Indeed, Marc's use of dated urls should avoid some of the issues, until the url is removed due to age.

Agreed, consider this patch dropped in favour of that one.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Reviewed-by on the v1 series
#21 lore raw
In reply to Daniel P. Berrangé
Quoted 30 lines · Daniel P. Berrangé

The first 4 patches fix failures to download a number of assets whose URLs have been deleted, or moved, content regenerated, or put behind anubis.

They will need to go to the pending 11.2 release and stable branches too.

The remaining patches are bug fixes except for the very last patch. Those can likely all wait until 12.0, but cherry-picking some of them into stable would be reasonable if desired.

After this series is applied we have one unresolvable problem with assets for MIPS, the yamon-bin-02.22.zip file hosted on AWS is throwing an error about using the wrong endpoint, but I can't figure out what the right one is (if any).

Daniel P. Berrangé (12):
tests/functional: update to newer sunxi kernel package tests/functional: update sha digests for tuxrun kernels tests/functional: update URL to rs6000 firmware tests/functional: add Accept header when downloading assets tests/functional: check if we are served an Anubis challenge tests/functional: don't write timestamp unless successful tests/functional: delete tmp file on interrupt tests/functional: honour make jobs in precache tests/functional: don't display stack trace on download fail tests/functional: always raise AssetError when download fails tests/functional: only run pre-cache once per class tests/functional: optionally display download progress

Quoted 14 lines
 docs/devel/testing/functional.rst       |  6 ++
 tests/Makefile.include                  |  2 +-
 tests/functional/aarch64/test_tuxrun.py |  4 +-
 tests/functional/arm/test_bpim2u.py     | 19 +++---
 tests/functional/arm/test_cubieboard.py | 15 ++---
 tests/functional/arm/test_orangepi.py   | 19 +++---
 tests/functional/arm/test_replay.py     | 12 ++--
 tests/functional/ppc/test_40p.py        |  3 +-
 tests/functional/qemu_test/asset.py     | 83 ++++++++++++++++++++-----
 tests/functional/qemu_test/testcase.py  |  8 ++-
 tests/functional/s390x/test_tuxrun.py   |  4 +-
 tests/functional/x86_64/test_tuxrun.py  |  4 +-
 12 files changed, 123 insertions(+), 56 deletions(-)

For the whole series,

Regards,
Pierrick