Skip to content

Commit

Permalink
Merge pull request #10657 from JRivrain/autoyast_lvm
Browse files Browse the repository at this point in the history
Add verification modules for autoyast_lvm
  • Loading branch information
Rodion I committed Jul 28, 2020
2 parents f4b4cf6 + 632069f commit ab33cc1
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 10 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 team <qa-sle-yast@suse.de>

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;
31 changes: 21 additions & 10 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) exists');
assert_script_run('lvmdiskscan -v | egrep "LVM physical volume?$"',
fail_message => 'LVM physical volume does not exist.');

record_info('ACTIVE volumes', 'Verify all Logical Volumes are ACTIVE');
Expand All @@ -39,12 +40,23 @@ sub run {
assert_equals($vol_status, 'ACTIVE', "Volume is Inactive");
}

# Sum up the Physical Extents across all Physical Volumes within each Volume group
# Then 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 @volumes = split(/\n/, script_output q[lvscan | awk '{print $2}'| sed s/\'//g]);
my $lv_size = 0;
my @pvdisplay_output = split(/\n/, script_output q[pvdisplay]);
my (@PE, @free_PE);
foreach (@pvdisplay_output) {
if ($_ =~ /.*Total PE\s*(?<total_pe>\S*)$/) {
push(@PE, $+{total_pe});
}
if ($_ =~ /.*Free PE\s*(?<total__free_pe>\S*)$/) {
push(@free_PE, $+{total_free_pe});
}
}
my $total_PEs = sum(@PE);
my $total_free_PEs = sum(@free_PE);
my @volumes = split(/\n/, script_output q[lvscan | awk '{print $2}'| sed s/\'//g]);
my $lv_size = 0;

foreach my $volume (@volumes) {
chomp;
Expand All @@ -66,10 +78,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 ab33cc1

Please sign in to comment.