Skip to content

Commit

Permalink
6
Browse files Browse the repository at this point in the history
  • Loading branch information
mloviska committed Aug 7, 2018
1 parent 783b431 commit 8b34729
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/console/lvm_thin_check.pm
Expand Up @@ -21,10 +21,11 @@ use serial_terminal 'select_virtio_console';

sub run {
my $lv_stats = {
write_access => 'read/write',
status => 'available',
readahead => 'auto',
block_device => "\d+:\d"
write_access => qr/\s{2}LV Write Access \s+ read\/write/,
status => qr/\s{2}LV Status \s+ available/,
readahead => qr/\s{2}Read ahead sectors \s+ auto/,
# 254 as major no. points to dev-mapper, see /proc/devices
block_device => qr/\s{2}Block device \s+ 254:\d/
};

select_virtio_console();
Expand All @@ -37,10 +38,12 @@ sub run {
# thin volume does not exceed thin pool size in our tests
my @volumes = split(/\n/, script_output q[lvscan | awk '{print $2}'| sed s/\'//g]);
# check for read only volumes and
foreach (@volumes) {
foreach my $volume (@volumes) {
chomp;
my $lvdisp_out = script_output "lvdisplay $volume";
foreach (keys %{$lv_stats}) {
chomp;
assert_script_run "lvdisplay $_ | grep $lv_stats->{$_}";
die "Value of $_" unless ($lvdisp_out =~ /(?<tested_string>$lv_stats->{$_})/);
record_info('TEST', "Found $+{tested_string} in $volume");
}
}

Expand All @@ -49,16 +52,17 @@ sub run {
assert_script_run "dd if=/dev/zero of=$test_file count=1024 bs=1M";
assert_script_run "ls -lah $test_file";
assert_script_run 'lvs -a | tee instant_usage';
if ((assert_script_run 'diff original_usage instant_usage') != 1) {
if ((script_run 'diff original_usage instant_usage') != 1) {
die "LVM usage stats do not differ!";
}
}

sub post_fail_hook {
my $self = shift;
select_console 'root-console';
my $lvmdump_regex = "\/root\/ldmdump-.*-\d+\.tgz";
if (script_output 'lvmdump' =~ /(?<lvmdump_gzip>$lvmdump_regex)/) {
my $lvmdump_regex = qr{/root/lvmdump-.*?-\d+\.tgz};
my $out = script_output 'lvmdump';
if ($out =~ /(?<lvmdump_gzip>$lvmdump_regex)/) {
upload_logs "$+{lvmdump_gzip}";
}
$self->save_and_upload_log('lvm dumpconfig', '/tmp/lvm_dumpconf.out');
Expand Down

0 comments on commit 8b34729

Please sign in to comment.