From 66068cd66e8244e5e3f292daf28c15da13be34cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Vidot?= Date: Wed, 13 Nov 2024 10:54:03 +0100 Subject: [PATCH] Add snapper-zypp-plugin test https://progress.opensuse.org/issues/168079 --- lib/main_common.pm | 1 + schedule/functional/extra_tests_textmode.yaml | 1 + tests/console/snapper_zypp.pm | 44 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 tests/console/snapper_zypp.pm diff --git a/lib/main_common.pm b/lib/main_common.pm index 162027298e68..82667ce1cbb5 100644 --- a/lib/main_common.pm +++ b/lib/main_common.pm @@ -1641,6 +1641,7 @@ sub load_extra_tests_zypper { replace_opensuse_repos_tests if is_repo_replacement_required; loadtest "console/zypper_lr_validate" unless is_sle '15+'; loadtest "console/zypper_ref"; + loadtest "console/snapper_zypp"; unless (is_jeos) { loadtest "console/zypper_info"; } diff --git a/schedule/functional/extra_tests_textmode.yaml b/schedule/functional/extra_tests_textmode.yaml index 70355ba5bedd..852104dc0cb5 100644 --- a/schedule/functional/extra_tests_textmode.yaml +++ b/schedule/functional/extra_tests_textmode.yaml @@ -124,6 +124,7 @@ schedule: - console/zypper_lr_validate - console/zypper_ref - console/zypper_info + - console/snapper_zypp - '{{validate_packages_and_patterns}}' - console/zypper_extend - console/check_os_release diff --git a/tests/console/snapper_zypp.pm b/tests/console/snapper_zypp.pm new file mode 100644 index 000000000000..b6f8a18e47b5 --- /dev/null +++ b/tests/console/snapper_zypp.pm @@ -0,0 +1,44 @@ +# SUSE's openQA tests +# +# Copyright SUSE LLC +# SPDX-License-Identifier: FSFAP +# Summary: Simple 'snapper-zypp-plugin' test +# 1. Ensure 'snapper-zypp-plugin' is installed +# 2. Get latest snapshot id number +# 3. Install/remove package +# 4. Ensure id number incremented by 2 (pre/post snapshots were created) +# Maintainer: QE Core + +use base "consoletest"; +use strict; +use warnings; +use testapi; +use serial_terminal 'select_serial_terminal'; +use utils; +use version_utils 'is_sle'; +use Test::Assert 'assert_equals'; + +sub get_snapshot_id { + my $snapshot_id = is_sle("<=12-SP5") ? '$3' : '$1'; + return script_output("snapper ls | awk 'END {print $snapshot_id}'"); +} + +sub run_zypper_cmd { + my $zypper_cmd = shift; + my $before_snapshot_id = get_snapshot_id(); + zypper_call($zypper_cmd); + my $after_snapshot_id = get_snapshot_id(); + record_info("Snapshot IDs", "Before: $before_snapshot_id, After: $after_snapshot_id"); + assert_equals($after_snapshot_id, $before_snapshot_id + 2, "Snapshot ID did not increment as expected"); +} + +sub run { + select_serial_terminal; + my $package = "vim"; + + assert_script_run("rpm -q snapper-zypp-plugin"); + run_zypper_cmd("rm $package"); + run_zypper_cmd("in $package"); +} + +1;