Skip to content

Commit

Permalink
tests: apply updates.img with mkksiso script instead of inst.updates
Browse files Browse the repository at this point in the history
In the meantime remove conditions for ELN to simplify the change,
as we don't run test there anymore and the condition is anyhow obsolete.
  • Loading branch information
KKoukiou committed Oct 4, 2024
1 parent 1046f5d commit cfba4e8
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions test/machine_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ def _wait_http_server_running(self, port):
with timeout.Timeout(seconds=50, error_message="Timeout while waiting for http server to start"):
self._execute(WAIT_HTTP_RUNNING)

def _serve_updates_img(self):
http_updates_img_port = self._get_free_port()
self.http_updates_img_server = subprocess.Popen(["python3", "-m", "http.server", "-d", ROOT_DIR, str(http_updates_img_port)])
self._wait_http_server_running(http_updates_img_port)

return http_updates_img_port

def _serve_payload(self):
payload_cached_path = os.path.realpath(self.payload_path)
payload_cached_dir = os.path.dirname(payload_cached_path)
Expand All @@ -93,30 +86,27 @@ def start(self):
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'.")


iso_path = f"{os.getcwd()}/bots/images/{self.image}"
extra_args = ""
if self.is_live():
# Live install ISO has different directory structure inside
iso_path = f"{os.getcwd()}/bots/images/{self.image}"

# Live install ISO has different directory structure ishsnside
# that doesn't follow the standard distribution tree directory structure.
location = f"{iso_path},kernel=images/pxeboot/vmlinuz,initrd=images/pxeboot/initrd.img"

# Live install ISO will not start automatically without providing correct
# kernel arguments to load the LiveOS/squashfs.img file as that's where everything is stored.
volume_id = self.get_volume_id(iso_path)
volume_id = self.get_volume_id(self.iso_path)
extra_args = f"root=live:CDLABEL={volume_id} rd.live.image quiet rhgb"
elif self.is_eln():
# FIXME: Remove this once https://gitlab.com/libosinfo/osinfo-db/-/merge_requests/674 is released
# and version is present in the task container
location = f"{iso_path},kernel=images/pxeboot/vmlinuz,initrd=images/pxeboot/initrd.img"
else:
location = f"{iso_path}"
self.iso_path = f"{os.getcwd()}/test/images/{self.label}.iso"
self._execute(f"mkksiso --skip-mkefiboot -u {update_img_file} bots/images/fedora-rawhide-boot {self.iso_path}")

location = f"{self.iso_path}"

if self.efi:
boot_arg = "--boot uefi "
Expand All @@ -135,8 +125,7 @@ def start(self):
"--memory 4096 "
"--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' "
"--extra-args \'inst.sshd inst.webui.remote inst.webui\' "
"--network none "
f"--qemu-commandline="
"'-netdev user,id=hostnet0,"
Expand Down Expand Up @@ -177,11 +166,13 @@ def kill(self):
f"virsh -q -c qemu:///session undefine --nvram " # tell undefine to also delete the EFI NVRAM device
f"--remove-all-storage {self.label} || true"
)
if self.http_updates_img_server:
self.http_updates_img_server.kill()
if self.http_payload_server:
self.http_payload_server.kill()

# Delete the generated ISO
if self.iso_path:
self._execute(f"rm -f {self._iso_path}")

# pylint: disable=arguments-differ # this fails locally if you have bots checked out
def wait_poweroff(self):
for _ in range(10):
Expand All @@ -197,11 +188,10 @@ def wait_poweroff(self):
def is_live(self):
return "live" in self.image

def is_eln(self):
return "eln" in self.image

def get_volume_id(self, iso_path):
return subprocess.check_output(fr"isoinfo -d -i {iso_path} | grep -oP 'Volume id: \K.*'", shell=True).decode(sys.stdout.encoding).strip()
return subprocess.check_output(
fr"isoinfo -d -i {self.iso_path} | grep -oP 'Volume id: \K.*'", shell=True
).decode(sys.stdout.encoding).strip()


class VirtInstallEFIMachine(VirtInstallMachine):
Expand Down

0 comments on commit cfba4e8

Please sign in to comment.