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

Capture installed and uninstalled packages during test #15340

Merged
merged 1 commit into from
Aug 15, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/main_common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ sub load_consoletests {
}
loadtest "console/nginx" if ((is_opensuse && !is_staging) || (is_sle('15+') && !is_desktop));
loadtest 'console/orphaned_packages_check' if is_jeos || get_var('UPGRADE') || get_var('ZDUP') || !is_sle('<12-SP4');
loadtest "console/zypper_log_packages" unless x11tests_is_applicable();
loadtest "console/consoletest_finish";
}

Expand Down Expand Up @@ -1447,6 +1448,7 @@ sub load_x11tests {
loadtest "x11/reboot_lxde";
}
}
loadtest "console/zypper_log_packages";
# Need to skip shutdown to keep backend alive if running rollback tests after migration
unless (get_var('ROLLBACK_AFTER_MIGRATION')) {
load_shutdown_tests;
Expand Down
25 changes: 25 additions & 0 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,31 @@ sub zypper_call {
}
last;
}

# log all install and remove actions for later use by tests/console/zypper_log_packages.pm
my @packages = split(" ", $command);
for (my $i = 0; $i < scalar(@packages); $i++) {
if ($packages[$i] eq "--root" || $packages[$i] eq "-R") {
splice(@packages, $i, 2);
}
}
@packages = grep(/^[^-]/, @packages);
my $zypper_action = shift(@packages);
$zypper_action = "install" if ($zypper_action eq "in");
$zypper_action = "remove" if ($zypper_action eq "rm");
if ($zypper_action =~ m/^(install|remove)$/) {
push(@{$testapi::distri->{zypper_packages}}, {
raw_command => $command,
action => $zypper_action,
packages => \@packages,
return_code => $ret,
test => {
module => $autotest::current_test->{name},
category => $autotest::current_test->{category}
}
});
}

upload_logs("/tmp/$log") if $log;

unless (grep { $_ == $ret } @$allow_exit_codes) {
Expand Down
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_clamav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ schedule:
- installation/bootloader_start
- boot/boot_to_desktop
- console/clamav
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_dracut.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ schedule:
- boot/boot_to_desktop
- console/dracut
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_gnome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ schedule:
- console/check_default_network_manager
- '{{python_liblouis}}'
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_gnome_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ schedule:
- console/consoletest_setup
- x11/libqt5_qtbase
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_gnuhealth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ schedule:
- gnuhealth/gnuhealth_client_install
- gnuhealth/gnuhealth_client_preconfigure
- gnuhealth/gnuhealth_client_first_time
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ schedule:
- console/journalctlLevels
- console/perf
- '{{tw_tests}}'
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_networkd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ schedule:
- networkd/networkd_vlan
- networkd/networkd_bridge
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_ovs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ schedule:
- installation/bootloader_start
- network/setup_multimachine
- '{{ovs}}'
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ schedule:
- qemu/qemu
- '{{kvm}}'
- '{{user}}'
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ schedule:
- '{{tumbleweed_tests}}'
- console/tar
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode_mod_desktop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ schedule:
- console/consoletest_setup
- '{{tests_requiring_soundcard}}'
- console/libvorbis
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode_phub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ schedule:
- console/vmstat
- console/sssd_389ds_functional
- console/coredump_collect
- console/zypper_log_packages
conditional_schedule:
wpa_supplicant:
ARCH:
Expand Down
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ schedule:
- boot/boot_to_desktop
- console/gdb
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_toolkits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ schedule:
- x11/toolkits/qt5
- x11/toolkits/swing
- console/coredump_collect
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_transactional_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ schedule:
- transactional/transactional_update
- transactional/rebootmgr
- transactional/health_check
- console/zypper_log_packages
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_webframeworks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ schedule:
- console/prepare_test_data
- console/django
- console/flask
- console/zypper_log_packages
1 change: 1 addition & 0 deletions t/data/test_schedule.out
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ tests/x11/kate.pm
tests/x11/amarok.pm
tests/x11/kontact.pm
tests/x11/reboot_plasma5.pm
tests/console/zypper_log_packages.pm
tests/shutdown/shutdown.pm
50 changes: 50 additions & 0 deletions tests/console/zypper_log_packages.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SUSE's openQA tests
#
# Copyright 2022 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Package: zypper
# Summary: gather info about installed/removed packages during the test
# Maintainer: Dominik Heidler <dheidler@suse.de>

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

use Mojo::UserAgent;
use Mojo::JSON qw(to_json);

sub run {
my $self = shift;
$self->select_serial_terminal;
my $zypper_packages = {};
$zypper_packages->{commands} = $testapi::distri->{zypper_packages} // [];
my $individual_pkgs = script_output('grep "|\(Installing:\|Removing\) .*} END" /var/log/zypper.log', proceed_on_failure => 1);
# this looks like this:
# 2022-08-05 12:18:55 <1> athene(13626) [Progress++] progressdata.cc(report):89 {#24|Installing: xosview-1.22-1.10.x86_64} END
# 2022-08-05 12:19:48 <1> athene(13993) [Progress++] progressdata.cc(report):89 {#21|Removing xosview-1.22-1.10.x86_64} END
while ($individual_pkgs =~ m/\|([A-Z][a-z]*):? ([^}]*)}/g) {
my $action;
if ($1 eq "Installing") { $action = "install"; }
elsif ($1 eq "Removing") { $action = "remove"; }
$2 =~ m/(.+)-([^-]+)-([^-]+)\.([^.]+)/;
push(@{$zypper_packages->{individual_pkgs}}, {
action => $action,
package => $1,
version => $2,
release => $3,
arch => $4,
});
}

my $ua = Mojo::UserAgent->new;
my $res = $ua->post(autoinst_url("/uploadlog/zypper_packages.json") => form => {
upload => {content => to_json($zypper_packages)},
uname => "zypper_packages.json"
})->result;
record_info('zypper_packages.json', 'zypper_packages.json was uploaded via worker', result => ($res->is_success) ? 'ok' : 'fail');
}

1;