Skip to content

Commit

Permalink
Introduce LVM thin volume test
Browse files Browse the repository at this point in the history
  • Loading branch information
mloviska committed Aug 6, 2018
1 parent 49ac948 commit 83a41ea
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/main_common.pm
Expand Up @@ -398,6 +398,7 @@ sub load_reboot_tests {
}
}
loadtest "installation/first_boot";
loadtest "installation/lvm_thin_check" if get_var('LVM_THIN_LV');
}
if (get_var("DUALBOOT")) {
loadtest "installation/reboot_eject_cd";
Expand Down Expand Up @@ -819,6 +820,9 @@ sub load_inst_tests {
elsif (get_var('FULL_LVM_ENCRYPT')) {
loadtest 'installation/partitioning_full_lvm';
}
elsif (get_var('LVM_THIN_LV')) {
loadtest "installation/partitioning_lvm_thin_provisioning";
}
if (get_var("FILESYSTEM")) {
if (get_var('PARTITIONING_WARNINGS')) {
loadtest 'installation/partitioning_warnings';
Expand Down
5 changes: 5 additions & 0 deletions lib/partition_setup.pm
Expand Up @@ -165,6 +165,9 @@ sub addlv {
send_key 'ret'; # create logical volume
assert_screen 'partition-lv-type';
type_string $args{name};

send_key($args{thinpool} ? 'alt-t' : $args{thinvolume} ? 'alt-i' : 'alt-o');

send_key $cmd{next};
assert_screen 'partition-lv-size';
if ($args{size}) { # use default max size if not defined
Expand All @@ -177,13 +180,15 @@ sub addlv {
type_string $args{size} . 'mb';
}
send_key $cmd{next};
return if $args{thinpool};
assert_screen 'partition-role';
send_key $partition_roles{$args{role}}; # swap role
send_key $cmd{next};
assert_screen 'partition-format';
# Add mount
mount_device $args{mount} if $args{mount};
send_key(is_storage_ng() ? $cmd{next} : $cmd{finish});
assert_screen 'expert-partitioner';
}

sub select_first_hard_disk {
Expand Down
53 changes: 53 additions & 0 deletions tests/installation/lvm_thin_check.pm
@@ -0,0 +1,53 @@
# SUSE's openQA tests
#
# Copyright © 2009-2013 Bernhard M. Wiedemann
# Copyright © 2012-2018 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: Simple LVM thin provisioning check
# Maintainer: Martin Loviska <mloviska@suse.com>

use strict;
use warnings;
use base "opensusebasetest";
use testapi;
use utils;
use y2logsstep;
use serial_terminal 'select_virtio_console';

sub run {
select_virtio_console();
record_info('INFO', 'Print lvm setup');
assert_script_run 'lsblk';
assert_script_run 'lvmdiskscan';
assert_script_run 'lvscan';
assert_script_run 'lvs -a';
assert_script_run 'pvs -a';
# thin volume does not exceed thin pool size in our tests
#my $thin_volume_size = script_output q[lvs | grep Vwi | awk '{print $(NF-1)}' | cut -d'.' -f 1];
my @volumes = split(/\n/, script_output q[lvscan | awk '{print $2}'| sed s/\'//g]);

foreach (@volumes) {
chomp;
assert_script_run "lvdisplay $_";
}

record_info('INFO', 'Create a file on thin volume');
my $test_file = '/home/bernhard/test_file.txt';
assert_script_run "dd if=/dev/zero of=$test_file count=1024 bs=1M";
assert_script_run "ls -lah /home/bernhard/test_file.txt2";
assert_script_run 'lvs -a';
}

sub post_fail_hook {
my $self = shift;
select_console 'root-console';
$self->save_and_upload_log('lvmdump', '/tmp/lvmdump_output');
}

1;

1 change: 1 addition & 0 deletions tests/installation/partitioning.pm
Expand Up @@ -49,6 +49,7 @@ sub run {
$cmd{resize} = 'alt-r';
$cmd{raw_volume} = 'alt-r';
$cmd{enable_snapshots} = 'alt-a';
$cmd{system_view} = 'alt-s';
# Set shortcut for role selection when creating partition
$partition_roles{raw} = $cmd{raw_volume};

Expand Down
62 changes: 62 additions & 0 deletions tests/installation/partitioning_lvm_thin_provisioning.pm
@@ -0,0 +1,62 @@
# SUSE's openQA tests
#
# Copyright © 2009-2013 Bernhard M. Wiedemann
# Copyright © 2012-2018 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: LVM thin provisioning setup
# Maintainer: Martin Loviska <mloviska@suse.com>

use strict;
use warnings;
use base 'y2logsstep';
use testapi;
use partition_setup qw(create_new_partition_table addpart addlv);
use version_utils 'is_storage_ng';

sub addvg {
my (%args) = @_;

assert_screen 'expert-partitioner';
send_key $cmd{system_view};
send_key_until_needlematch('volume_management_feature', 'down');
send_key $cmd{addpart};
wait_still_screen 2;
save_screenshot;
send_key 'down';
send_key 'ret';
assert_screen 'partition-add-volume-group';
send_key 'alt-v';
type_string $args{name};
wait_screen_change { send_key 'tab' } for (0 .. 1);
wait_screen_change { send_key 'spc' };
assert_screen 'partition-select-first-from-top';
send_key 'alt-a';
wait_still_screen 2;
save_screenshot;
send_key(is_storage_ng() ? $cmd{next} : $cmd{finish});
}

sub run {
create_new_partition_table;
# create boot and 2 lvm partitions
addpart(role => 'raw', fsid => 'bios-boot', size => 2);
addpart(role => 'raw', size => 10000);
addpart(role => 'raw');
# create volume group for root and swap non thin lvs
addvg(name => 'vg-no-thin');
addlv(name => 'lv-swap', role => 'swap', size => 2000);
addlv(name => 'lv-root', role => 'OS');
# create volume group for thin lv
addvg(name => 'vg-thin');
addlv(name => 'thin_pool', thinpool => 1);
addlv(name => 'thin_lv_home', role => 'data', thinvolume => 1);
send_key $cmd{accept};

}

1;

0 comments on commit 83a41ea

Please sign in to comment.