diff --git a/schedule/yast/autoyast/autoyast_lvm.yaml b/schedule/yast/autoyast/autoyast_lvm.yaml index c8f7fb377d43..6fae426df713 100644 --- a/schedule/yast/autoyast/autoyast_lvm.yaml +++ b/schedule/yast/autoyast/autoyast_lvm.yaml @@ -13,6 +13,8 @@ schedule: - autoyast/installation - autoyast/console - autoyast/login + - console/validate_lvm + - autoyast/verify_lvm_partitions - autoyast/wicked - autoyast/autoyast_verify - autoyast/repos @@ -21,3 +23,43 @@ schedule: - autoyast/autoyast_reboot - installation/grub_test - installation/first_boot + - autoyast/verify_cloned_profile +test_data: + profile: + partitioning: + - drive: + unique_key: device + device: /dev/system + partitions: + - partition: + unique_key: lv_name + lv_name: root_lv + mount: / + - partition: + unique_key: lv_name + lv_name: opt_lv + mount: /opt + - partition: + unique_key: lv_name + lv_name: swap_lv + mount: swap + - drive: + unique_key: device + device: /dev/sda + partitions: + - partition: + unique_key: partition_nr + partition_nr: 1 + lvm_group: system + - partition: + unique_key: partition_nr + partition_nr: 2 + - partition: + unique_key: partition_nr + partition_nr: 3 + lvm: + vg: system + lvs: + - root_lv + - opt_lv + - swap_lv diff --git a/tests/autoyast/verify_lvm_partitions.pm b/tests/autoyast/verify_lvm_partitions.pm new file mode 100644 index 000000000000..939153d3df94 --- /dev/null +++ b/tests/autoyast/verify_lvm_partitions.pm @@ -0,0 +1,28 @@ +# SUSE's openQA tests +# +# Copyright © 2020 SUSE LLC +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. +# +# Summary: Verify lvm partitions after autoyast installation +# Maintainer: qa-sle-yast + +use strict; +use warnings; +use parent 'installbasetest'; +use testapi; +use scheduler 'get_test_suite_data'; + +sub run { + my $test_data = get_test_suite_data(); + my $vg = $test_data->{lvm}->{vg}; + assert_script_run("vgdisplay $vg"); + foreach my $lv (@{$test_data->{lvm}->{lvs}}) { + assert_script_run("lvdisplay /dev/$vg/$lv"); + } +} + +1; diff --git a/tests/console/validate_lvm.pm b/tests/console/validate_lvm.pm index 6a4c09e8fdf1..e8bd1cae12dc 100644 --- a/tests/console/validate_lvm.pm +++ b/tests/console/validate_lvm.pm @@ -18,6 +18,7 @@ use utils; use y2_module_basetest 'workaround_suppress_lvm_warnings'; use Test::Assert ':all'; use Mojo::JSON 'decode_json'; +use List::Util 'sum'; sub pre_run_hook { select_console('root-console'); @@ -29,8 +30,8 @@ sub run { assert_script_run('lvmconfig --mergedconfig --validate | grep "LVM configuration valid."', fail_message => 'LVM config validation failed'); - record_info('LVM volume', 'Verify the LVM physical volume exists'); - assert_script_run('lvmdiskscan -v | grep "1 LVM physical volume"', + record_info('LVM volume', 'Verify the LVM physical volume(s) exist'); + assert_script_run('lvmdiskscan -v | egrep "[[:digit:]] LVM physical volume[s]{0,1}$"', fail_message => 'LVM physical volume does not exist.'); record_info('ACTIVE volumes', 'Verify all Logical Volumes are ACTIVE'); @@ -39,9 +40,39 @@ sub run { assert_equals($vol_status, 'ACTIVE', "Volume is Inactive"); } + # Sum up the Physical Extents across all Physical Volumes within each Volume group + # of a given system. So it gives us : $PEs_in_VGs{$vg} = [@extents_in_vg] + # Then do the same for the free extents, so we can compare total PEs with total logical extents. record_info('equal extents', 'Verify sum of logical extents corresponds to physical extent size'); - my $pvTotalPE = script_output q[pvdisplay|grep "Total PE" | awk '{print $3}']; - my $pvFreePE = script_output q[pvdisplay|grep "Free PE" | awk '{print $3}']; + my @PV = split(/\n/, script_output qq[pvdisplay |grep "PV Name" |awk '{print \$3}']); + my @VG = split(/\n/, script_output qq[vgdisplay |grep "VG Name" |awk '{print \$3}']); + my %PEs_in_PVs; + my %FEs_in_PVs; + + foreach my $vg (@VG) { + my @extents_in_vg; + my @free_extents_in_vg; + foreach my $pv (@PV) { + my $vg_for_pv = script_output qq[pvdisplay $pv |grep "VG Name" |awk '{print \$3}']; + chomp($vg_for_pv); + if ("$vg_for_pv" eq "$vg") { + my $extents_in_pv = script_output qq[pvdisplay $pv |grep "Total PE" |awk '{print \$3}']; + my $free_extents_in_pv = script_output qq[pvdisplay $pv |grep "Free PE" |awk '{print \$3}']; + chomp($extents_in_pv, $free_extents_in_pv); + push(@extents_in_vg, $extents_in_pv); + push(@free_extents_in_vg, $free_extents_in_pv); + } + $PEs_in_PVs{$vg} = [@extents_in_vg]; + $FEs_in_PVs{$vg} = [@free_extents_in_vg]; + } + } + + my $total_PEs; + my $total_free_PEs; + foreach my $vg (keys %PEs_in_PVs) { + $total_PEs = sum @{$PEs_in_PVs{$vg}}; + $total_free_PEs = sum @{$FEs_in_PVs{$vg}}; + } my @volumes = split(/\n/, script_output q[lvscan | awk '{print $2}'| sed s/\'//g]); my $lv_size = 0; @@ -66,10 +97,9 @@ sub run { } die "Partitions not found in $volume configuration: \n $results" if ($results); } - assert_equals($pvTotalPE - $pvFreePE, $lv_size, "Sum of Logical Extents differs!"); - + assert_equals($total_PEs - $total_free_PEs, $lv_size, "Sum of Logical Extents differs!"); record_info('LVM usage stats', 'Verify LVM usage stats are updated after adding a file.'); - my $test_file = '/home/bernhard/test_file.txt'; + my $test_file = '/home/test_file.txt'; assert_script_run 'df -h | tee original_usage'; assert_script_run "dd if=/dev/zero of=$test_file count=1024 bs=1M"; assert_script_run "ls -lah $test_file";