Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to bare metal for direct image installation of SL Micro #20253

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/microos/ignition/config.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ignition": { "version": "3.0.0" },
"passwd": {
"users": [
{
"name": "root",
"passwordHash": "$6$eEm2HpuzI7dfE4i7$dbYiTRLhrqVvwryR7zmMEcnrp13IqZ3mzLbsx9EeHAX7849PibGVgX5vdPuaeYYIO7hVfcboI9/JDpGiDZhHf/"
}
]
}
}
12 changes: 11 additions & 1 deletion lib/main_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions lib/power_action_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ sub handle_livecd_reboot_failure {

=head2 power_action

power_action($action [,observe => $observe] [,keepconsole => $keepconsole] [,textmode => $textmode]);
power_action($action [,observe => $observe] [,keepconsole => $keepconsole] [,textmode => $textmode] [,force => boolean ]);

Executes the selected power action (e.g. poweroff, reboot).

Expand All @@ -271,6 +271,7 @@ C<$keepconsole> prevents a console change, which we do by default to make sure t
desktop which was in text console at the time of C<power_action> call, is switched to the expected
console, that is 'root-console' for textmode, 'x11' otherwise. The actual execution happens in a shell
for textmode or with GUI commands otherwise unless explicitly overridden by setting C<$textmode> to either 0 or 1.
C<$force> sets force option to reboot command in textmode.

=cut

Expand All @@ -280,6 +281,7 @@ sub power_action {
$args{keepconsole} //= 0;
$args{textmode} //= check_var('DESKTOP', 'textmode');
$args{first_reboot} //= 0;
$args{force} //= 0;
die "'action' was not provided" unless $action;

prepare_system_shutdown;
Expand All @@ -290,7 +292,7 @@ sub power_action {

unless ($args{observe}) {
if ($args{textmode}) {
enter_cmd "$action";
$args{force} ? enter_cmd "$action -f" : enter_cmd "$action";
}
elsif ($action eq 'reboot') {
reboot_x11;
Expand Down
2 changes: 1 addition & 1 deletion lib/transactional.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ sub process_reboot {
}
# Replace by wait_boot if possible
select_console('sol', await_console => 0) if (is_ipmi);
assert_screen 'grub2', 150;
assert_screen 'grub2', 300;
wait_screen_change { send_key 'ret' };
}
assert_screen 'linux-login', 200;
Expand Down
11 changes: 9 additions & 2 deletions tests/installation/ipxe_install.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ sub set_pxe_boot {
}

sub set_bootscript {
my $distri;
my $version;
if (get_var('IPXE_BOOT_FIXED')) {
$distri = get_var('IPXE_BOOT_FIXED_DISTRI', 'sle');
$version = get_var('IPXE_BOOT_FIXED_VERSION', '15-SP6');
} else {
$distri = is_sle_micro('>=6.1') ? "SL-Micro" : get_required_var('DISTRI');
$version = get_required_var('VERSION');
}
my $host = get_required_var('SUT_IP');
my $distri = is_sle_micro('>=6.1') ? "SL-Micro" : get_required_var('DISTRI');
my $arch = get_required_var('ARCH');
my $version = get_required_var('VERSION');
my $autoyast = get_var('AUTOYAST', '');
my $mirror_http = get_required_var('MIRROR_HTTP');

Expand Down
100 changes: 100 additions & 0 deletions tests/microos/install_image.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# SUSE's openQA tests
#
# Copyright SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Install SL Micro image on bare metal disk
# Maintainer: Petr Cervinka <[email protected]>

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/ ? "p" : "";
# 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;
czerw marked this conversation as resolved.
Show resolved Hide resolved
# 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;
czerw marked this conversation as resolved.
Show resolved Hide resolved
# Fully disable graphical terminal on legacy systems without UEFI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ever confirmed with SLM project managers that SLE Micro only supports uefi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter at all, especially for kernel testing where we have more legacy machines than in uefi mode.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really?
How many machines relevant today cannot do EFI?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter at all, especially for kernel testing where we have more legacy machines than in uefi mode.

I do not quite agree . It will brings invalid test results, I think. @jlausuch HDYT?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also shouldn't EFI provide a mechanism for thekernel to get the actual console set up in the BIOS?

Even if it's not the case it would be much more reasonable get the console settings from the commandline of the runnig kernel rather than hardcoding it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is specific part is in the newly introduced .pm module, so personally I see no reason to block the merge.
We could improve handling of this parameter and we could make it in a way that the test run could change the behavior, but this could be done later when it is needed and by folks who needed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's not the case it would be much more reasonable get the console settings from the commandline of the runnig kernel rather than hardcoding it.

Hardcoded console settings are directly in image produced by ibs. If you think it is not right, feel free to file a bug or create jira for it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are, however, additional hardcoded setting in this test, separate from settings hardcoded in the image.

The value with which the settings are replaced could be taken from the commandline of the running kernel which can in turn be adjusted in the test setup making it easier to adjust console settings for the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be, but console of running kernel is already configured by the test in ipxe boot script from variable IPXE_CONSOLE. Follow up ticket for this change was already created and is mentioned on other comments in this PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
czerw marked this conversation as resolved.
Show resolved Hide resolved

# 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("parted ${device} --script print");
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"));
schlad marked this conversation as resolved.
Show resolved Hide resolved
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");
my $final_disk_layout = script_output("parted ${device} --script print");
record_info("INFO", "${image} was installed on ${device}. System is going to be rebooted.\n\nFinal disk layout:\n ${final_disk_layout}");

czerw marked this conversation as resolved.
Show resolved Hide resolved
# We have to use force option to reboot command as installer doesn't have fully running systemd environment
czerw marked this conversation as resolved.
Show resolved Hide resolved
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", 600);
}

sub test_flags {
return {fatal => 1};
}

1;
4 changes: 4 additions & 0 deletions variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ INSTALLONLY | boolean | false | Indicates that test suite conducts only installa
INSTLANG | string | en_US | Installation locale settings.
IPERF_REPO | string | | Link to repository with iperf tool for network performance testing. Currently used in Public Cloud Azure test
IPXE | boolean | false | Indicates ipxe boot.
IPXE_BOOT_FIXED | boolean | false | Indicates to ipxe boot fixed distribution independent on DISTRI and VERSION variables.
IPXE_BOOT_FIXED_DISTRI | string | sle | Sets distribution name for fixed ipxe boot.
IPXE_BOOT_FIXED_VERSION | string | 15-SP6 | Sets distribution version for fixed ipxe boot.
IPXE_SET_HDD_BOOTSCRIPT | boolean | false | Upload second IPXE boot script for booting from HDD after the installation boot script gets executed. This is a workaround for cases where the installer fails to switch default boot order to HDD boot. See also PXE_BOOT_TIME.
ISO_MAXSIZE | integer | | Max size of the iso, used in `installation/isosize.pm`.
IS_MM_SERVER | boolean | | If set, run server-specific part of the multimachine job
Expand Down Expand Up @@ -138,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`.
Expand Down
Loading