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

Adjust modify_existing_partition to the UI chnages in the Expert Partitioner #11531

Merged
merged 10 commits into from
Dec 3, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,22 @@ sub set_new_partition_size {
sub resize_partition {
my ($self, $args) = @_;
my $part = $args->{partition};
$self->get_expert_partitioner_page()->select_disk_device_in_table({
disk => $args->{disk},
nr => $part->{nr}
});
$self->get_expert_partitioner_page()->select_disk_partition({disk => $args->{disk}, partition => $part->{name}});
$self->get_expert_partitioner_page()->open_resize_device();
$self->get_resize_page()->set_custom_size($part->{size});
$self->get_resize_page()->press_next();
$self->get_small_for_snapshots_warning()->press_yes();
}

sub edit_partition_on_gpt_disk {
my ($self, $args) = @_;
my $part = $args->{partition};
$self->get_expert_partitioner_page()->select_disk_partition({disk => $args->{disk}, partition => $part->{name}});
$self->get_expert_partitioner_page()->press_edit_partition_button();
$self->get_edit_formatting_options_page()->select_format_device_radiobutton($part->{formatting_options}->{skip});
$self->get_edit_formatting_options_page()->select_filesystem($part->{formatting_options}->{filesystem}, $part->{formatting_options}->{skip});
$self->get_edit_formatting_options_page()->select_mount_device_radiobutton();
$self->get_edit_formatting_options_page()->fill_in_mount_point_field($part->{mounting_options}->{mount_point});
$self->get_edit_formatting_options_page()->press_next();
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sub init {
my $self = shift;

$self->{btn_add_partition} = $self->{app}->button({id => '"Y2Partitioner::Widgets::PartitionAddButton"'});
$self->{btn_edit_partition} = $self->{app}->button({id => '"Y2Partitioner::Widgets::BlkDeviceEditButton"'});
$self->{btn_lvm_add_vg} = $self->{app}->button({id => '"Y2Partitioner::Widgets::LvmVgAddButton"'});
$self->{btn_lvm_add_lv} = $self->{app}->button({id => '"Y2Partitioner::Widgets::LvmLvAddButton"'});
$self->{btn_add_raid} = $self->{app}->button({id => '"Y2Partitioner::Widgets::MdAddButton"'});
Expand Down Expand Up @@ -83,6 +84,11 @@ sub press_add_partition_button {
return $self->{btn_add_partition}->click();
}

sub press_edit_partition_button {
my ($self) = @_;
return $self->{btn_edit_partition}->click();
}

sub press_add_volume_group_button {
my ($self) = @_;
return $self->{btn_lvm_add_vg}->click();
Expand Down Expand Up @@ -111,6 +117,14 @@ sub select_disk {
return $self;
}

sub select_disk_partition {
my ($self, $args) = @_;
$self->select_disk($args->{disk});
$self->{tbl_devices}->select(value => '/dev/' . $args->{disk} . '|' . $args->{partition});
send_key('up');
send_key('down');
}

sub select_raid {
my ($self, $disk) = @_;
return $self->select_item_in_system_view_table('RAID');
Expand All @@ -126,12 +140,12 @@ sub select_volume_group {
return $self->select_item_in_system_view_table('LVM Volume Groups|' . $vg);
}

sub select_disk_device_in_table {
sub select_logical_volume {
my ($self, $args) = @_;
my $dev = "/dev/$args->{disk}|$args->{disk}$args->{nr}";
$self->{tbl_devices}->select(value => $dev);
send_key('down');
$self->select_volume_group($args->{vg});
$self->{tbl_lvm_devices}->select(value => '/dev/' . $args->{vg} . '|' . $args->{lv});
send_key('up');
send_key('down');
}

1;
10 changes: 9 additions & 1 deletion schedule/yast/lvm/lvm+resize_root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ schedule:
- console/consoletest_finish
- console/validate_modify_existing_partition
test_data:
disks:
- name: vda
partitions:
- name: root
size: 45G
formatting_options:
filesystem: btrfs
mounting_options:
mount_point: /
root:
disk: current-volume-management
existing_partition: root
mount_point: /
expert_partitioner_from: current
part_size: 45GiB
lsblk_expected_size_output: 45G
6 changes: 4 additions & 2 deletions schedule/yast/modify_existing_partition_opensuse.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: modify_existing_partition_opensuse
description: >
Installation where we modify some pre-existing partitions. Must depend on some create_hdd test suite.

vars:
YUI_REST_API: 1
schedule:
- installation/isosize
- installation/bootloader_start
- installation/setup_libyui
- installation/welcome
- installation/online_repos
- installation/installation_mode
Expand All @@ -21,6 +22,7 @@ schedule:
- installation/await_install
- installation/logs_from_installation_system
- installation/reboot_after_installation
- installation/teardown_libyui
- installation/grub_test
- installation/first_boot
- console/validate_modify_existing_partition
Expand Down
4 changes: 4 additions & 0 deletions schedule/yast/modify_existing_partition_sle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: modify_existing_partition
description: >
Installation where we modify some pre-existing partitions. Must depend on some
create_hdd test suite.
vars:
YUI_REST_API: 1
schedule:
- installation/bootloader_start
- installation/setup_libyui
- installation/welcome
- installation/accept_license
- installation/scc_registration
Expand All @@ -23,6 +26,7 @@ schedule:
- installation/await_install
- installation/logs_from_installation_system
- installation/reboot_after_installation
- installation/teardown_libyui
- '{{reconnect_mgmt_console}}'
- '{{grub_test}}'
- installation/first_boot
Expand Down
5 changes: 3 additions & 2 deletions schedule/yast/separate_usr_partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: >
accept warning about root device too small for snapshots
and create new partition for /usr.
vars:
HDDSIZEGB: 40
YUI_REST_API: 1
schedule:
- installation/bootloader_start
Expand Down Expand Up @@ -35,8 +36,8 @@ test_data:
disks:
- name: vda
partitions:
- nr: 2
size: 5GiB
- name: vda2
size: 18GiB
- role: raw-volume
formatting_options:
should_format: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
---
root:
disk: vda
existing_partition: vda2
mount_point: /
fs_type: ext4
# Sizes should be preferably expressed in human readable binary units (eg GiB)
# for this test suite: we use lsblk in validation modules, which uses human
# readable binary unit (*ibits).
# part_size is the size we input in partitioner, lsblk_expected_size_output
# is what we'll use for validation.
part_size: 11GiB
lsblk_expected_size_output: 11G
swap:
disk: vda
existing_partition: vda3
fs_type: swap
skip: 1
part_size: 2GiB
lsblk_expected_size_output: 2G
disks:
- name: vda
partitions:
- name: vda2
# Sizes should be preferably expressed in human readable binary units (eg GiB)
# for this test suite: we use lsblk in validation modules, which uses human
# readable binary unit (*ibits).
# part_size is the size we input in partitioner, as we use lsbls output for validation.
size: 11G
role: raw-volume
formatting_options:
should_format: 1
filesystem: ext4
mounting_options:
should_mount: 1
mount_point: /
- name: vda3
size: 2G
role: raw-volume
formatting_options:
should_format: 1
filesystem: swap
mounting_options:
should_mount: 1
mount_point: swap
23 changes: 13 additions & 10 deletions tests/console/validate_modify_existing_partition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ sub run {

select_console "root-console";

foreach my $part (keys %$test_data) {
record_info("Check $test_data->{$part}->{fs_type}", "Verify that the partition filesystem is $test_data->{$part}->{fs_type}");
my @partitions = @{$test_data->{disks}[0]->{partitions}};
foreach my $part (@partitions) {
record_info("Check $part->{name}", "Verify that the partition filesystem is $part->{formatting_options}->{filesystem}");

my $fstype;
if ($test_data->{$part}->{fs_type} eq "swap") {
my $actual_fstype;
my $expected_fstype = $part->{formatting_options}->{filesystem};
if ($expected_fstype eq "swap") {
# We cannot use df for swap, it is not actually mounted. lsblk shows [SWAP] in output if swap is on, but we have to process it.
$fstype = lc(script_output("lsblk | grep $test_data->{$part}->{existing_partition} | sed 's/.* //;s/[][]//g'"));
$actual_fstype = lc(script_output("lsblk | grep $part->{name} | sed 's/.* //;s/[][]//g'"));
}
else {
$fstype = script_output("df -PT $test_data->{$part}->{mount_point} | grep -v \"Filesystem\" | awk '{print \$2}'");
$actual_fstype = script_output("df -PT $part->{mounting_options}->{mount_point} | grep -v \"Filesystem\" | awk '{print \$2}'");
}
assert_matches(qr/$test_data->{$part}->{fs_type}/, $fstype, "$test_data->{$part}->{fs_type} does not match with $fstype");
assert_matches(qr/$expected_fstype/, $actual_fstype,
"$expected_fstype does not match with $actual_fstype");

record_info("Check size", "Verify that the partition size is $test_data->{$part}->{part_size}");
my $partsize = script_output("lsblk | grep $test_data->{$part}->{existing_partition} | awk '{print \$4}'");
record_info("Check size", "Verify that the partition size is $part->{size}");
my $partsize = script_output("lsblk | grep $part->{name} | awk '{print \$4}'");

assert_equals($test_data->{$part}->{lsblk_expected_size_output}, $partsize);
assert_equals($part->{size}, $partsize);
}
}

Expand Down
12 changes: 8 additions & 4 deletions tests/installation/partitioning/modify_existing_partition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ sub run {
my $test_data = get_test_suite_data();
my $partitioner = $testapi::distri->get_expert_partitioner();
$partitioner->run_expert_partitioner();
my $disk = $test_data->{disks}[0]->{name};
my @partitions = @{$test_data->{disks}[0]->{partitions}};
my $root_part = $partitions[0];

record_info("Resize root");
$partitioner->resize_partition_on_gpt_disk($test_data->{root});
for my $part (keys %$test_data) {
record_info("Edit $part", "$$test_data{$part}->{existing_partition}");
$partitioner->edit_partition_on_gpt_disk($$test_data{$part});
$partitioner->resize_partition({disk => $disk, partition => $root_part});
for my $part (@partitions) {
record_info("Edit $part->{name}", "$part");
$partitioner->edit_partition_on_gpt_disk({disk => $disk, partition => $part});
}
$partitioner->accept_changes_and_press_next();
}
Expand Down