From 1f42a312c2b7cf7e8247fce969377d2e95232882 Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Fri, 4 Oct 2024 17:20:05 +0200 Subject: [PATCH 1/2] Add interactive-defaults.ks to updates image The interactive-defaults is must have to enable testing of web ui on the boot.iso because we don't have support for package based installations there. This way we are serving the tarball for the VM which will be used as payload to overcome this missing implementation. Do not SSH the interactive-defaults.ks into the VM when it's running but instead add the interactive-defaults.ks to the updates.img. The SSH copy of interactive-defaults.ks works but not reliably. The issue is that we are copying the interactive-defaults.ks to the running installation and if the file will land too late it won't be taken by the installer. To avoid this issue add the interactive-defaults.ks content to the updates image before the VM is started. --- test/machine_install.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/machine_install.py b/test/machine_install.py index a273eaba75..eaa18cafae 100755 --- a/test/machine_install.py +++ b/test/machine_install.py @@ -20,6 +20,7 @@ import subprocess import sys import time +from tempfile import TemporaryDirectory WEBUI_TEST_DIR = os.path.dirname(__file__) ROOT_DIR = os.path.dirname(WEBUI_TEST_DIR) @@ -83,10 +84,20 @@ def _serve_payload(self): return payload_cached_name, http_payload_port - def _write_interactive_defaults_ks(self): + def _write_interactive_defaults_ks(self, updates_image): payload_cached_name, http_payload_port = self._serve_payload() content = f'liveimg --url="http://10.0.2.2:{http_payload_port}/{payload_cached_name}"' - Machine.execute(self, f'echo \'{content}\' > /usr/share/anaconda/interactive-defaults.ks') + defaults_path = "usr/share/anaconda/" + print("Adding interactive defaults to updates.img") + with TemporaryDirectory() as tmp_dir: + os.makedirs(f"{tmp_dir}/{defaults_path}") + # unpack initrd to the temporary directory + os.system(f"cd {tmp_dir} && gzip -dc {updates_image} | cpio -idu") + # add new interactive-defaults.ks (have to be available at start of the installer) + with open(f"{tmp_dir}/{defaults_path}/interactive-defaults.ks", "wt", encoding="utf-8") as f: + f.write(content) + # pack the updates.img again and replace the original one + os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image}") def start(self): update_img_file = os.path.join(ROOT_DIR, "updates.img") @@ -118,6 +129,10 @@ def start(self): else: location = f"{iso_path}" + if not self.is_live(): + # Configure the payload in interactive-defaults.ks + self._write_interactive_defaults_ks(update_img_file) + if self.efi: boot_arg = "--boot uefi " else: @@ -153,9 +168,6 @@ def start(self): if not self.is_live(): Machine.wait_boot(self, timeout_sec=300) - # Configure the payload in interactive-defaults.ks - self._write_interactive_defaults_ks() - for _ in range(30): try: Machine.execute(self, "journalctl -t anaconda | grep 'anaconda: ui.webui: cockpit web view has been started'") From 48378d053a23c43073bcd127d92e2102d65b21fe Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Wed, 9 Oct 2024 11:37:39 +0200 Subject: [PATCH 2/2] tests: when editing the updates.img generate new one per VM --- Makefile | 2 +- test/machine_install.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 0f7cae0f4a..bb142dcceb 100644 --- a/Makefile +++ b/Makefile @@ -192,7 +192,7 @@ $(UPDATES_IMG): prepare-test-deps test/prepare-updates-img create-updates.img: bots - -rm $(UPDATES_IMG) + -rm *updates.img make $(UPDATES_IMG) test/reference: test/common diff --git a/test/machine_install.py b/test/machine_install.py index eaa18cafae..a78d2656f3 100755 --- a/test/machine_install.py +++ b/test/machine_install.py @@ -84,7 +84,7 @@ def _serve_payload(self): return payload_cached_name, http_payload_port - def _write_interactive_defaults_ks(self, updates_image): + def _write_interactive_defaults_ks(self, updates_image, updates_image_edited): payload_cached_name, http_payload_port = self._serve_payload() content = f'liveimg --url="http://10.0.2.2:{http_payload_port}/{payload_cached_name}"' defaults_path = "usr/share/anaconda/" @@ -97,19 +97,23 @@ def _write_interactive_defaults_ks(self, updates_image): with open(f"{tmp_dir}/{defaults_path}/interactive-defaults.ks", "wt", encoding="utf-8") as f: f.write(content) # pack the updates.img again and replace the original one - os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image}") + os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image_edited}") def start(self): - update_img_file = os.path.join(ROOT_DIR, "updates.img") - if not os.path.exists(update_img_file): - raise FileNotFoundError("Missing updates.img file") - - self.http_updates_img_port = self._serve_updates_img() - self.payload_path = os.path.join(BOTS_DIR, "./images/fedora-rawhide-anaconda-payload") if not os.path.exists(self.payload_path): raise FileNotFoundError(f"Missing payload file {self.payload_path}; use 'make payload'.") + update_img_global_file = os.path.join(ROOT_DIR, "updates.img") + update_img_file = os.path.join(ROOT_DIR, self.label + "-updates.img") + if not os.path.exists(update_img_global_file): + raise FileNotFoundError("Missing updates.img file") + + if not self.is_live(): + # Configure the payload in interactive-defaults.ks + self._write_interactive_defaults_ks(update_img_global_file, update_img_file) + + self.http_updates_img_port = self._serve_updates_img() iso_path = f"{os.getcwd()}/bots/images/{self.image}" extra_args = "" @@ -129,10 +133,6 @@ def start(self): else: location = f"{iso_path}" - if not self.is_live(): - # Configure the payload in interactive-defaults.ks - self._write_interactive_defaults_ks(update_img_file) - if self.efi: boot_arg = "--boot uefi " else: @@ -151,7 +151,7 @@ def start(self): "--noautoconsole " f"--graphics vnc,listen={self.ssh_address} " "--extra-args " - f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/updates.img' " + f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/{self.label}-updates.img' " "--network none " f"--qemu-commandline=" "'-netdev user,id=hostnet0,"