[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/25] tests/acceptance: refactor boot_linux to allow code reuse
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 25/25] tests/acceptance: refactor boot_linux to allow code reuse |
Date: |
Sun, 31 May 2020 18:38:46 +0200 |
From: Pavel Dovgalyuk <Pavel.Dovgaluk@gmail.com>
This patch moves image downloading functions to the separate class to allow
reusing them from record/replay tests.
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <159073593167.20809.17582679291556188984.stgit@pasha-ThinkPad-X280>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
tests/acceptance/boot_linux.py | 49 ++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
index 075a386300..3aa57e88b0 100644
--- a/tests/acceptance/boot_linux.py
+++ b/tests/acceptance/boot_linux.py
@@ -26,22 +26,8 @@
TCG_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "TCG"
-class BootLinux(Test):
- """
- Boots a Linux system, checking for a successful initialization
- """
-
- timeout = 900
- chksum = None
-
- def setUp(self):
- super(BootLinux, self).setUp()
- self.vm.add_args('-smp', '2')
- self.vm.add_args('-m', '1024')
- self.prepare_boot()
- self.prepare_cloudinit()
-
- def prepare_boot(self):
+class BootLinuxBase(Test):
+ def download_boot(self):
self.log.debug('Looking for and selecting a qemu-img binary to be '
'used to create the bootable snapshot image')
# If qemu-img has been built, use it, otherwise the system wide one
@@ -60,17 +46,17 @@ def prepare_boot(self):
if image_arch == 'ppc64':
image_arch = 'ppc64le'
try:
- self.boot = vmimage.get(
+ boot = vmimage.get(
'fedora', arch=image_arch, version='31',
checksum=self.chksum,
algorithm='sha256',
cache_dir=self.cache_dirs[0],
snapshot_dir=self.workdir)
- self.vm.add_args('-drive', 'file=%s' % self.boot.path)
except:
self.cancel('Failed to download/prepare boot image')
+ return boot.path
- def prepare_cloudinit(self):
+ def download_cloudinit(self):
self.log.info('Preparing cloudinit image')
try:
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
@@ -81,9 +67,32 @@ def prepare_cloudinit(self):
# QEMU's hard coded usermode router address
phone_home_host='10.0.2.2',
phone_home_port=self.phone_home_port)
- self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
except Exception:
self.cancel('Failed to prepared cloudinit image')
+ return cloudinit_iso
+
+class BootLinux(BootLinuxBase):
+ """
+ Boots a Linux system, checking for a successful initialization
+ """
+
+ timeout = 900
+ chksum = None
+
+ def setUp(self):
+ super(BootLinux, self).setUp()
+ self.vm.add_args('-smp', '2')
+ self.vm.add_args('-m', '1024')
+ self.prepare_boot()
+ self.prepare_cloudinit()
+
+ def prepare_boot(self):
+ path = self.download_boot()
+ self.vm.add_args('-drive', 'file=%s' % path)
+
+ def prepare_cloudinit(self):
+ cloudinit_iso = self.download_cloudinit()
+ self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
def launch_and_wait(self):
self.vm.set_console()
--
2.21.3
- [PULL 15/25] python/qemu/qmp: use True/False for non/blocking modes, (continued)
- [PULL 15/25] python/qemu/qmp: use True/False for non/blocking modes, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 16/25] python/qemu/qmp: assert sockfile is not None, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 17/25] python/qemu/qtest: Check before accessing _qtest, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 18/25] tests/vm: Pass --debug through for vm-boot-ssh, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 19/25] tests/vm: Add ability to select QEMU from current build, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 20/25] tests/vm: allow wait_ssh() to specify command, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 21/25] tests/migration/guestperf: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 22/25] tests/acceptance/migration.py: Wait for both sides, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 23/25] tests/acceptance: allow console interaction with specific VMs, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 24/25] tests/acceptance: refactor boot_linux_console test to allow code reuse, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 25/25] tests/acceptance: refactor boot_linux to allow code reuse,
Philippe Mathieu-Daudé <=