Skip to content

Commit

Permalink
Merge pull request #18178 from lemon-suse/fix-lock-package
Browse files Browse the repository at this point in the history
Verify lock_package test after migration
  • Loading branch information
tinawang123 authored Nov 23, 2023
2 parents af9ea45 + e6a65fc commit 8c52a98
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions products/sle/main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ sub load_online_migration_tests {
if (is_sle && (get_var('FLAVOR') =~ /Migration/) && (get_var('SCC_ADDONS') !~ /ha/) && !is_sles4sap && (is_upgrade || get_var('MEDIA_UPGRADE'))) {
loadtest "console/check_os_release";
loadtest "console/check_system_info";
loadtest "console/verify_lock_package" if (get_var("LOCK_PACKAGE"));
}
}

Expand Down Expand Up @@ -1181,6 +1182,7 @@ else {
if (is_sle && (get_var('FLAVOR') =~ /Migration/) && (get_var('SCC_ADDONS') !~ /ha/) && !is_sles4sap && (is_upgrade || get_var('MEDIA_UPGRADE'))) {
loadtest "console/check_os_release";
loadtest "console/check_system_info";
loadtest "console/verify_lock_package" if (get_var("LOCK_PACKAGE"));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/console/lock_package.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ sub run {

# Packages to be locked is comma-separated
my @pkgs = split(/,/, get_var('LOCK_PACKAGE'));
my $version_str = '';
zypper_install_available @pkgs;
for my $pkg (@pkgs) {
# Save each package's name, version and release info to variable
my $fullname = script_output "rpm -q $pkg";
push @$locked_pkg_info, {name => $pkg, fullname => $fullname};
$version_str = $version_str ? join(',', $version_str, $fullname) : $fullname;

# Add a lock for each package
zypper_call "al $pkg";
}
set_var('LOCK_PACKAGE_VERSIONS', $version_str);
}

sub test_flags {
Expand Down
35 changes: 35 additions & 0 deletions tests/console/verify_lock_package.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SUSE's openQA tests
#
# Copyright 2023 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: verify lock package works after migation test.
# Maintainer: QE YaST and Migration (QE Yam) <qe-yam at suse de>

package verify_lock_package;
use base "consoletest";
use strict;
use warnings;
use testapi;
use utils;

sub run {
select_console 'root-console';

# Packages to be locked is comma-separated
my @pkgs = split(/,/, get_var('LOCK_PACKAGE'));
my $old_version_str = get_var('LOCK_PACKAGE_VERSIONS');
my $version_str = '';
for my $pkg (@pkgs) {
# Save each package's name, version and release info to variable
my $fullname = script_output "rpm -q $pkg";
$version_str = $version_str ? join(',', $version_str, $fullname) : $fullname;
}
die "The packages hadn't been locked as expected, origin: $old_version_str new: $version_str" if ($version_str ne $old_version_str);
}

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

1;

0 comments on commit 8c52a98

Please sign in to comment.