Skip to content

Commit

Permalink
Add snapper-zypp-plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
cedvid committed Jan 10, 2025
1 parent 80b91b1 commit 66068cd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/main_common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions tests/console/snapper_zypp.pm
Original file line number Diff line number Diff line change
@@ -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 <qe-core@suse.de>

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;

0 comments on commit 66068cd

Please sign in to comment.