Skip to content

Commit

Permalink
kernel: Add support for transactional systems to update_kernel module
Browse files Browse the repository at this point in the history
  • Loading branch information
czerw committed Oct 19, 2023
1 parent 2626881 commit df06b63
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
12 changes: 6 additions & 6 deletions lib/bootloader_setup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ sub add_custom_grub_entries {
if (check_var('VERSION', '12-SP4') && is_aarch64) {
$distro = 'SLE-HPC' . ' \\?' . get_required_var('VERSION');
}
elsif (check_var('SLE_PRODUCT', 'slert')) {
$distro = "SLE_RT" . ' \\?' . get_required_var('VERSION');
}
elsif (is_sle()) {
$distro = "SLES" . ' \\?' . get_required_var('VERSION');
}
elsif (is_alp()) {
$distro = "ALP";
}
elsif (is_sle_micro()) {
$distro = "SLE Micro";
}
elsif (check_var('SLE_PRODUCT', 'slert')) {
$distro = "SLE_RT" . ' \\?' . get_required_var('VERSION');
}
elsif (is_sle()) {
$distro = "SLES" . ' \\?' . get_required_var('VERSION');
}

bmwqemu::diag("Trying to trigger purging old kernels before changing grub menu");
script_run('/sbin/purge-kernels');
Expand Down
24 changes: 14 additions & 10 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use warnings;
use testapi qw(is_serial_terminal :DEFAULT);
use lockapi 'mutex_wait';
use mm_network;
use version_utils qw(is_sle_micro is_microos is_leap is_public_cloud is_sle is_sle12_hdd_in_upgrade is_storage_ng is_jeos package_version_cmp);
use version_utils qw(is_sle_micro is_microos is_leap is_public_cloud is_sle is_sle12_hdd_in_upgrade is_storage_ng is_jeos package_version_cmp is_transactional);
use Utils::Architectures;
use Utils::Systemd qw(systemctl disable_and_stop_service);
use Utils::Backends;
Expand Down Expand Up @@ -775,17 +775,21 @@ sub fully_patch_system {
return;
}

# Repeatedly call zypper patch until it returns something other than 103 (package manager updates)
my $ret = 1;
# Add -q to reduce the unnecessary log output.
# Reduce the pressure of serial port when running hyperv test with sle15.
# poo#115454
my $zypp_opt = check_var('VIRSH_VMM_FAMILY', 'hyperv') ? '-q' : '';
for (1 .. 3) {
$ret = zypper_call("$zypp_opt patch --with-interactive -l", exitcode => [0, 4, 102, 103], timeout => 6000);
last if $ret != 103;
if (is_transactional) {
transactional::trup_call("-c patch");
return;
} else {
# Repeatedly call zypper patch until it returns something other than 103 (package manager updates)
# Add -q to reduce the unnecessary log output.
# Reduce the pressure of serial port when running hyperv test with sle15.
# poo#115454
my $zypp_opt = check_var('VIRSH_VMM_FAMILY', 'hyperv') ? '-q' : '';
for (1 .. 3) {
$ret = zypper_call("$zypp_opt patch --with-interactive -l", exitcode => [0, 4, 102, 103], timeout => 6000);
last if $ret != 103;
}
}

if (($ret == 4) && is_sle('>=12') && is_sle('<15')) {
record_soft_failure 'bsc#1176655 openQA test fails in patch_sle - binutils-devel-2.31-9.29.1.aarch64 requires binutils = 2.31-9.29.1';
my $para = '';
Expand Down
26 changes: 19 additions & 7 deletions tests/kernel/update_kernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ use base 'opensusebasetest';
use testapi;
use serial_terminal 'select_serial_terminal';
use utils;
use version_utils qw(is_sle package_version_cmp);
use version_utils qw(is_sle is_transactional package_version_cmp);
use qam;
use kernel 'remove_kernel_packages';
use klp;
use power_action_utils 'power_action';
use repo_tools 'add_qa_head_repo';
use Utils::Backends;
use LTP::utils;
use transactional;

sub check_kernel_package {
my $kernel_name = shift;
Expand All @@ -30,7 +31,8 @@ sub check_kernel_package {
# Only check versioned kernels in livepatch tests. Some old kernel
# packages install /boot/vmlinux symlink but don't set package ownership.
my $glob = get_var('KGRAFT', 0) ? '-*' : '*';
my $cmd = 'rpm -qf --qf "%{NAME}\n" /boot/vmlinu[xz]' . $glob;
my $run_cmd = is_transactional ? 'transactional-update -c -d --quiet run ' : '';
my $cmd = $run_cmd . 'rpm -qf --qf "%{NAME}\n" /boot/vmlinu[xz]' . $glob;
my $packs = script_output($cmd);

for my $packname (split /\s+/, $packs) {
Expand Down Expand Up @@ -85,7 +87,11 @@ sub update_kernel {
fully_patch_system;

if (check_var('SLE_PRODUCT', 'slert')) {
zypper_call('in kernel-devel-rt');
if (is_transactional) {
record_info("There is no kernel-devel-rt available on transactional system.");
} else {
zypper_call('in kernel-devel-rt');
}
}
elsif (is_sle('12+')) {
zypper_call('in kernel-devel');
Expand All @@ -106,7 +112,11 @@ sub update_kernel {
}
else {
# Use single patch or patch list
zypper_call("in -l -t patch $patches", exitcode => [0, 102, 103], log => 'zypper.log', timeout => 1400);
if (is_transactional) {
trup_call("-n -c patch");
} else {
zypper_call("in -l -t patch $patches", exitcode => [0, 102, 103], log => 'zypper.log', timeout => 1400);
}
}
}

Expand Down Expand Up @@ -388,7 +398,7 @@ sub boot_to_console {
sub run {
my $self = shift;

if (is_ipmi && get_var('LTP_BAREMETAL')) {
if ((is_ipmi && get_var('LTP_BAREMETAL')) || is_transactional) {
# System is already booted after installation, just switch terminal
select_serial_terminal;
} else {
Expand All @@ -407,7 +417,7 @@ sub run {
}

$kernel_package = 'kernel-default-base' if is_sle('<12');
$kernel_package = 'kernel-rt' if check_var('SLE_PRODUCT', 'slert');
$kernel_package = 'kernel-rt' if (check_var('SLE_PRODUCT', 'slert'));

if (get_var('KGRAFT')) {
my $incident_klp_pkg = prepare_kgraft($repo, $incident_id);
Expand Down Expand Up @@ -454,7 +464,9 @@ sub run {

check_kernel_package($kernel_package);

if (!get_var('KGRAFT')) {
if (is_transactional) {
reboot_on_changes;
} elsif (!get_var('KGRAFT')) {
power_action('reboot', textmode => 1);
$self->wait_boot if get_var('LTP_BAREMETAL');
}
Expand Down

0 comments on commit df06b63

Please sign in to comment.