diff --git a/lib/qam.pm b/lib/qam.pm index a2380bbc2b5e..016557d0de5b 100644 --- a/lib/qam.pm +++ b/lib/qam.pm @@ -16,10 +16,12 @@ use utils qw(zypper_call handle_screen zypper_repos); use JSON; use List::Util qw(max); use version_utils qw(is_sle is_transactional); +use transactional qw(trup_call check_reboot_changes); our @EXPORT = qw(capture_state check_automounter is_patch_needed add_test_repositories disable_test_repositories enable_test_repositories - add_extra_customer_repositories ssh_add_test_repositories remove_test_repositories advance_installer_window get_patches check_patch_variables); + add_extra_customer_repositories ssh_add_test_repositories remove_test_repositories advance_installer_window get_patches + check_patch_variables install_package); use constant ZYPPER_PACKAGE_COL => 1; use constant OLD_ZYPPER_STATUS_COL => 4; use constant ZYPPER_STATUS_COL => 5; @@ -245,4 +247,39 @@ sub check_patch_variables { } } +=head2 install_package + install_package('kernel-devel' [, trup_packages => 'kernel-default-base] [, zypper_packages => 'kernel-devel']); + +C defines packages to install for both zypper and trup call, +Parameters C and C define transactional +or zypper specific packages. +C or C will return from fucntion, +record_info is used if sentence is argument value. +C parameter will run check_reboot_changes after trup_call, +reboot if diff between the current FS and the new snapshot. + +=cut + +sub install_package { + my $ret; + my ($packages, %args) = @_; + die 'Paramater packages is required' unless defined($packages); + my $timeout = $args{timeout} // 500; + + if (is_transactional) { + record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/; + return if $args{skip_trup}; + $packages .= ' ' . $args{trup_extra} // ''; + $ret = trup_call('pkg in -l ' . $packages, timeout => $args{timeout}); + check_reboot_changes if $args{trup_reboot}; + } + else { + record_info('install_package', $args{skip_zypper}) if $args{skip_zypper} =~ /\w+/; + return if $args{skip_zypper}; + $packages .= ' ' . $args{zypper_extra} // ''; + $ret = zypper_call('in -l ' . $packages, timeout => $args{timeout}); + } + return $ret; +} + 1; diff --git a/lib/wrapper.pm b/lib/wrapper.pm deleted file mode 100644 index 178c6ccaf92e..000000000000 --- a/lib/wrapper.pm +++ /dev/null @@ -1,56 +0,0 @@ -# SUSE's openQA tests -# -# Copyright 2023 SUSE LLC -# SPDX-License-Identifier: FSFAP -# -# Summary: Wrapper for package installation, zypper or transactional update -# Maintainer: QE Core - -package wrapper; -use Mojo::Base qw(Exporter); -use testapi; -use version_utils qw(is_transactional); -use transactional qw(trup_call check_reboot_changes); -use utils qw(zypper_call); - -our @EXPORT = "install_package"; - -=head1 DESCRIPTION - - Wrapper for zypper_call and trup_call - -=head2 install_package - - install_package('kernel-devel' [, trup_packages => 'kernel-default-base] [, zypper_packages => 'kernel-devel']); - -C defines packages to install for both zypper and trup call, -Parameters C and C define transactional -or zypper specific packages. -C or C will return from fucntion, -record_info is used if sentence is argument value. -C parameter will run check_reboot_changes after trup_call, -reboot if diff between the current FS and the new snapshot. - -=cut - -sub install_package { - my $ret; - my ($packages, %args) = @_; - die 'Paramater packages is required' unless defined($packages); - my $timeout = $args{timeout} // 500; - - if (is_transactional) { - record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/; - return if $args{skip_trup}; - $packages .= ' ' . $args{trup_extra} // ''; - $ret = trup_call('pkg in -l ' . $packages, timeout => $args{timeout}); - check_reboot_changes if $args{trup_reboot}; - } - else { - record_info('install_package', $args{skip_zypper}) if $args{skip_zypper} =~ /\w+/; - return if $args{skip_zypper}; - $packages .= ' ' . $args{zypper_extra} // ''; - $ret = zypper_call('in -l ' . $packages, timeout => $args{timeout}); - } - return $ret; -} diff --git a/tests/console/year_2038_detection.pm b/tests/console/year_2038_detection.pm index dc10350e5480..66b295283503 100644 --- a/tests/console/year_2038_detection.pm +++ b/tests/console/year_2038_detection.pm @@ -25,17 +25,13 @@ use version_utils qw(is_transactional is_sle is_sle_micro is_leap is_leap_micro) use Utils::Systemd 'disable_and_stop_service'; use power_action_utils 'power_action'; use Utils::Backends 'is_pvm'; -use wrapper; - -sub install_pkg { - install_package('chrony', trup_reboot => 1); -} +use qam; sub run { my $self = shift; select_serial_terminal; - install_pkg if (script_run('rpm -qi chrony') != 0); + install_package('chrony', trup_reboot => 1) if script_run('rpm -qi chrony') != 0; systemctl("start chronyd"); # Ensure chrony is started assert_script_run('chronyc makestep'); record_info('Show current date and time', script_output('date +"%Y-%m-%d"')); diff --git a/tests/kernel/update_kernel.pm b/tests/kernel/update_kernel.pm index 55a799c0f8e1..6b333448222d 100644 --- a/tests/kernel/update_kernel.pm +++ b/tests/kernel/update_kernel.pm @@ -23,7 +23,6 @@ use repo_tools 'add_qa_head_repo'; use Utils::Backends; use LTP::utils; use transactional; -use wrapper; sub check_kernel_package { my $kernel_name = shift;