Skip to content

Commit

Permalink
Add verification modules for autoyast_lvm
Browse files Browse the repository at this point in the history
  • Loading branch information
JRivrain committed Jul 23, 2020
1 parent 7043fd2 commit b0b027a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 7 deletions.
42 changes: 42 additions & 0 deletions schedule/yast/autoyast/autoyast_lvm.yaml
Expand Up @@ -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
Expand All @@ -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
28 changes: 28 additions & 0 deletions 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 <qa-sle-yast@suse.com>

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;
44 changes: 37 additions & 7 deletions tests/console/validate_lvm.pm
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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" |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;
Expand All @@ -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";
Expand Down

0 comments on commit b0b027a

Please sign in to comment.