diff --git a/data/microos/ignition/config.ign b/data/microos/ignition/config.ign new file mode 100644 index 000000000000..a926fba4e95c --- /dev/null +++ b/data/microos/ignition/config.ign @@ -0,0 +1,11 @@ +{ + "ignition": { "version": "3.0.0" }, + "passwd": { + "users": [ + { + "name": "root", + "passwordHash": "$6$eEm2HpuzI7dfE4i7$dbYiTRLhrqVvwryR7zmMEcnrp13IqZ3mzLbsx9EeHAX7849PibGVgX5vdPuaeYYIO7hVfcboI9/JDpGiDZhHf/" + } + ] + } +} diff --git a/lib/main_ltp.pm b/lib/main_ltp.pm index ea5a7133c637..a7e69ef84a9a 100644 --- a/lib/main_ltp.pm +++ b/lib/main_ltp.pm @@ -34,7 +34,17 @@ sub load_kernel_tests { if (get_var('INSTALL_LTP')) { if (is_transactional) { - is_s390x ? loadtest 'boot/boot_to_desktop' : loadtest 'microos/disk_boot'; + # Handle specific boot requirements for different backends and architectures + if (is_s390x) { + loadtest 'boot/boot_to_desktop'; + } + elsif ((is_ipmi || is_pvm)) { + loadtest 'installation/ipxe_install' if is_ipmi; + loadtest 'microos/install_image'; + } + else { + loadtest 'microos/disk_boot'; + } replace_opensuse_repos_tests if is_repo_replacement_required; loadtest 'transactional/host_config'; loadtest 'console/suseconnect_scc' if is_sle_micro; diff --git a/tests/microos/install_image.pm b/tests/microos/install_image.pm new file mode 100644 index 000000000000..c8df8078aeb8 --- /dev/null +++ b/tests/microos/install_image.pm @@ -0,0 +1,99 @@ +# SUSE's openQA tests +# +# Copyright SUSE LLC +# SPDX-License-Identifier: FSFAP + +# Summary: Install SL Micro image on bare metal disk +# Maintainer: Petr Cervinka + +use base 'opensusebasetest'; +use strict; +use warnings; +use testapi; +use utils; + +use Utils::Backends; +use Utils::Architectures 'is_x86_64'; +use power_action_utils 'power_action'; +use serial_terminal 'select_serial_terminal'; + +sub run { + select_serial_terminal; + + # Use image name from HDD_1 variable + my $image = get_required_var('HDD_1'); + # Use sda as target disk by default + my $device = get_var("MICRO_INSTALL_IMAGE_TARGET_DEVICE", "/dev/sda"); + # Use partition prefix for nvme devices + my $prefix = $device =~ /nvme/ ? "n" : ""; + # SL Micro x86_64 image has three partitions, aarch64 and ppc64le images have only two partitions + my $root_partition_id = is_x86_64 ? 3 : 2; + my $root_partition = "${device}" . $prefix . $root_partition_id; + # New partition id for ignition will be directly after root partition + my $ignition_partition_id = $root_partition_id + 1; + my $ignition_partition = "${device}" . $prefix . $ignition_partition_id; + record_info("Device information", "Device: ${device}\nRoot partition: ${root_partition}\nIgnition partition: ${ignition_partition}"); + + # Mount nfs share with images + assert_script_run("mount -o ro,noauto,nofail,nolock -t nfs openqa.suse.de:/var/lib/openqa/share /mnt"); + assert_script_run("ls -als /mnt/factory/hdd/${image}"); + # dd image to disk + assert_script_run("xzcat /mnt/factory/hdd/${image} | dd of=${device} bs=65536 status=progress", timeout => 300); + assert_script_run("sync"); + assert_script_run("umount /mnt"); + + my $device_layout = script_output("lsblk"); + record_info("Device layout", ${device_layout}); + + # Modify disk to be able to correctly boot and login + assert_script_run("mount ${root_partition} /mnt"); + assert_script_run("btrfs property set /mnt ro false"); + # Set correct serial console to be able to see login in first boot + assert_script_run("sed -i 's/console=ttyS0,115200/console=ttyS1,115200/g' /mnt/boot/grub2/grub.cfg") if is_x86_64; + # Upload original grub configuration + upload_logs("/mnt/etc/default/grub", failok => 1); + # Set permanent grub configuration + assert_script_run("sed -i 's/console=ttyS0,115200/console=ttyS1,115200/g' /mnt/etc/default/grub") if is_x86_64; + # Fully disable graphical terminal on legacy systems without UEFI + assert_script_run("sed -i 's/#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /mnt/etc/default/grub") if (is_ipmi && !get_var('IPXE_UEFI')); + # We need to properly set grub terminal bsc#1230844, otherwise grub menu will not be visible in non graphical boot environments + assert_script_run("sed -i 's/GRUB_TERMINAL_INPUT=\".*\"/GRUB_TERMINAL_INPUT=\"console gfxterm\"/g' /mnt/etc/default/grub"); + assert_script_run("sed -i 's/GRUB_TERMINAL_OUTPUT=\".*\"/GRUB_TERMINAL_OUTPUT=\"console gfxterm\"/g' /mnt/etc/default/grub"); + # Enable root loging with password + assert_script_run("echo 'PermitRootLogin yes' > /mnt/etc/ssh/sshd_config.d/root.conf"); + assert_script_run("btrfs property set /mnt ro true"); + assert_script_run("umount /mnt"); + + # Setup ignition parition on the end of the same disk and resize root partition to use all the space + # script_output recommended in https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/20253/files#r1776549682 + script_output("printf \"fix\n\" | parted ---pretend-input-tty ${device} print"); + assert_script_run("parted ${device} --script mkpart primary ext4 98% 100%"); + assert_script_run("mkfs.ext4 -F ${ignition_partition}"); + assert_script_run("e2label ${ignition_partition} ignition"); + assert_script_run("mount ${ignition_partition} /mnt/"); + assert_script_run("mkdir /mnt/ignition"); + assert_script_run("curl -v -o /mnt/ignition/config.ign " . data_url("microos/ignition/config.ign")); + assert_script_run('umount /mnt'); + + # Resize root filesystem to maximum size to use all space up to partition with ignition + assert_script_run("parted ${device} --script resize ${root_partition_id} 98%"); + assert_script_run("mount ${root_partition} /mnt"); + assert_script_run("btrfs filesystem resize max /mnt"); + assert_script_run("umount /mnt"); + assert_script_run("fdisk ${device} -l"); + record_info("INFO", "${image} was installed on ${device}. System is going to be rebooted"); + + # We have to use force option to reboot command as installer doesn't have fully running systemd environment + power_action("reboot", textmode => 1, force => 1); + + # We can't use reconnect_mgmt_console as it expects fully configured grub, which we don't have at this stage yet + select_console "sol", await_console => 0 if is_ipmi; + select_console 'powerhmc-ssh', await_console => 0 if is_pvm_hmc; + assert_screen("linux-login", 1800); +} + +sub test_flags { + return {fatal => 1}; +} + +1; diff --git a/variables.md b/variables.md index b943961936b2..21fcb47a67f9 100644 --- a/variables.md +++ b/variables.md @@ -141,6 +141,7 @@ LVM_THIN_LV | boolean | false | Use thin provisioning logical volumes for partit MACHINE | string | | Define machine name which defines worker specific configuration, including WORKER_CLASS. MEDIACHECK | boolean | false | Enables `installation/mediacheck` test module. MEMTEST | boolean | false | Enables `installation/memtest` test module. +MICRO_INSTALL_IMAGE_TARGET_DEVICE | string | /dev/sda | Target disk device for bare metal SL Micro installation. MIRROR_{protocol} | string | | Specify source address MM_MTU | integer | 1380 | Specifies the MTU to set in SUTs of MM tests usually started with `NICTYPE=tap`. MOK_VERBOSITY | boolean | false | Enable verbosity feature of shim. Requires preinstalled `mokutil`.