Skip to contentSkip to conversation

tests/functional: ppc update and download fail fix

PATCH In review Nicholas Piggin 4 participants 9 messages Dec 20, 2024 – Jan 2, 2025

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 tests/functional: Don't fail the whole test if a pre-cache fetch fails

In reply to Nicholas Piggin

If any pre-cache downloads fail, the entire functional test run is failed.

---
 tests/functional/qemu_test/asset.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +9 -2
index f126cd5863a..f82b07e7027 100644
@@ -102,7 +102,8 @@ def fetch(self):
             return str(self.cache_file)
 
         if os.environ.get("QEMU_TEST_NO_DOWNLOAD", False):
-            raise Exception("Asset cache is invalid and downloads disabled")
+            raise Exception("Failed to fetch asset %s, not found in cache "
+                            "and downloads are disabled", self.url)
 
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)
         tmp_cache_file = self.cache_file.with_suffix(".download")
@@ -162,7 +163,13 @@ def precache_test(test):
         for name, asset in vars(test.__class__).items():
             if name.startswith("ASSET_") and type(asset) == Asset:
                 log.info("Attempting to cache '%s'" % asset)
-                asset.fetch()
+                try:
+                    asset.fetch()
+                except:
+                    # Asset pre-cache should not be fatal. An error is printed
+                    # and the test itself will fail if it is unable to get the
+                    # assert.
+                    pass
         log.removeHandler(handler)
 
     def precache_suite(suite):
Signature · 1 line
2.45.2
#7 lore raw

PATCH 3/4 tests/functional/test_ppc64_hv: Update repo management

In reply to Nicholas Piggin

setup-apkrepos can be used to set repos rather than open-coding URLs.

---
 tests/functional/test_ppc64_hv.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tests/functional/test_ppc64_hv.py +4 -3
index afc8b9a3106..62e1a0f3a2d 100755
@@ -110,6 +110,10 @@ def do_start_alpine(self):
         exec_command_and_wait_for_pattern(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'), ps1)
         ps1='alpine:~#'
         exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
+        exec_command_and_wait_for_pattern(self, 'setup-apkrepos -c1', ps1)
+        exec_command_and_wait_for_pattern(self, 'apk update', ps1)
+        # Could upgrade here but it usually should not be necessary
+        # exec_command_and_wait_for_pattern(self, 'apk upgrade --available', ps1)
 
     def do_stop_alpine(self):
         exec_command(self, 'echo "TEST ME"')
@@ -120,9 +124,6 @@ def do_stop_alpine(self):
 
     def do_setup_kvm(self):
         ps1='alpine:~#'
-        exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories', ps1)
-        exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories', ps1)
-        exec_command_and_wait_for_pattern(self, 'apk update', ps1)
         exec_command_and_wait_for_pattern(self, 'apk add qemu-system-ppc64', ps1)
         exec_command_and_wait_for_pattern(self, 'modprobe kvm-hv', ps1)
 
Signature · 1 line
2.45.2
#0 lore raw

cover tests/functional: ppc update and download fail fix

This updates test_ppc64_hv to the character-based console handling, tidies up repo handling, and updates the image.

Also add a patch that keeps other functional tests working when some assets can't be pre-cached because test_rx_gdbsim started failing for me.

Thanks,
Nick

Nicholas Piggin (4):
tests/functional: Don't fail the whole test if a pre-cache fetch fails tests/functional/test_ppc64_hv: Simplify console handling tests/functional/test_ppc64_hv: Update repo management tests/functional/test_ppc64_hv: Update to Alpine 3.21.0

 tests/functional/qemu_test/asset.py | 11 ++++--
 tests/functional/test_ppc64_hv.py   | 52 +++++++++++++----------------
 2 files changed, 33 insertions(+), 30 deletions(-)
Signature · 1 line
2.45.2
#8 lore raw

PATCH 4/4 tests/functional/test_ppc64_hv: Update to Alpine 3.21.0

---
 tests/functional/test_ppc64_hv.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/functional/test_ppc64_hv.py +4 -4
index 62e1a0f3a2d..f5ff0993ff5 100755
@@ -56,9 +56,9 @@ class HypervisorTest(QemuSystemTest):
     good_message = 'VFS: Cannot open root device'
 
     ASSET_ISO = Asset(
-        ('https://dl-cdn.alpinelinux.org/alpine/v3.18/'
-         'releases/ppc64le/alpine-standard-3.18.4-ppc64le.iso'),
-        'c26b8d3e17c2f3f0fed02b4b1296589c2390e6d5548610099af75300edd7b3ff')
+        ('https://dl-cdn.alpinelinux.org/alpine/v3.21/'
+         'releases/ppc64le/alpine-standard-3.21.0-ppc64le.iso'),
+        '7651ab4e3027604535c0b36e86c901b4695bf8fe97b908f5b48590f6baae8f30')
 
     def extract_from_iso(self, iso, path):
         """
@@ -143,7 +143,7 @@ def do_test_kvm(self, hpt=False):
                            '-initrd /media/nvme0n1/boot/initramfs-lts '
                            '-kernel /media/nvme0n1/boot/vmlinuz-lts '
                            '-append \'usbcore.nousb ' + append + '\'')
-        # Alpine 3.18 kernel seems to crash in XHCI USB driver.
+        # Alpine 3.21 kernel seems to crash in XHCI USB driver.
         ps1='localhost:~#'
         wait_for_console_pattern(self, 'localhost login:')
         exec_command_and_wait_for_pattern(self, 'root', ps1)
Signature · 1 line
2.45.2
#5 lore raw

PATCH 2/4 tests/functional/test_ppc64_hv: Simplify console handling

In reply to Nicholas Piggin

Since functional tests have character-based console output parsing, there is no need for strange hacks to work around old line-based.

---
 tests/functional/test_ppc64_hv.py | 43 ++++++++++++++-----------------
 1 file changed, 19 insertions(+), 24 deletions(-)
tests/functional/test_ppc64_hv.py +19 -24
index d97b62e364f..afc8b9a3106 100755
@@ -12,6 +12,7 @@
 from unittest import skipIf, skipUnless
 from qemu_test import QemuSystemTest, Asset
 from qemu_test import wait_for_console_pattern, exec_command
+from qemu_test import exec_command_and_wait_for_pattern
 import os
 import time
 import subprocess
@@ -102,31 +103,28 @@ def do_start_alpine(self):
                                     "id=drive0,read-only=true")
 
         self.vm.launch()
-        wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
-        exec_command(self, 'root')
+        ps1='localhost:~#'
         wait_for_console_pattern(self, 'localhost login:')
-        wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
+        exec_command_and_wait_for_pattern(self, 'root', ps1)
         # If the time is wrong, SSL certificates can fail.
-        exec_command(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'))
-        exec_command(self, 'setup-alpine -qe')
-        wait_for_console_pattern(self, 'Updating repository indexes... done.')
+        exec_command_and_wait_for_pattern(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'), ps1)
+        ps1='alpine:~#'
+        exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
 
     def do_stop_alpine(self):
-        exec_command(self, 'poweroff')
+        exec_command(self, 'echo "TEST ME"')
         wait_for_console_pattern(self, 'alpine:~#')
+        exec_command(self, 'poweroff')
+        wait_for_console_pattern(self, 'reboot: Power down')
         self.vm.wait()
 
     def do_setup_kvm(self):
-        exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories')
-        wait_for_console_pattern(self, 'alpine:~#')
-        exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories')
-        wait_for_console_pattern(self, 'alpine:~#')
-        exec_command(self, 'apk update')
-        wait_for_console_pattern(self, 'alpine:~#')
-        exec_command(self, 'apk add qemu-system-ppc64')
-        wait_for_console_pattern(self, 'alpine:~#')
-        exec_command(self, 'modprobe kvm-hv')
-        wait_for_console_pattern(self, 'alpine:~#')
+        ps1='alpine:~#'
+        exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories', ps1)
+        exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories', ps1)
+        exec_command_and_wait_for_pattern(self, 'apk update', ps1)
+        exec_command_and_wait_for_pattern(self, 'apk add qemu-system-ppc64', ps1)
+        exec_command_and_wait_for_pattern(self, 'modprobe kvm-hv', ps1)
 
     # This uses the host's block device as the source file for guest block
     # device for install media. This is a bit hacky but allows reuse of the
@@ -145,15 +143,12 @@ def do_test_kvm(self, hpt=False):
                            '-kernel /media/nvme0n1/boot/vmlinuz-lts '
                            '-append \'usbcore.nousb ' + append + '\'')
         # Alpine 3.18 kernel seems to crash in XHCI USB driver.
-        wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
-        exec_command(self, 'root')
+        ps1='localhost:~#'
         wait_for_console_pattern(self, 'localhost login:')
-        wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
-        exec_command(self, 'poweroff >& /dev/null')
-        wait_for_console_pattern(self, 'localhost:~#')
+        exec_command_and_wait_for_pattern(self, 'root', ps1)
+        exec_command(self, 'poweroff')
         wait_for_console_pattern(self, 'reboot: Power down')
-        time.sleep(1)
-        exec_command(self, '')
+        # Now wait for the host's prompt to come back
         wait_for_console_pattern(self, 'alpine:~#')
 
     def test_hv_pseries(self):
Signature · 1 line
2.45.2
#2 lore raw

Re: [PATCH 1/4] tests/functional: Don't fail the whole test if a pre-cache fetch fails

In reply to Nicholas Piggin

+danpb

Quoted 37 lines · Nicholas Piggin

If any pre-cache downloads fail, the entire functional test run is failed.

---
  tests/functional/qemu_test/asset.py | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +9 -2
index f126cd5863a..f82b07e7027 100644
@@ -102,7 +102,8 @@ def fetch(self):
              return str(self.cache_file)
 
          if os.environ.get("QEMU_TEST_NO_DOWNLOAD", False):
-            raise Exception("Asset cache is invalid and downloads disabled")
+            raise Exception("Failed to fetch asset %s, not found in cache "
+                            "and downloads are disabled", self.url)
 
          self.log.info("Downloading %s to %s...", self.url, self.cache_file)
          tmp_cache_file = self.cache_file.with_suffix(".download")
@@ -162,7 +163,13 @@ def precache_test(test):
          for name, asset in vars(test.__class__).items():
              if name.startswith("ASSET_") and type(asset) == Asset:
                  log.info("Attempting to cache '%s'" % asset)
-                asset.fetch()
+                try:
+                    asset.fetch()
+                except:
+                    # Asset pre-cache should not be fatal. An error is printed
+                    # and the test itself will fail if it is unable to get the
+                    # assert.
+                    pass
          log.removeHandler(handler)
 
      def precache_suite(suite):
#3 lore raw

Re: [PATCH 1/4] tests/functional: Don't fail the whole test if a pre-cache fetch fails

In reply to Nicholas Piggin
Quoted 27 lines · Nicholas Piggin

If any pre-cache downloads fail, the entire functional test run is failed.

---
 tests/functional/qemu_test/asset.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +2 -2
index f126cd5863a..f82b07e7027 100644
@@ -102,7 +102,8 @@ def fetch(self):
             return str(self.cache_file)
 
         if os.environ.get("QEMU_TEST_NO_DOWNLOAD", False):
-            raise Exception("Asset cache is invalid and downloads disabled")
+            raise Exception("Failed to fetch asset %s, not found in cache "
+                            "and downloads are disabled", self.url)
 
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)
         tmp_cache_file = self.cache_file.with_suffix(".download")
@@ -162,7 +163,13 @@ def precache_test(test):
         for name, asset in vars(test.__class__).items():
             if name.startswith("ASSET_") and type(asset) == Asset:
                 log.info("Attempting to cache '%s'" % asset)
-                asset.fetch()

tests/functional/qemu_test/asset.py def precache_test(test): · line 175

Quoted 10 lines
tests/functional/qemu_test/asset.py +7 -0
+                try:
+                    asset.fetch()
+                except:
+                    # Asset pre-cache should not be fatal. An error is printed
+                    # and the test itself will fail if it is unable to get the
+                    # assert.
+                    pass
         log.removeHandler(handler)
 
     def precache_suite(suite):

Asset fetching errors & skipping tests is being handled by a pending pull request:

https://lists.nongnu.org/archive/html/qemu-devel/2024-12/msg04334.html
https://lists.nongnu.org/archive/html/qemu-devel/2024-12/msg04333.html

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Re: [PATCH 1/4] tests/functional: Don't fail the whole test if a pre-cache fetch fails

Quoted 37 lines · Daniel P. Berrangé
Quoted 36 lines · Nicholas Piggin

If any pre-cache downloads fail, the entire functional test run is failed.

---
 tests/functional/qemu_test/asset.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/functional/qemu_test/asset.py +9 -2
index f126cd5863a..f82b07e7027 100644
@@ -102,7 +102,8 @@ def fetch(self):
             return str(self.cache_file)
 
         if os.environ.get("QEMU_TEST_NO_DOWNLOAD", False):
-            raise Exception("Asset cache is invalid and downloads disabled")
+            raise Exception("Failed to fetch asset %s, not found in cache "
+                            "and downloads are disabled", self.url)
 
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)
         tmp_cache_file = self.cache_file.with_suffix(".download")
@@ -162,7 +163,13 @@ def precache_test(test):
         for name, asset in vars(test.__class__).items():
             if name.startswith("ASSET_") and type(asset) == Asset:
                 log.info("Attempting to cache '%s'" % asset)
-                asset.fetch()
+                try:
+                    asset.fetch()
+                except:
+                    # Asset pre-cache should not be fatal. An error is printed
+                    # and the test itself will fail if it is unable to get the
+                    # assert.
+                    pass
         log.removeHandler(handler)
 
Quoted 7 lines

tests/functional/qemu_test/asset.py def precache_test(test): · line 175

Quoted 1 line
tests/functional/qemu_test/asset.py +0 -0
     def precache_suite(suite):

Asset fetching errors & skipping tests is being handled by a pending pull request:

https://lists.nongnu.org/archive/html/qemu-devel/2024-12/msg04334.html
https://lists.nongnu.org/archive/html/qemu-devel/2024-12/msg04333.html

Oh thanks, it's merged now I should have looked more carefully. That looks good thank you.

Thanks,
Nick

Reviewed-by on v1 2/4
#6 lore raw

Re: [PATCH 2/4] tests/functional/test_ppc64_hv: Simplify console handling

In reply to Nicholas Piggin
Quoted 7 lines · Nicholas Piggin

Since functional tests have character-based console output parsing, there is no need for strange hacks to work around old line-based.

---
  tests/functional/test_ppc64_hv.py | 43 ++++++++++++++-----------------
  1 file changed, 19 insertions(+), 24 deletions(-)