-
Notifications
You must be signed in to change notification settings - Fork 266
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
New test for correct btrfs setup #19242
New test for correct btrfs setup #19242
Conversation
acb310e
to
149f484
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
1d01292
to
57cb0b2
Compare
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.
I'm not sure this PR addresses the requirements setup in the poo ticket as it only runs some commands that are guaranteed not to fail, without validating anything.
57cb0b2
to
48822fe
Compare
The main point of the ticket is to check the layout of images. So the test should run only for minimal-vm or sle-micro. This layout is defined by the corresponding kiwi file. For jeos/minimal-vm it is https://build.suse.de/projects/SUSE:SLE-15-SP6:GA:TEST/packages/kiwi-templates-Minimal/files/Minimal.kiwi?expand=1 defined by |
0baf37f
to
a1a4dd1
Compare
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.
I like the approach so far, however we really need to test this code thoroughly with different hypervisors. Please use jeos-filesystem
test suite from the latest job group.
tests/console/btrfs_check.pm
Outdated
sub run { | ||
select_console 'root-console'; | ||
|
||
my $kiwi_volumes = qq( |
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.
this will a bit more complicated. Given the fact that we have 3 archs (no ppc) the layout will differ. Especially when we are talking about boot subvolumes.
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.
Any clues for checking all the possibilities?
tests/console/btrfs_check.pm
Outdated
/usr/local | ||
/var); | ||
|
||
my $test_volumes = script_output("lsblk --list --noheadings --output MOUNTPOINTS /dev/vda3 | sort"); |
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.
I would rather see a list of subvolumes, hence using btrfs commands, but that might be a matter of taste. The good part is that with subvolumes you would use /
rather than a drive. Drives might have different labels, depends on hypervisor mostly
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.
Nice, I'll see if I can remove all the "unnecessary" info and keep only the last column for comparison purposes.
tests/console/btrfs_check.pm
Outdated
record_info('test_volumes', "$test_volumes"); | ||
record_info('kiwi_volumes', "$kiwi_volumes"); | ||
die "Volumes mismatch from Kiwi definition" | ||
if $kiwi_volumes !~ $test_volumes; |
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.
Not sure whether this works or not. The order is always guaranteed? I think nested loops would be more robust.
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.
Yep, nice idea. I'm already working on it.
tests/console/btrfs_check.pm
Outdated
assert_script_run('rpm -qa > /tmp/rpm_qa.txt'); | ||
upload_logs('/tmp/rpm_qa.txt'); | ||
upload_logs('/var/log/zypper.log'); | ||
$self->SUPER::post_fail_hook; |
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.
This needs to be reworked. We are interested in the filesystem, hence a custom post_fail_hook would suit better here
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.
This is my first time writing a post_fail_hook
, so I just copy-pasted 😅
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.
IMO this does not need a custom post_fail_hook
at all. All relevant info for possible failures is already visible.
43e9605
to
301d6ed
Compare
tests/console/btrfs_check.pm
Outdated
|
||
# Prepare the arrays of subvolumes for comparing | ||
# TODO: the subvolumes list vary depending on the arch and the version | ||
my @kiwi_volumes = qw(@ @/.snapshots @/home @/opt @/root @/srv @/tmp @/usr/local @/var); |
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.
/tmp
is a tmpfs on SL(E)M and openSUSE and must not be a subvolume
tests/console/btrfs_check.pm
Outdated
# Compare that the lists of subvolumes match | ||
foreach my $kiwi (@kiwi_volumes) { | ||
my $found = 0; | ||
foreach my $test (@test_volumes) { |
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.
This can be simplified by using the any
module from List::Util
I think
foreach my $test (@test_volumes) { | |
die "Subvolume $kiwi not present" unless (any {$_ eq $kiwi} @test_volumes); |
And you will need a use List::Util 'any';
in the beginning.
I think that can simplify this routine a lot.
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.
Let's put this to the test!
https://www.youtube.com/watch?v=sByxTCQU8Rc
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.
I'll remember this reference.
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.
You're goddamn right!!
https://youtu.be/S9RVS8cjNN0
f70f66c
to
c6b5186
Compare
c6b5186
to
ac6a1ac
Compare
tests/console/btrfs_check.pm
Outdated
use List::Util qw(any); | ||
|
||
sub run { | ||
select_console 'root-console'; |
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.
Could use select_serial_terminal;
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.
Done ✔️
276ede7
to
2ab14dd
Compare
The main idea is to check for the correct btrfs layout on the disk. Snapshots and rollbacks are already covered in other test modules.
2ab14dd
to
c94c212
Compare
The main idea is to check for the correct btrfs layout on the disk. Snapshots and rollbacks are already covered in other test modules.