diff --git a/README.md b/README.md index 36d3e0c7..41afabb0 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,13 @@ After installation is finished and installed system is fully booted, you can run ### Test inheritance -Your test can inherit from `basetest`, `fedorabase`, `installedtest` or `anacondatest`. Each provides relevant methods that are documented in-line, so read the files (`lib/basetest.pm`, `lib/fedorabase.pm` etc.) for information on these. +Your test can inherit from `basetest`, `installedtest` or `anacondatest`. Each provides relevant methods that are documented in-line, so read the files (`lib/anacondatest.pm`, `lib/installedtest.pm`) for information on these. - `basetest`: A base class provided by os-autoinst - it has empty `post_fail_hook()` and doesn't set any flags. -- `fedorabase`: doesn't set flags and does nothing in `post_fail_hook()`, but provides some basic methods that will be useful during testing Fedora. It should be used when no other, more specific class can be used. - `anacondatest`: should be used in tests where Anaconda is running. It uploads Anaconda logs (for example `anaconda.log` or `packaging.log`) in `post_fail_hook()`. - `installedtest`: should be used in tests that are running on installed system (either in postinstall phase or in upgrade tests). -There are also several modules that export utility functions, currently `main_common`, `freeipa`, and `packagetest`. Your test can `use` any of these modules and then directly call the functions they export. Again, the functions are documented in-line. +There are also several modules that export utility functions, currently `utils`, `anaconda`, `freeipa`, `packagetest` and `tapnet`. Your test can `use` any of these modules and then directly call the functions they export. Again, the functions are documented in-line. ### New test development workflow diff --git a/lib/anaconda.pm b/lib/anaconda.pm new file mode 100644 index 00000000..b36826e9 --- /dev/null +++ b/lib/anaconda.pm @@ -0,0 +1,180 @@ +package anaconda; + +use strict; + +use base 'Exporter'; +use Exporter; + +use testapi; +use utils; + +our @EXPORT = qw/select_disks custom_scheme_select custom_change_type custom_change_fs custom_change_device custom_delete_part get_full_repo get_mirrorlist_url/; + +sub select_disks { + # Handles disk selection. Has one optional argument - number of + # disks to select. Should be run when main Anaconda hub is + # displayed. Enters disk selection spoke and then ensures that + # required number of disks are selected. Additionally, if + # PARTITIONING variable starts with custom_, selects "custom + # partitioning" checkbox. Example usage: + # after calling `select_disks(2);` from Anaconda main hub, + # installation destination spoke will be displayed and two + # attached disks will be selected for installation. + my %args = ( + disks => 1, + iscsi => {}, + @_ + ); + my %iscsi = %{$args{iscsi}}; + # Anaconda hub + assert_screen "anaconda_main_hub", 300; # + # Damn animation delay can cause bad clicks here too - wait for it + sleep 1; + assert_and_click "anaconda_main_hub_install_destination"; + + if (get_var('NUMDISKS') > 1) { + # Multi-disk case. Select however many disks the test needs. If + # $disks is 0, this will do nothing, and 0 disks will be selected. + for my $n (1 .. $args{disks}) { + assert_and_click "anaconda_install_destination_select_disk_$n"; + } + } + else { + # Single disk case. + if ($args{disks} == 0) { + # Clicking will *de*-select. + assert_and_click "anaconda_install_destination_select_disk_1"; + } + elsif ($args{disks} > 1) { + die "Only one disk is connected! Cannot select $args{disks} disks."; + } + # For exactly 1 disk, we don't need to do anything. + } + + # Handle network disks. + if (%iscsi) { + assert_and_click "anaconda_install_destination_add_network_disk"; + foreach my $target (keys %iscsi) { + my $ip = $iscsi{$target}->[0]; + my $user = $iscsi{$target}->[1]; + my $password = $iscsi{$target}->[2]; + assert_and_click "anaconda_install_destination_add_iscsi_target"; + wait_still_screen 2; + type_safely $ip; + wait_screen_change { send_key "tab"; }; + type_safely $target; + # start discovery - three tabs, enter + type_safely "\t\t\t\n"; + if ($user && $password) { + assert_and_click "anaconda_install_destination_target_auth_type"; + assert_and_click "anaconda_install_destination_target_auth_type_chap"; + send_key "tab"; + type_safely $user; + send_key "tab"; + type_safely $password; + } + assert_and_click "anaconda_install_destination_target_login"; + assert_and_click "anaconda_install_destination_select_target"; + } + assert_and_click "anaconda_spoke_done"; + } + + # If this is a custom partitioning test, select custom partitioning. + if (get_var('PARTITIONING') =~ /^custom_/) { + assert_and_click "anaconda_manual_partitioning"; + } +} + +sub custom_scheme_select { + # Used for setting custom partitioning scheme (such as LVM). + # Should be called when custom partitioning spoke is displayed. + # Pass the name of the partitioning scheme. Needle + # `anaconda_part_scheme_$scheme` should exist. Example usage: + # `custom_scheme_select("btrfs");` uses needle + # `anaconda_part_scheme_btrfs` to set partition scheme to Btrfs. + my ($scheme) = @_; + assert_and_click "anaconda_part_scheme"; + # Move the mouse away from the menu + mouse_set(10, 10); + assert_and_click "anaconda_part_scheme_$scheme"; +} + +sub custom_change_type { + # Used to set different device types for specified partition (e.g. + # RAID). Should be called when custom partitioning spoke is + # displayed. Pass it type of partition and name of partition. + # Needles `anaconda_part_select_$part` and + # `anaconda_part_device_type_$type` should exist. Example usage: + # `custom_change_type("raid", "root");` uses + # `anaconda_part_select_root` and `anaconda_part_device_type_raid` + # needles to set RAID for root partition. + my ($type, $part) = @_; + $part ||= "root"; + assert_and_click "anaconda_part_select_$part"; + assert_and_click "anaconda_part_device_type"; + # Move the mouse away from the menu + mouse_set(10, 10); + assert_and_click "anaconda_part_device_type_$type"; + assert_and_click "anaconda_part_update_settings"; +} + +sub custom_change_fs { + # Used to set different file systems for specified partition. + # Should be called when custom partitioning spoke is displayed. + # Pass filesystem name and name of partition. Needles + # `anaconda_part_select_$part` and `anaconda_part_fs_$fs` should + # exist. Example usage: + # `custom_change_fs("ext3", "root");` uses + # `anaconda_part_select_root` and `anaconda_part_fs_ext3` needles + # to set ext3 file system for root partition. + my ($fs, $part) = @_; + $part ||= "root"; + assert_and_click "anaconda_part_select_$part"; + # if fs is already set correctly, do nothing + return if (check_screen "anaconda_part_fs_${fs}_selected", 5); + assert_and_click "anaconda_part_fs"; + # Move the mouse away from the menu + mouse_set(10, 10); + assert_and_click "anaconda_part_fs_$fs"; + assert_and_click "anaconda_part_update_settings"; +} + +sub custom_change_device { + my ($part, $devices) = @_; + assert_and_click "anaconda_part_select_$part"; + assert_and_click "anaconda_part_device_modify"; + foreach my $device (split(/ /, $devices)) { + assert_and_click "anaconda_part_device_${device}"; + } + assert_and_click "anaconda_part_device_select"; + assert_and_click "anaconda_part_update_settings"; +} + +sub custom_delete_part { + # Used for deletion of previously added partitions in custom + # partitioning spoke. Should be called when custom partitioning + # spoke is displayed. Pass the partition name. Needle + # `anaconda_part_select_$part` should exist. Example usage: + # `custom_delete_part('swap');` uses needle + # `anaconda_part_select_swap` to delete previously added swap + # partition. + my ($part) = @_; + return if not $part; + assert_and_click "anaconda_part_select_$part"; + assert_and_click "anaconda_part_delete"; +} + +sub get_full_repo { + my ($repourl) = @_; + # trivial thing we kept repeating: fill out an HTTP or HTTPS + # repo URL with flavor and arch, leave NFS ones alone (as for + # NFS tests we just use a mounted ISO and the URL is complete) + if ($repourl !~ m/^nfs/) { + $repourl .= "/Everything/".get_var("ARCH")."/os"; + } + return $repourl; +} + +sub get_mirrorlist_url { + return "mirrors.fedoraproject.org/mirrorlist?repo=fedora-" . lc(get_var("VERSION")) . "&arch=" . get_var('ARCH'); +} diff --git a/lib/anacondatest.pm b/lib/anacondatest.pm index 93801aa5..5f9a7e7b 100644 --- a/lib/anacondatest.pm +++ b/lib/anacondatest.pm @@ -1,13 +1,14 @@ package anacondatest; -use base 'fedorabase'; +use base 'basetest'; # base class for all Anaconda (installation) tests # should be used in tests where Anaconda is running - when it makes sense -# to upload Anaconda logs when something fails +# to upload Anaconda logs when something fails. Many tests using this as a +# base likely will also want to `use anaconda` for commonly-used functions. use testapi; -use main_common; +use utils; sub post_fail_hook { my $self = shift; @@ -74,176 +75,6 @@ sub root_console { console_login(user=>"root"); } -sub select_disks { - # Handles disk selection. Has one optional argument - number of - # disks to select. Should be run when main Anaconda hub is - # displayed. Enters disk selection spoke and then ensures that - # required number of disks are selected. Additionally, if - # PARTITIONING variable starts with custom_, selects "custom - # partitioning" checkbox. Example usage: - # after calling `$self->select_disks(2);` from Anaconda main hub, - # installation destination spoke will be displayed and two - # attached disks will be selected for installation. - my $self = shift; - my %args = ( - disks => 1, - iscsi => {}, - @_ - ); - my %iscsi = %{$args{iscsi}}; - # Anaconda hub - assert_screen "anaconda_main_hub", 300; # - # Damn animation delay can cause bad clicks here too - wait for it - sleep 1; - assert_and_click "anaconda_main_hub_install_destination"; - - if (get_var('NUMDISKS') > 1) { - # Multi-disk case. Select however many disks the test needs. If - # $disks is 0, this will do nothing, and 0 disks will be selected. - for my $n (1 .. $args{disks}) { - assert_and_click "anaconda_install_destination_select_disk_$n"; - } - } - else { - # Single disk case. - if ($args{disks} == 0) { - # Clicking will *de*-select. - assert_and_click "anaconda_install_destination_select_disk_1"; - } - elsif ($args{disks} > 1) { - die "Only one disk is connected! Cannot select $args{disks} disks."; - } - # For exactly 1 disk, we don't need to do anything. - } - - # Handle network disks. - if (%iscsi) { - assert_and_click "anaconda_install_destination_add_network_disk"; - foreach my $target (keys %iscsi) { - my $ip = $iscsi{$target}->[0]; - my $user = $iscsi{$target}->[1]; - my $password = $iscsi{$target}->[2]; - assert_and_click "anaconda_install_destination_add_iscsi_target"; - wait_still_screen 2; - type_safely $ip; - wait_screen_change { send_key "tab"; }; - type_safely $target; - # start discovery - three tabs, enter - type_safely "\t\t\t\n"; - if ($user && $password) { - assert_and_click "anaconda_install_destination_target_auth_type"; - assert_and_click "anaconda_install_destination_target_auth_type_chap"; - send_key "tab"; - type_safely $user; - send_key "tab"; - type_safely $password; - } - assert_and_click "anaconda_install_destination_target_login"; - assert_and_click "anaconda_install_destination_select_target"; - } - assert_and_click "anaconda_spoke_done"; - } - - # If this is a custom partitioning test, select custom partitioning. - if (get_var('PARTITIONING') =~ /^custom_/) { - assert_and_click "anaconda_manual_partitioning"; - } -} - -sub custom_scheme_select { - # Used for setting custom partitioning scheme (such as LVM). - # Should be called when custom partitioning spoke is displayed. - # Pass the name of the partitioning scheme. Needle - # `anaconda_part_scheme_$scheme` should exist. Example usage: - # `$self->custom_scheme_select("btrfs");` uses needle - # `anaconda_part_scheme_btrfs` to set partition scheme to Btrfs. - my ($self, $scheme) = @_; - assert_and_click "anaconda_part_scheme"; - # Move the mouse away from the menu - mouse_set(10, 10); - assert_and_click "anaconda_part_scheme_$scheme"; -} - -sub custom_change_type { - # Used to set different device types for specified partition (e.g. - # RAID). Should be called when custom partitioning spoke is - # displayed. Pass it type of partition and name of partition. - # Needles `anaconda_part_select_$part` and - # `anaconda_part_device_type_$type` should exist. Example usage: - # `$self->custom_change_type("raid", "root");` uses - # `anaconda_part_select_root` and `anaconda_part_device_type_raid` - # needles to set RAID for root partition. - my ($self, $type, $part) = @_; - $part ||= "root"; - assert_and_click "anaconda_part_select_$part"; - assert_and_click "anaconda_part_device_type"; - # Move the mouse away from the menu - mouse_set(10, 10); - assert_and_click "anaconda_part_device_type_$type"; - assert_and_click "anaconda_part_update_settings"; -} - -sub custom_change_fs { - # Used to set different file systems for specified partition. - # Should be called when custom partitioning spoke is displayed. - # Pass filesystem name and name of partition. Needles - # `anaconda_part_select_$part` and `anaconda_part_fs_$fs` should - # exist. Example usage: - # `$self->custom_change_fs("ext3", "root");` uses - # `anaconda_part_select_root` and `anaconda_part_fs_ext3` needles - # to set ext3 file system for root partition. - my ($self, $fs, $part) = @_; - $part ||= "root"; - assert_and_click "anaconda_part_select_$part"; - # if fs is already set correctly, do nothing - return if (check_screen "anaconda_part_fs_${fs}_selected", 5); - assert_and_click "anaconda_part_fs"; - # Move the mouse away from the menu - mouse_set(10, 10); - assert_and_click "anaconda_part_fs_$fs"; - assert_and_click "anaconda_part_update_settings"; -} - -sub custom_change_device { - my ($self, $part, $devices) = @_; - assert_and_click "anaconda_part_select_$part"; - assert_and_click "anaconda_part_device_modify"; - foreach my $device (split(/ /, $devices)) { - assert_and_click "anaconda_part_device_${device}"; - } - assert_and_click "anaconda_part_device_select"; - assert_and_click "anaconda_part_update_settings"; -} - -sub custom_delete_part { - # Used for deletion of previously added partitions in custom - # partitioning spoke. Should be called when custom partitioning - # spoke is displayed. Pass the partition name. Needle - # `anaconda_part_select_$part` should exist. Example usage: - # `$self->custom_delete_part('swap');` uses - # `anaconda_part_select_swap` to delete previously added swap - # partition. - my ($self, $part) = @_; - return if not $part; - assert_and_click "anaconda_part_select_$part"; - assert_and_click "anaconda_part_delete"; -} - -sub get_full_repo { - my ($self, $repourl) = @_; - # trivial thing we kept repeating: fill out an HTTP or HTTPS - # repo URL with flavor and arch, leave NFS ones alone (as for - # NFS tests we just use a mounted ISO and the URL is complete) - if ($repourl !~ m/^nfs/) { - $repourl .= "/Everything/".get_var("ARCH")."/os"; - } - return $repourl; -} - -sub get_mirrorlist_url { - return "mirrors.fedoraproject.org/mirrorlist?repo=fedora-" . lc(get_var("VERSION")) . "&arch=" . get_var('ARCH') -} - 1; # vim: set sw=4 et: diff --git a/lib/fedorabase.pm b/lib/fedorabase.pm deleted file mode 100644 index 0382901f..00000000 --- a/lib/fedorabase.pm +++ /dev/null @@ -1,142 +0,0 @@ -package fedorabase; -use base 'basetest'; -use lockapi; - -# base class for all Fedora tests - -# use this class when using other base class doesn't make sense - -use testapi; - -sub do_bootloader { - # Handle bootloader screen. 'bootloader' is syslinux or grub. - # 'uefi' is whether this is a UEFI install, will get_var UEFI if - # not explicitly set. 'postinstall' is whether we're on an - # installed system or at the installer (this matters for how many - # times we press 'down' to find the kernel line when typing args). - # 'args' is a string of extra kernel args, if desired. 'mutex' is - # a parallel test mutex lock to wait for before proceeding, if - # desired. 'first' is whether to hit 'up' a couple of times to - # make sure we boot the first menu entry. 'timeout' is how long to - # wait for the bootloader screen. - my $self = shift; - my %args = ( - postinstall => 0, - params => "", - mutex => "", - first => 1, - timeout => 30, - uefi => get_var("UEFI"), - @_ - ); - # if not postinstall and not UEFI, syslinux - $args{bootloader} //= ($args{uefi} || $args{postinstall}) ? "grub" : "syslinux"; - if ($args{uefi}) { - # we use the firmware-type specific tags because we want to be - # sure we actually did a UEFI boot - assert_screen "bootloader_uefi", $args{timeout}; - } else { - assert_screen "bootloader_bios", $args{timeout}; - } - if ($args{mutex}) { - # cancel countdown - send_key "left"; - mutex_lock $args{mutex}; - mutex_unlock $args{mutex}; - } - if ($args{first}) { - # press up a couple of times to make sure we're at first entry - send_key "up"; - send_key "up"; - } - if ($args{params}) { - if ($args{bootloader} eq "syslinux") { - send_key "tab"; - } - else { - send_key "e"; - # ternary: 13 'downs' to reach the kernel line for installed - # system, 2 for UEFI installer - my $presses = $args{postinstall} ? 13 : 2; - foreach my $i (1..$presses) { - send_key "down"; - } - send_key "end"; - } - type_string " $args{params}"; - } - # ctrl-X boots from grub editor mode - send_key "ctrl-x"; - # return boots all other cases - send_key "ret"; -} - -sub get_milestone { - my $self = shift; - # FIXME: we don't know how to do this with Pungi 4 yet. - return ''; -} - -sub clone_host_file { - # copy a given file from the host into the guest. Mainly used - # for networking config on tap tests. this is pretty crazy, but - # SUSE do almost the same thing... - my $self = shift; - my $file = shift; - my $text = ''; - open(my $fh, '<', $file); - while (<$fh>) { - $text .= $_; - } - # escape any ' characters in the text... - $text =~ s/"/\\"/g; - assert_script_run "printf \"$text\" > $file"; - # for debugging... - assert_script_run "cat $file"; -} - -sub setup_tap_static { - # this is a common thing for tap tests, where we set up networking - # for the system with a static IP address and possibly a specific - # hostname - my $self = shift; - my $ip = shift; - my $hostname = shift || ""; - if ($hostname) { - # assigning output of split to a single-item array gives us just - # the first split - my ($short) = split(/\./, $hostname); - # set hostname - assert_script_run "hostnamectl set-hostname $hostname"; - # add entry to /etc/hosts - assert_script_run "echo '$ip $hostname $short' >> /etc/hosts"; - } - # bring up network. DEFROUTE is *vital* here - assert_script_run "printf 'DEVICE=eth0\nBOOTPROTO=none\nIPADDR=$ip\nGATEWAY=10.0.2.2\nPREFIX=24\nDEFROUTE=yes' > /etc/sysconfig/network-scripts/ifcfg-eth0"; - script_run "systemctl restart NetworkManager.service"; -} - -sub get_host_dns { - # get DNS server addresses from the host - my @forwards; - open(FH, '<', "/etc/resolv.conf"); - while () { - if ($_ =~ m/^nameserver +(.+)/) { - push @forwards, $1; - } - } - return @forwards; -} - -sub boot_decrypt { - # decrypt storage during boot; arg is timeout (in seconds) - my $self = shift; - my $timeout = shift || 60; - assert_screen "boot_enter_passphrase", $timeout; # - type_string get_var("ENCRYPT_PASSWORD"); - send_key "ret"; -} - -1; - -# vim: set sw=4 et: diff --git a/lib/freeipa.pm b/lib/freeipa.pm index e0b52ad2..eed53a7c 100644 --- a/lib/freeipa.pm +++ b/lib/freeipa.pm @@ -6,7 +6,7 @@ use base 'Exporter'; use Exporter; use testapi; -use main_common; +use utils; our @EXPORT = qw/add_user start_webui/; diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 7b7173ab..9fb7fa70 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -1,5 +1,5 @@ package installedtest; -use base 'fedorabase'; +use base 'basetest'; # base class for tests that run on installed system @@ -7,7 +7,7 @@ use base 'fedorabase'; # of upgrade tests, postinstall phases... use testapi; -use main_common; +use utils; sub root_console { # Switch to a default or specified TTY and log in as root. @@ -45,68 +45,6 @@ sub post_fail_hook { } } -sub check_release { - # Checks whether the installed release matches a given value. E.g. - # `check_release(23)` checks whether the installed system is - # Fedora 23. The value can be 'Rawhide' or a Fedora release - # number; often you will want to use `get_var('VERSION')`. Expects - # a console prompt to be active when it is called. - my $self = shift; - my $release = shift; - my $check_command = "grep SUPPORT_PRODUCT_VERSION /usr/lib/os.release.d/os-release-fedora"; - validate_script_output $check_command, sub { $_ =~ m/REDHAT_SUPPORT_PRODUCT_VERSION=$release/ }; -} - -sub menu_launch_type { - # Launch an application in a graphical environment, by opening a - # launcher, typing the specified string and hitting enter. Pass - # the string to be typed to launch whatever it is you want. - my $self = shift; - my $app = shift; - # super does not work on KDE, because fml - send_key 'alt-f1'; - # srsly KDE y u so slo - wait_still_screen 3; - type_very_safely $app; - send_key 'ret'; -} - -sub start_cockpit { - # Starting from a console, get to a browser with Cockpit (running - # on localhost) shown. If $login is truth-y, also log in. Assumes - # X and Firefox are installed. - my $self = shift; - my $login = shift || 0; - # run firefox directly in X as root. never do this, kids! - type_string "startx /usr/bin/firefox -width 1024 -height 768 http://localhost:9090\n"; - assert_screen "cockpit_login"; - wait_still_screen 5; - if ($login) { - type_safely "root"; - wait_screen_change { send_key "tab"; }; - type_safely get_var("ROOT_PASSWORD", "weakpassword"); - send_key "ret"; - assert_screen "cockpit_main"; - # wait for any animation or other weirdness - # can't use wait_still_screen because of that damn graph - sleep 3; - } -} - -sub repo_setup { - # disable updates-testing and updates and use the compose location - # as the target for fedora and rawhide rather than mirrorlist, so - # tools see only packages from the compose under test - my $location = get_var("LOCATION"); - assert_script_run 'dnf config-manager --set-disabled updates-testing updates'; - # we use script_run here as the rawhide repo file won't always exist - # and we don't want to bother testing or predicting its existence; - # assert_script_run doesn't buy you much with sed anyway as it'll - # return 0 even if it replaced nothing - script_run "sed -i -e 's,^metalink,#metalink,g' -e 's,^#baseurl.*basearch,baseurl=${location}/Everything/\$basearch,g' /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0; - script_run "cat /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0; -} - 1; # vim: set sw=4 et: diff --git a/lib/tapnet.pm b/lib/tapnet.pm new file mode 100644 index 00000000..279322fe --- /dev/null +++ b/lib/tapnet.pm @@ -0,0 +1,62 @@ +package tapnet; + +use strict; + +use base 'Exporter'; +use Exporter; + +use testapi; +our @EXPORT = qw/clone_host_file setup_tap_static get_host_dns/; + +sub clone_host_file { + # copy a given file from the host into the guest. Mainly used + # for networking config on tap tests. this is pretty crazy, but + # SUSE do almost the same thing... + my $file = shift; + my $text = ''; + open(my $fh, '<', $file); + while (<$fh>) { + $text .= $_; + } + # escape any " characters in the text... + $text =~ s/"/\\"/g; + assert_script_run "printf \"$text\" > $file"; + # for debugging... + assert_script_run "cat $file"; +} + +sub setup_tap_static { + # this is a common thing for tap tests, where we set up networking + # for the system with a static IP address and possibly a specific + # hostname + my $ip = shift; + my $hostname = shift || ""; + if ($hostname) { + # assigning output of split to a single-item array gives us just + # the first split + my ($short) = split(/\./, $hostname); + # set hostname + assert_script_run "hostnamectl set-hostname $hostname"; + # add entry to /etc/hosts + assert_script_run "echo '$ip $hostname $short' >> /etc/hosts"; + } + # bring up network. DEFROUTE is *vital* here + assert_script_run "printf 'DEVICE=eth0\nBOOTPROTO=none\nIPADDR=$ip\nGATEWAY=10.0.2.2\nPREFIX=24\nDEFROUTE=yes' > /etc/sysconfig/network-scripts/ifcfg-eth0"; + script_run "systemctl restart NetworkManager.service"; +} + +sub get_host_dns { + # get DNS server addresses from the host + my @forwards; + open(FH, '<', "/etc/resolv.conf"); + while () { + if ($_ =~ m/^nameserver +(.+)/) { + push @forwards, $1; + } + } + return @forwards; +} + +1; + +# vim: set sw=4 et: diff --git a/lib/main_common.pm b/lib/utils.pm similarity index 51% rename from lib/main_common.pm rename to lib/utils.pm index 75cfc457..bbacc0a8 100644 --- a/lib/main_common.pm +++ b/lib/utils.pm @@ -1,12 +1,13 @@ -package main_common; +package utils; use strict; use base 'Exporter'; use Exporter; +use lockapi; use testapi; -our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us/; +our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader get_milestone boot_decrypt check_release menu_launch_type start_cockpit repo_setup/; sub run_with_error_check { my ($func, $error_screen) = @_; @@ -162,3 +163,141 @@ sub console_loadkeys_us { script_run "loqdkeys us", 0; } } + +sub do_bootloader { + # Handle bootloader screen. 'bootloader' is syslinux or grub. + # 'uefi' is whether this is a UEFI install, will get_var UEFI if + # not explicitly set. 'postinstall' is whether we're on an + # installed system or at the installer (this matters for how many + # times we press 'down' to find the kernel line when typing args). + # 'args' is a string of extra kernel args, if desired. 'mutex' is + # a parallel test mutex lock to wait for before proceeding, if + # desired. 'first' is whether to hit 'up' a couple of times to + # make sure we boot the first menu entry. 'timeout' is how long to + # wait for the bootloader screen. + my %args = ( + postinstall => 0, + params => "", + mutex => "", + first => 1, + timeout => 30, + uefi => get_var("UEFI"), + @_ + ); + # if not postinstall and not UEFI, syslinux + $args{bootloader} //= ($args{uefi} || $args{postinstall}) ? "grub" : "syslinux"; + if ($args{uefi}) { + # we use the firmware-type specific tags because we want to be + # sure we actually did a UEFI boot + assert_screen "bootloader_uefi", $args{timeout}; + } else { + assert_screen "bootloader_bios", $args{timeout}; + } + if ($args{mutex}) { + # cancel countdown + send_key "left"; + mutex_lock $args{mutex}; + mutex_unlock $args{mutex}; + } + if ($args{first}) { + # press up a couple of times to make sure we're at first entry + send_key "up"; + send_key "up"; + } + if ($args{params}) { + if ($args{bootloader} eq "syslinux") { + send_key "tab"; + } + else { + send_key "e"; + # ternary: 13 'downs' to reach the kernel line for installed + # system, 2 for UEFI installer + my $presses = $args{postinstall} ? 13 : 2; + foreach my $i (1..$presses) { + send_key "down"; + } + send_key "end"; + } + type_string " $args{params}"; + } + # ctrl-X boots from grub editor mode + send_key "ctrl-x"; + # return boots all other cases + send_key "ret"; +} + +sub get_milestone { + # FIXME: we don't know how to do this with Pungi 4 yet. + return ''; +} + +sub boot_decrypt { + # decrypt storage during boot; arg is timeout (in seconds) + my $timeout = shift || 60; + assert_screen "boot_enter_passphrase", $timeout; # + type_string get_var("ENCRYPT_PASSWORD"); + send_key "ret"; +} + +sub check_release { + # Checks whether the installed release matches a given value. E.g. + # `check_release(23)` checks whether the installed system is + # Fedora 23. The value can be 'Rawhide' or a Fedora release + # number; often you will want to use `get_var('VERSION')`. Expects + # a console prompt to be active when it is called. + my $self = shift; + my $release = shift; + my $check_command = "grep SUPPORT_PRODUCT_VERSION /usr/lib/os.release.d/os-release-fedora"; + validate_script_output $check_command, sub { $_ =~ m/REDHAT_SUPPORT_PRODUCT_VERSION=$release/ }; +} + +sub menu_launch_type { + # Launch an application in a graphical environment, by opening a + # launcher, typing the specified string and hitting enter. Pass + # the string to be typed to launch whatever it is you want. + my $self = shift; + my $app = shift; + # super does not work on KDE, because fml + send_key 'alt-f1'; + # srsly KDE y u so slo + wait_still_screen 3; + type_very_safely $app; + send_key 'ret'; +} + +sub start_cockpit { + # Starting from a console, get to a browser with Cockpit (running + # on localhost) shown. If $login is truth-y, also log in. Assumes + # X and Firefox are installed. + my $self = shift; + my $login = shift || 0; + # run firefox directly in X as root. never do this, kids! + type_string "startx /usr/bin/firefox -width 1024 -height 768 http://localhost:9090\n"; + assert_screen "cockpit_login"; + wait_still_screen 5; + if ($login) { + type_safely "root"; + wait_screen_change { send_key "tab"; }; + type_safely get_var("ROOT_PASSWORD", "weakpassword"); + send_key "ret"; + assert_screen "cockpit_main"; + # wait for any animation or other weirdness + # can't use wait_still_screen because of that damn graph + sleep 3; + } +} + +sub repo_setup { + # disable updates-testing and updates and use the compose location + # as the target for fedora and rawhide rather than mirrorlist, so + # tools see only packages from the compose under test + my $location = get_var("LOCATION"); + assert_script_run 'dnf config-manager --set-disabled updates-testing updates'; + # we use script_run here as the rawhide repo file won't always exist + # and we don't want to bother testing or predicting its existence; + # assert_script_run doesn't buy you much with sed anyway as it'll + # return 0 even if it replaced nothing + script_run "sed -i -e 's,^metalink,#metalink,g' -e 's,^#baseurl.*basearch,baseurl=${location}/Everything/\$basearch,g' /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0; + script_run "cat /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0; +} + diff --git a/tests/_boot_to_anaconda.pm b/tests/_boot_to_anaconda.pm index 024b5a53..61f82f93 100644 --- a/tests/_boot_to_anaconda.pm +++ b/tests/_boot_to_anaconda.pm @@ -1,7 +1,8 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; +use anaconda; sub run { my $self = shift; @@ -15,7 +16,7 @@ sub run { # Construct inst.repo arg for REPOSITORY_VARIATION my $repourl = get_var("REPOSITORY_VARIATION"); if ($repourl) { - $params .= "inst.repo=" . $self->get_full_repo($repourl) . " "; + $params .= "inst.repo=" . get_full_repo($repourl) . " "; } $params .= "inst.text " if get_var("ANACONDA_TEXT"); # inst.debug enables memory use tracking @@ -27,7 +28,7 @@ sub run { my $mutex = get_var("INSTALL_UNLOCK"); # call do_bootloader with postinstall=0, the params, and the mutex - $self->do_bootloader(postinstall=>0, params=>$params, mutex=>$mutex); + do_bootloader(postinstall=>0, params=>$params, mutex=>$mutex); # proceed to installer if (get_var("KICKSTART")) { diff --git a/tests/_check_install_source.pm b/tests/_check_install_source.pm index c90e0a25..021c06d8 100644 --- a/tests/_check_install_source.pm +++ b/tests/_check_install_source.pm @@ -1,16 +1,17 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; my $repourl; if (get_var("MIRRORLIST_GRAPHICAL")) { - $repourl = $self->get_mirrorlist_url(); + $repourl = get_mirrorlist_url(); } else { $repourl = get_var("REPOSITORY_VARIATION", get_var("REPOSITORY_GRAPHICAL")); - $repourl = $self->get_full_repo($repourl); + $repourl = get_full_repo($repourl); } # check that the repo was used diff --git a/tests/_console_avc_crash.pm b/tests/_console_avc_crash.pm index 677c79b5..ed8ec9d2 100644 --- a/tests/_console_avc_crash.pm +++ b/tests/_console_avc_crash.pm @@ -1,6 +1,6 @@ use base "installedtest"; use strict; -use main_common; +use utils; use testapi; sub run { diff --git a/tests/_console_login.pm b/tests/_console_login.pm index 6605c9f9..fb7c17f1 100644 --- a/tests/_console_login.pm +++ b/tests/_console_login.pm @@ -1,7 +1,7 @@ -use base "fedorabase"; +use base "basetest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/_console_wait_login.pm b/tests/_console_wait_login.pm index 79c712a6..8141eaec 100644 --- a/tests/_console_wait_login.pm +++ b/tests/_console_wait_login.pm @@ -1,7 +1,7 @@ -use base "fedorabase"; +use base "basetest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; @@ -11,7 +11,7 @@ sub run { # handle bootloader, if requested if (get_var("GRUB_POSTINSTALL")) { - $self->do_bootloader(postinstall=>1, params=>get_var("GRUB_POSTINSTALL"), timeout=>$wait_time); + do_bootloader(postinstall=>1, params=>get_var("GRUB_POSTINSTALL"), timeout=>$wait_time); $wait_time = 180; } diff --git a/tests/_do_install_and_reboot.pm b/tests/_do_install_and_reboot.pm index 8533e6d3..951827bf 100644 --- a/tests/_do_install_and_reboot.pm +++ b/tests/_do_install_and_reboot.pm @@ -1,7 +1,7 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; sub type_user_password { my $self = shift; diff --git a/tests/_graphical_input.pm b/tests/_graphical_input.pm index 96d5d6d1..6122f06b 100644 --- a/tests/_graphical_input.pm +++ b/tests/_graphical_input.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { # check both layouts are available at the desktop; here, diff --git a/tests/_graphical_wait_login.pm b/tests/_graphical_wait_login.pm index 3a545641..1d330c0e 100644 --- a/tests/_graphical_wait_login.pm +++ b/tests/_graphical_wait_login.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/_network_static.pm b/tests/_network_static.pm index bcb1dec0..7a39a8eb 100644 --- a/tests/_network_static.pm +++ b/tests/_network_static.pm @@ -1,7 +1,8 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; +use tapnet; sub run { my $self = shift; @@ -19,7 +20,7 @@ sub run { # move to DNS servers type_safely "\n\t\t\t"; # set DNS from host - type_safely join(',', $self->get_host_dns()); + type_safely join(',', get_host_dns()); type_safely "\t\t\t\t\t\n"; # can take a bit of time as it seems to wait for all the pending # DHCP requests to time out before applying the static config diff --git a/tests/_support_server.pm b/tests/_support_server.pm index 4a98f687..f1e563b9 100644 --- a/tests/_support_server.pm +++ b/tests/_support_server.pm @@ -3,16 +3,17 @@ use strict; use testapi; use lockapi; use mmapi; +use tapnet; sub run { my $self=shift; # clone host's /etc/hosts (for phx2 internal routing to work) # must come *before* setup_tap_static or else it would overwrite # its changes - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.110", "support.domain.local"); - $self->clone_host_file("/etc/resolv.conf"); + setup_tap_static("10.0.2.110", "support.domain.local"); + clone_host_file("/etc/resolv.conf"); ## DNS / DHCP (dnsmasq) # create config diff --git a/tests/base_service_manipulation.pm b/tests/base_service_manipulation.pm index 118aa04f..259ea88f 100644 --- a/tests/base_service_manipulation.pm +++ b/tests/base_service_manipulation.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/database_client.pm b/tests/database_client.pm index 89eeca51..ca004633 100644 --- a/tests/database_client.pm +++ b/tests/database_client.pm @@ -2,19 +2,21 @@ use base "installedtest"; use strict; use testapi; use lockapi; +use tapnet; +use utils; sub run { my $self=shift; # clone host's /etc/hosts (for phx2 internal routing to work) # must come *before* setup_tap_static or else it would overwrite # its changes - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.105", "dbclient.domain.local"); + setup_tap_static("10.0.2.105", "dbclient.domain.local"); # clone host's resolv.conf to get name resolution - $self->clone_host_file("/etc/resolv.conf"); + clone_host_file("/etc/resolv.conf"); # use compose repo, disable u-t, etc. - $self->repo_setup(); + repo_setup(); # install postgresql assert_script_run "dnf -y install postgresql", 120; # wait for the server to be ready diff --git a/tests/desktop_browser.pm b/tests/desktop_browser.pm index 42a67f30..672a5002 100644 --- a/tests/desktop_browser.pm +++ b/tests/desktop_browser.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; # we are very paranoid with waits and typing speed in this test # because the system can be very busy; it's effectively first boot of diff --git a/tests/desktop_notifications.pm b/tests/desktop_notifications.pm index 276a1528..75a65dcf 100644 --- a/tests/desktop_notifications.pm +++ b/tests/desktop_notifications.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; use packagetest; # This test sort of covers QA:Testcase_desktop_update_notification @@ -15,10 +15,10 @@ sub run { my $desktop = get_var("DESKTOP"); # for the live image case, handle bootloader here if (get_var("BOOTFROM")) { - $self->do_bootloader(postinstall=>1, params=>'3'); + do_bootloader(postinstall=>1, params=>'3'); } else { - $self->do_bootloader(postinstall=>0, params=>'3'); + do_bootloader(postinstall=>0, params=>'3'); } boot_to_login_screen; $self->root_console(tty=>3); diff --git a/tests/desktop_terminal.pm b/tests/desktop_terminal.pm index 028c8b09..dd5b7c8d 100644 --- a/tests/desktop_terminal.pm +++ b/tests/desktop_terminal.pm @@ -1,12 +1,12 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self=shift; assert_screen 'graphical_desktop_clean'; - $self->menu_launch_type('terminal'); + menu_launch_type('terminal'); wait_still_screen 5; # need to be root my $rootpass = get_var("ROOT_PASSWORD", "weakpassword"); diff --git a/tests/desktop_update_graphical.pm b/tests/desktop_update_graphical.pm index 59547ab6..9a9a4dba 100644 --- a/tests/desktop_update_graphical.pm +++ b/tests/desktop_update_graphical.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; use packagetest; sub run { @@ -22,7 +22,7 @@ sub run { else { # this launches GNOME Software on GNOME, dunno for any other # desktop yet - $self->menu_launch_type('update'); + menu_launch_type('update'); } # GNOME Software has a welcome screen, get rid of it if it shows # up (but don't fail if it doesn't, we're not testing that) diff --git a/tests/disk_custom_btrfs.pm b/tests/disk_custom_btrfs.pm index 38434f31..96d2495a 100644 --- a/tests/disk_custom_btrfs.pm +++ b/tests/disk_custom_btrfs.pm @@ -1,17 +1,18 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure the disk is selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed. Select BTRFS # partitioning scheme - $self->custom_scheme_select("btrfs"); + custom_scheme_select("btrfs"); assert_and_click "anaconda_part_automatic"; assert_and_click "anaconda_spoke_done"; assert_and_click "anaconda_part_accept_changes"; diff --git a/tests/disk_custom_ext3.pm b/tests/disk_custom_ext3.pm index a6249c8b..b9f5f29f 100644 --- a/tests/disk_custom_ext3.pm +++ b/tests/disk_custom_ext3.pm @@ -1,21 +1,22 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure the disk is selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed. Select Standard # Partition scheme - $self->custom_scheme_select("standard"); + custom_scheme_select("standard"); # Do 'automatic' partition creation assert_and_click "anaconda_part_automatic"; # Change root partition to ext3 - $self->custom_change_fs("ext3"); + custom_change_fs("ext3"); assert_and_click "anaconda_spoke_done"; assert_and_click "anaconda_part_accept_changes"; diff --git a/tests/disk_custom_iscsi.pm b/tests/disk_custom_iscsi.pm index 8bd4115f..bcc5d924 100644 --- a/tests/disk_custom_iscsi.pm +++ b/tests/disk_custom_iscsi.pm @@ -1,6 +1,7 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; @@ -10,15 +11,15 @@ sub run { # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one regular disk # and the iscsi target are selected. - $self->select_disks(iscsi=>\%iscsi); + select_disks(iscsi=>\%iscsi); assert_and_click "anaconda_spoke_done"; # now we're at custom part. let's use standard partitioning for # simplicity - $self->custom_scheme_select("standard"); + custom_scheme_select("standard"); # Do 'automatic' partition creation assert_and_click "anaconda_part_automatic"; # Make sure / is on the iSCSI target (which appears as sda) - $self->custom_change_device("root", "sda"); + custom_change_device("root", "sda"); assert_and_click "anaconda_spoke_done"; assert_and_click "anaconda_part_accept_changes"; } diff --git a/tests/disk_custom_lvmthin.pm b/tests/disk_custom_lvmthin.pm index a588f2df..279bc4c6 100644 --- a/tests/disk_custom_lvmthin.pm +++ b/tests/disk_custom_lvmthin.pm @@ -1,17 +1,18 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure the disk is selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed. Select LVM Thin # Partitioning scheme - $self->custom_scheme_select("lvmthin"); + custom_scheme_select("lvmthin"); # Do 'automatic' partition creation assert_and_click "anaconda_part_automatic"; assert_and_click "anaconda_spoke_done"; diff --git a/tests/disk_custom_no_swap.pm b/tests/disk_custom_no_swap.pm index 197907bc..04d2bd7c 100644 --- a/tests/disk_custom_no_swap.pm +++ b/tests/disk_custom_no_swap.pm @@ -1,17 +1,18 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure the disk is selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed assert_and_click "anaconda_part_automatic"; - $self->custom_delete_part('swap'); + custom_delete_part('swap'); assert_and_click "anaconda_spoke_done"; # Deleting swap shows a warning and requires a second click to confirm # Wait a sec first, otherwise sometimes we click too fast diff --git a/tests/disk_custom_software_raid.pm b/tests/disk_custom_software_raid.pm index ce31d420..c6385729 100644 --- a/tests/disk_custom_software_raid.pm +++ b/tests/disk_custom_software_raid.pm @@ -1,17 +1,18 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure two disks are selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(disks=>2); + select_disks(disks=>2); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed assert_and_click "anaconda_part_automatic"; - $self->custom_change_type("raid"); + custom_change_type("raid"); assert_and_click "anaconda_spoke_done"; assert_and_click "anaconda_part_accept_changes"; diff --git a/tests/disk_custom_xfs.pm b/tests/disk_custom_xfs.pm index 72f05759..56f409e2 100644 --- a/tests/disk_custom_xfs.pm +++ b/tests/disk_custom_xfs.pm @@ -1,21 +1,22 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Go to INSTALLATION DESTINATION and ensure the disk is selected. # Because PARTITIONING starts with 'custom_', this will select custom. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # Manual partitioning spoke should be displayed. Select Standard # Partition scheme - $self->custom_scheme_select("standard"); + custom_scheme_select("standard"); # Do 'automatic' partition creation assert_and_click "anaconda_part_automatic"; # Change root partition to xfs - $self->custom_change_fs("xfs"); + custom_change_fs("xfs"); assert_and_click "anaconda_spoke_done"; assert_and_click "anaconda_part_accept_changes"; diff --git a/tests/disk_guided_delete_all.pm b/tests/disk_guided_delete_all.pm index ae6d7ba3..40ad3558 100644 --- a/tests/disk_guided_delete_all.pm +++ b/tests/disk_guided_delete_all.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one disk is selected. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # the only provided disk should be automatically selected and full diff --git a/tests/disk_guided_delete_partial.pm b/tests/disk_guided_delete_partial.pm index c3189f29..0e521798 100644 --- a/tests/disk_guided_delete_partial.pm +++ b/tests/disk_guided_delete_partial.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one disk is selected. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # the only provided disk should be automatically selected and full diff --git a/tests/disk_guided_empty.pm b/tests/disk_guided_empty.pm index ced18da4..1696e36f 100644 --- a/tests/disk_guided_empty.pm +++ b/tests/disk_guided_empty.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one disk is selected. - $self->select_disks(); + select_disks(); # updates.img tests work by changing the appearance of the INSTALLATION # DESTINATION screen, so check that if needed. diff --git a/tests/disk_guided_encrypted.pm b/tests/disk_guided_encrypted.pm index 9e1eca12..ea0a3a23 100644 --- a/tests/disk_guided_encrypted.pm +++ b/tests/disk_guided_encrypted.pm @@ -1,13 +1,14 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one disk is selected. - $self->select_disks(); + select_disks(); # check "encrypt data" checkbox assert_and_click "anaconda_install_destination_encrypt_data"; diff --git a/tests/disk_guided_multi.pm b/tests/disk_guided_multi.pm index 551d6df9..827211b6 100644 --- a/tests/disk_guided_multi.pm +++ b/tests/disk_guided_multi.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and select only one disk. - $self->select_disks(disks=>1); + select_disks(disks=>1); assert_and_click "anaconda_spoke_done"; # Anaconda hub diff --git a/tests/disk_guided_multi_empty_all.pm b/tests/disk_guided_multi_empty_all.pm index 204fea6c..940c7467 100644 --- a/tests/disk_guided_multi_empty_all.pm +++ b/tests/disk_guided_multi_empty_all.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and select two disks. - $self->select_disks(disks=>2); + select_disks(disks=>2); assert_and_click "anaconda_spoke_done"; # Anaconda hub diff --git a/tests/disk_guided_shrink.pm b/tests/disk_guided_shrink.pm index 2b50286c..a854fc8d 100644 --- a/tests/disk_guided_shrink.pm +++ b/tests/disk_guided_shrink.pm @@ -1,12 +1,13 @@ use base "anacondatest"; use strict; use testapi; +use anaconda; sub run { my $self = shift; # Anaconda hub # Go to INSTALLATION DESTINATION and ensure one disk is selected. - $self->select_disks(); + select_disks(); assert_and_click "anaconda_spoke_done"; # the only provided disk should be automatically selected and full diff --git a/tests/freeipa_client.pm b/tests/freeipa_client.pm index 420395c9..0627eddd 100644 --- a/tests/freeipa_client.pm +++ b/tests/freeipa_client.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self=shift; diff --git a/tests/freeipa_password_change.pm b/tests/freeipa_password_change.pm index 756504e9..911f53bc 100644 --- a/tests/freeipa_password_change.pm +++ b/tests/freeipa_password_change.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; use freeipa; sub run { diff --git a/tests/freeipa_webui.pm b/tests/freeipa_webui.pm index 142048f0..e535f522 100644 --- a/tests/freeipa_webui.pm +++ b/tests/freeipa_webui.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; use freeipa; sub run { diff --git a/tests/install_arm_image_deployment.pm b/tests/install_arm_image_deployment.pm index 65da4407..7e88b0ca 100644 --- a/tests/install_arm_image_deployment.pm +++ b/tests/install_arm_image_deployment.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/install_source_graphical.pm b/tests/install_source_graphical.pm index 8812b21d..2f909ad9 100644 --- a/tests/install_source_graphical.pm +++ b/tests/install_source_graphical.pm @@ -1,7 +1,8 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; +use anaconda; use Time::HiRes qw( usleep ); sub run { @@ -40,14 +41,14 @@ sub run { # if either MIRRORLIST_GRAPHICAL or REPOSITORY_GRAPHICAL is set, type this into # the repository url input if (get_var("MIRRORLIST_GRAPHICAL")) { - $repourl = $self->get_mirrorlist_url(); + $repourl = get_mirrorlist_url(); type_safely $repourl; # select as mirror list assert_and_click "anaconda_install_source_repo_select_mirrorlist"; } elsif (get_var("REPOSITORY_GRAPHICAL")) { - $repourl = $self->get_full_repo(get_var("REPOSITORY_GRAPHICAL")); + $repourl = get_full_repo(get_var("REPOSITORY_GRAPHICAL")); # strip the 'nfs:' for typing here $repourl =~ s/^nfs://; type_safely $repourl; diff --git a/tests/install_text.pm b/tests/install_text.pm index 2f7e80ef..ea02bbf1 100644 --- a/tests/install_text.pm +++ b/tests/install_text.pm @@ -1,7 +1,7 @@ use base "anacondatest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/realmd_join_cockpit.pm b/tests/realmd_join_cockpit.pm index 6ebd1c23..26373e66 100644 --- a/tests/realmd_join_cockpit.pm +++ b/tests/realmd_join_cockpit.pm @@ -2,16 +2,17 @@ use base "installedtest"; use strict; use testapi; use lockapi; -use main_common; +use utils; +use tapnet; sub run { my $self = shift; # clone host's /etc/hosts (for phx2 internal routing to work) # must come *before* setup_tap_static or else it would overwrite # its changes - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.102", "client002.domain.local"); + setup_tap_static("10.0.2.102", "client002.domain.local"); # use FreeIPA server as DNS server assert_script_run "printf 'search domain.local\nnameserver 10.0.2.100' > /etc/resolv.conf"; # wait for the server to be ready (do it now just to make sure name @@ -22,7 +23,7 @@ sub run { # note: we can't use wait_screen_change, wait_still_screen or # check_type_string in cockpit because of that fucking constantly # scrolling graph - $self->start_cockpit(1); + start_cockpit(1); assert_and_click "cockpit_join_domain_button"; assert_screen "cockpit_join_domain"; send_key "tab"; diff --git a/tests/realmd_join_sssd.pm b/tests/realmd_join_sssd.pm index 158bfaab..d6186fd8 100644 --- a/tests/realmd_join_sssd.pm +++ b/tests/realmd_join_sssd.pm @@ -2,15 +2,17 @@ use base "installedtest"; use strict; use testapi; use lockapi; +use tapnet; +use utils; sub run { my $self=shift; # clone host's /etc/hosts (for phx2 internal routing to work) # must come *before* setup_tap_static or else it would overwrite # its changes - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.103", "client003.domain.local"); + setup_tap_static("10.0.2.103", "client003.domain.local"); # use FreeIPA server as DNS server assert_script_run "printf 'search domain.local\nnameserver 10.0.2.100' > /etc/resolv.conf"; # wait for the server to be ready (do it now just to make sure name @@ -18,7 +20,7 @@ sub run { mutex_lock "freeipa_ready"; mutex_unlock "freeipa_ready"; # use compose repo, disable u-t, etc. - $self->repo_setup(); + repo_setup(); # do the enrolment assert_script_run "echo 'monkeys123' | realm join --user=admin ipa001.domain.local", 300; } diff --git a/tests/role_deploy_database_server.pm b/tests/role_deploy_database_server.pm index 15e856cd..4a1256b0 100644 --- a/tests/role_deploy_database_server.pm +++ b/tests/role_deploy_database_server.pm @@ -3,16 +3,18 @@ use strict; use testapi; use lockapi; use mmapi; +use tapnet; +use utils; sub run { my $self=shift; - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.104", "db.domain.local"); + setup_tap_static("10.0.2.104", "db.domain.local"); # clone host's resolv.conf to get name resolution - $self->clone_host_file("/etc/resolv.conf"); + clone_host_file("/etc/resolv.conf"); # use compose repo, disable u-t, etc. - $self->repo_setup(); + repo_setup(); # deploy the database server role assert_script_run 'echo \'{"database":"openqa","owner":"openqa","password":"correcthorse"}\' | rolectl deploy databaseserver --settings-stdin', 300; # check the role status, should be 'running' diff --git a/tests/role_deploy_domain_controller.pm b/tests/role_deploy_domain_controller.pm index a3e2807c..6d6dc8c4 100644 --- a/tests/role_deploy_domain_controller.pm +++ b/tests/role_deploy_domain_controller.pm @@ -3,6 +3,8 @@ use strict; use testapi; use lockapi; use mmapi; +use tapnet; +use utils; sub run { my $self = shift; @@ -11,20 +13,20 @@ sub run { # clone host's /etc/hosts (for phx2 internal routing to work) # must come *before* setup_tap_static or else it would overwrite # its changes - $self->clone_host_file("/etc/hosts"); + clone_host_file("/etc/hosts"); # set up networking - $self->setup_tap_static("10.0.2.100", "ipa001.domain.local"); + setup_tap_static("10.0.2.100", "ipa001.domain.local"); # clone host's resolv.conf to get name resolution - $self->clone_host_file("/etc/resolv.conf"); + clone_host_file("/etc/resolv.conf"); # use compose repo, disable u-t, etc. - $self->repo_setup(); + repo_setup(); # we need a lot of entropy for this, and we don't care how good # it is, so let's use haveged assert_script_run 'dnf -y install haveged', 300; assert_script_run 'systemctl start haveged.service'; # read DNS server IPs from host's /etc/resolv.conf for passing to # rolectl - my @forwards = $self->get_host_dns(); + my @forwards = get_host_dns(); # we are now gonna work around a stupid bug in rolekit. we want to # pass it a list of ipv4 DNS forwarders and have no ipv6 DNS # forwarders. but it won't allow you to have a dns_forwarders array diff --git a/tests/server_cockpit_basic.pm b/tests/server_cockpit_basic.pm index 08619321..4659051f 100644 --- a/tests/server_cockpit_basic.pm +++ b/tests/server_cockpit_basic.pm @@ -1,11 +1,12 @@ use base "installedtest"; use strict; use testapi; +use utils; sub run { my $self=shift; # run firefox and login to cockpit - $self->start_cockpit(1); + start_cockpit(1); # go to the logs screen assert_and_click "cockpit_logs"; # the date dropdown changes and messes with the button locations, so wait diff --git a/tests/server_cockpit_default.pm b/tests/server_cockpit_default.pm index 5f085243..064d5fad 100644 --- a/tests/server_cockpit_default.pm +++ b/tests/server_cockpit_default.pm @@ -1,6 +1,7 @@ use base "installedtest"; use strict; use testapi; +use utils; sub run { my $self = shift; @@ -9,11 +10,11 @@ sub run { assert_script_run 'systemctl is-active cockpit.socket'; assert_script_run 'firewall-cmd --query-service cockpit'; # use compose repo, disable u-t, etc. - $self->repo_setup(); + repo_setup(); # install a desktop and firefox so we can actually try it assert_script_run 'dnf -y groupinstall "base-x"', 300; assert_script_run 'dnf -y install firefox', 120; - $self->start_cockpit(0); + start_cockpit(0); # quit firefox (return to console) send_key "ctrl-q"; } diff --git a/tests/upgrade_postinstall.pm b/tests/upgrade_postinstall.pm index 0d85571b..6367a172 100644 --- a/tests/upgrade_postinstall.pm +++ b/tests/upgrade_postinstall.pm @@ -1,13 +1,13 @@ use base "installedtest"; use strict; use testapi; - +use utils; sub run { my $self = shift; # try to login, check whether target release is installed $self->root_console(tty=>3); - $self->check_release(lc(get_var('VERSION'))); + check_release(lc(get_var('VERSION'))); } diff --git a/tests/upgrade_preinstall.pm b/tests/upgrade_preinstall.pm index 9dda0fca..e6086d2a 100644 --- a/tests/upgrade_preinstall.pm +++ b/tests/upgrade_preinstall.pm @@ -1,7 +1,7 @@ use base "installedtest"; use strict; use testapi; -use main_common; +use utils; sub run { my $self = shift; diff --git a/tests/upgrade_run.pm b/tests/upgrade_run.pm index bab0b15f..b3869d43 100644 --- a/tests/upgrade_run.pm +++ b/tests/upgrade_run.pm @@ -1,6 +1,7 @@ use base "installedtest"; use strict; use testapi; +use utils; sub run { my $self = shift; @@ -9,7 +10,7 @@ sub run { script_run "setterm -blank 0"; # use compose repo - $self->repo_setup(); + repo_setup(); my $params = "-y --releasever=${release}"; if ($release eq "rawhide") { $params .= " --nogpgcheck";