Skip to content
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

Conversation

pablo-herranz
Copy link
Contributor

@pablo-herranz pablo-herranz commented May 6, 2024

@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch from acb310e to 149f484 Compare May 6, 2024 13:44

This comment was marked as off-topic.

@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch 3 times, most recently from 1d01292 to 57cb0b2 Compare May 7, 2024 07:23
@pablo-herranz pablo-herranz marked this pull request as ready for review May 7, 2024 07:55
Copy link
Contributor

@ricardobranco777 ricardobranco777 left a 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.

tests/console/btrfs_check.pm Outdated Show resolved Hide resolved
tests/console/btrfs_check.pm Outdated Show resolved Hide resolved
@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch from 57cb0b2 to 48822fe Compare May 7, 2024 08:29
@pablo-herranz pablo-herranz marked this pull request as draft May 7, 2024 08:29
@mloviska
Copy link
Contributor

mloviska commented May 7, 2024

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 <systemdisk> section. This layout might change from flavor to flavor and products

@pablo-herranz pablo-herranz added the WIP Work in progress label May 7, 2024
@pablo-herranz pablo-herranz changed the title New test for correct btrfs setup [WIP] New test for correct btrfs setup May 7, 2024
@pablo-herranz pablo-herranz changed the title [WIP] New test for correct btrfs setup New test for correct btrfs setup May 7, 2024
@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch 16 times, most recently from 0baf37f to a1a4dd1 Compare May 10, 2024 09:49
Copy link
Contributor

@mloviska mloviska left a 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.

sub run {
select_console 'root-console';

my $kiwi_volumes = qq(
Copy link
Contributor

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.

Copy link
Contributor Author

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?

/usr/local
/var);

my $test_volumes = script_output("lsblk --list --noheadings --output MOUNTPOINTS /dev/vda3 | sort");
Copy link
Contributor

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

Copy link
Contributor Author

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.

record_info('test_volumes', "$test_volumes");
record_info('kiwi_volumes', "$kiwi_volumes");
die "Volumes mismatch from Kiwi definition"
if $kiwi_volumes !~ $test_volumes;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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;
Copy link
Contributor

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

Copy link
Contributor Author

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 😅

Copy link
Member

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.

@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch 9 times, most recently from 43e9605 to 301d6ed Compare May 16, 2024 09:49
@pablo-herranz pablo-herranz removed the WIP Work in progress label May 16, 2024
@pablo-herranz pablo-herranz marked this pull request as ready for review May 16, 2024 11:38
@pablo-herranz pablo-herranz added the RFC Request for Comments label May 16, 2024

# 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);
Copy link
Member

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

# Compare that the lists of subvolumes match
foreach my $kiwi (@kiwi_volumes) {
my $found = 0;
foreach my $test (@test_volumes) {
Copy link
Contributor

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

Suggested change
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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch 3 times, most recently from f70f66c to c6b5186 Compare May 16, 2024 12:56
@pablo-herranz pablo-herranz added the WIP Work in progress label May 16, 2024
@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch from c6b5186 to ac6a1ac Compare May 16, 2024 13:08
@pablo-herranz pablo-herranz removed WIP Work in progress RFC Request for Comments labels May 17, 2024
use List::Util qw(any);

sub run {
select_console 'root-console';
Copy link
Member

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;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✔️

@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch 2 times, most recently from 276ede7 to 2ab14dd Compare May 20, 2024 07:40
The main idea is to check for the correct btrfs layout on the disk. Snapshots and rollbacks are already covered in other test modules.
@pablo-herranz pablo-herranz force-pushed the poo66613_test-for-correct-btrfs-setup branch from 2ab14dd to c94c212 Compare May 20, 2024 08:26
@pablo-herranz pablo-herranz merged commit 7095520 into os-autoinst:master May 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants