-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add raid validation test #7182
Merged
Merged
Add raid validation test #7182
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# SUSE's openQA tests | ||
# | ||
# Copyright © 2019 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 RAID partitioning layout validation | ||
# Maintainer: Joaquín Rivera <jeriveramoya@suse.com> | ||
|
||
use strict; | ||
use warnings; | ||
use base "opensusebasetest"; | ||
use testapi; | ||
use version_utils 'is_sle'; | ||
use Test::Assert ':all'; | ||
|
||
# | ||
# Define blocks of expected data for partitioning layout in different products and architectures | ||
# | ||
# 4 btrfs partitions mounted on / in raid partition | ||
my $btrfs = qr/(md0(p1)?.+btrfs.+\/.*){4}/s; | ||
# 4 swap partitions in raid partition | ||
my $swap = qr/(md((1|2)p1)?.+swap.+\[SWAP\].*){4}/s; | ||
# 8 raid partitions | ||
my $raid_partitions_2_arrays = qr/(md(0|1).*){8}/s; | ||
# 12 raid partitions | ||
my $raid_partitions_3_arrays = qr/(md(0|1|2).*){12}/s; | ||
# 8 linux raid members | ||
my $linux_raid_member_2_arrays = qr/(vd(a|b|c|d)(2|3).+linux_raid_member.*){8}/s; | ||
# 12 linux raid members | ||
my $linux_raid_member_3_arrays = qr/(vd(a|b|c|d)(1|2|3|4).+linux_raid_member.*){12}/s; | ||
# 4 hard disks | ||
my $hard_disks = qr/(vd(a|b|c|d)\D+.*){4}/s; | ||
# 4 ext4 partitions mounted on /boot | ||
my $ext4_boot = qr/(md1(p1)?.+ext4.+\/boot.*){4}/s; | ||
# Unique vfat partition in first disk (mounted on /boot) | ||
my $vfat_efi = qr/vda1.+vfat.\s+\/boot\/efi.*(vd(b|c|d)1(?!.*vfat).*){3}/s; | ||
# | ||
# Define blocks of expected data for raid configuration in different products and architectures | ||
# | ||
# RAID arrays | ||
my @raid_arrays = qw(/dev/md0 /dev/md1); | ||
# Number of array devices | ||
my $num_raid_arrays = @raid_arrays; | ||
# RAID level from settings | ||
my $level = get_required_var('RAIDLEVEL'); | ||
# RAID array with corresponding RAID level | ||
my $raid_level = qr/\/dev\/md0:.*?Raid Level : raid$level/s; | ||
# RAID array always with level 0 | ||
my $raid0 = qr/\/dev\/md(1|2):.*?Raid Level : raid0/s; | ||
# RAID array always with level 1? why? | ||
my $raid1 = qr/\/dev\/md1:.*?Raid Level : raid1/s; | ||
my @raid_detail = ( | ||
# 4 RAID devices per RAID array | ||
/(Raid Devices : 4.*){$num_raid_arrays}/s, | ||
# 4 active RAID devices per RAID array | ||
/(Active Devices : 4.*){$num_raid_arrays}/s, | ||
# 4 working RAID devices per RAID array | ||
/(Working Devices : 4.*){$num_raid_arrays}/s, | ||
# 1st raid device per RAID array, i.e.: /dev/vda2 | ||
/(0.*\/dev\/\w{2}a\d.*){$num_raid_arrays}/s, | ||
# 2nd raid device per RAID array, i.e.: /dev/vdb2 | ||
/(1.*\/dev\/\w{2}b\d.*){$num_raid_arrays}/s, | ||
# 3rd raid device per RAID array, i.e.: /dev/vdc2 | ||
/(2.*\/dev\/\w{2}c\d.*){$num_raid_arrays}/s, | ||
# 4th raid device per RAID array, i.e.: /dev/vdd2 | ||
/(3.*\/dev\/\w{2}d\d.*){$num_raid_arrays}/s, | ||
); | ||
# Store test data to test expected partitioning/raid in specific architecture/product | ||
my ( | ||
@partitioning, | ||
@raid, | ||
); | ||
# Prepare test data depending on specific architecture/product | ||
sub prepare_test_data { | ||
if (check_var('ARCH', 'ppc64le')) { | ||
@partitioning = ( | ||
$raid_partitions_3_arrays, $hard_disks, $linux_raid_member_3_arrays, | ||
$ext4_boot, | ||
$btrfs, $swap, | ||
); | ||
# Additional RAID array (update num_raid_arrays to regenerate regex) | ||
push(@raid_arrays, '/dev/md2'); | ||
$num_raid_arrays = @raid_arrays; | ||
@raid = (($raid_level, $raid0, $raid1), @raid_detail); | ||
} | ||
elsif (check_var('ARCH', 'aarch64')) { | ||
@partitioning = @partitioning = ( | ||
$raid_partitions_2_arrays, $hard_disks, $linux_raid_member_2_arrays, | ||
$vfat_efi, | ||
$btrfs, $swap, | ||
); | ||
} | ||
elsif (check_var('ARCH', 'x86_64')) { | ||
if (is_sle('<15')) { | ||
@partitioning = ( | ||
$btrfs, $ext4_boot, $swap, | ||
$hard_disks, $linux_raid_member_3_arrays, | ||
); | ||
# Additional RAID array (update num_raid_arrays to regenerate regex) | ||
push(@raid_arrays, '/dev/md2'); | ||
$num_raid_arrays = @raid_arrays; | ||
@raid = (($raid_level, $raid0, $raid1), @raid_detail); | ||
} | ||
} | ||
else { | ||
@partitioning = ( | ||
$raid_partitions_2_arrays, $hard_disks, $linux_raid_member_2_arrays, | ||
$btrfs, $swap, | ||
); | ||
@raid = (($raid_level, $raid0), @raid_detail); | ||
} | ||
} | ||
|
||
sub command_output { | ||
my %args = @_; | ||
my $name = $args{name}; | ||
my $options = $args{options}; | ||
my $description = "$args{description}\n$name $options"; | ||
my @expected = @{$args{matches}}; | ||
record_info($name, $description); | ||
my $actual = script_output("$name $options"); | ||
assert_matches($_, $actual, "Partition not found") for (@expected); | ||
} | ||
|
||
sub run { | ||
select_console 'root-console'; | ||
prepare_test_data; | ||
command_output( | ||
name => 'lsblk', | ||
options => '--list --output NAME,FSTYPE,MOUNTPOINT', | ||
description => 'Verify partitioning', | ||
matches => \@partitioning, | ||
); | ||
command_output( | ||
name => 'mdadm', | ||
options => "--detail " . join(' ', @raid_arrays), | ||
description => 'Verify raid configuration', | ||
matches => \@raid, | ||
); | ||
} | ||
|
||
1; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, our idea with named regexp will require too many changes to the PR. But for your info, here is how it could look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for those cases it would work but most of the regex are taking into account repetition. I didn't find in perl the way to capture in cases like this:
(md(?<number>\d).*){8}
Basically .* matches until the end of the full output, the break line is treated as another character with /s modifier and not sure how to call it later in case it would be possible unless hash $+{number} could contain an array, but this is also bad example as "md" would remain out of the match, but just to explain what I found tricky. We'll figure out all together, thanks! :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we don't have answer yet, but your PR shows us that there is a question we need to answer =)