diff --git a/lib/cockpit.pm b/lib/cockpit.pm new file mode 100644 index 00000000..8ddeb1ee --- /dev/null +++ b/lib/cockpit.pm @@ -0,0 +1,53 @@ +package cockpit; + +use strict; + +use base 'Exporter'; +use Exporter; +use lockapi; +use testapi; +use utils; + +our @EXPORT = qw(start_cockpit select_cockpit_update check_updates); + + +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 $login = shift || 0; + # https://bugzilla.redhat.com/show_bug.cgi?id=1439429 + assert_script_run "sed -i -e 's,enable_xauth=1,enable_xauth=0,g' /usr/bin/startx"; + disable_firefox_studies; + # 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", 30; + # this happened on early Modular Server composes... + record_soft_failure "Unbranded Cockpit" if (match_has_tag "cockpit_login_unbranded"); + 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 select_cockpit_update { + # This method navigates to to the updates screen + assert_and_click "cockpit_software_updates", '', 120; + # wait for the updates to download + assert_screen 'cockpit_updates_check', 300; +} + +sub check_updates { + my $logfile = shift; + sleep 2; + my $checkresult = script_run "dnf check-update > $logfile"; + upload_logs "$logfile", failok=>1; + return($checkresult); +} diff --git a/lib/utils.pm b/lib/utils.pm index 9dd79675..47020b0e 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -7,7 +7,7 @@ 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 do_bootloader boot_decrypt check_release menu_launch_type start_cockpit repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist/; +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 boot_decrypt check_release menu_launch_type repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist/; sub run_with_error_check { my ($func, $error_screen) = @_; @@ -316,33 +316,6 @@ sub disable_firefox_studies { assert_script_run 'printf \'{"policies": {"DisableFirefoxStudies": true}}\' > $(rpm --eval %_libdir)/firefox/distribution/policies.json'; } -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 $login = shift || 0; - # https://bugzilla.redhat.com/show_bug.cgi?id=1439429 - assert_script_run "sed -i -e 's,enable_xauth=1,enable_xauth=0,g' /usr/bin/startx"; - disable_firefox_studies; - # 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", 45; - # this happened on early Modular Server composes... - record_soft_failure "Unbranded Cockpit" if (match_has_tag "cockpit_login_unbranded"); - # login screen has a flashing cursor so screen is not still at level 47 - wait_still_screen(stilltime=>5, similarity_level=>45); - 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 repos_mirrorlist { # Use mirrorlist not metalink so we don't hit the timing issue where # the infra repo is updated but mirrormanager metadata checksums diff --git a/needles/cockpit/autoupdate_planned_day.json b/needles/cockpit/autoupdate_planned_day.json new file mode 100644 index 00000000..3855333c --- /dev/null +++ b/needles/cockpit/autoupdate_planned_day.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 596, + "ypos": 331, + "width": 71, + "height": 19, + "type": "match" + } + ], + "properties": [], + "tags": [ + "autoupdate_planned_day" + ] +} \ No newline at end of file diff --git a/needles/cockpit/autoupdate_planned_day.png b/needles/cockpit/autoupdate_planned_day.png new file mode 100644 index 00000000..f230dd66 Binary files /dev/null and b/needles/cockpit/autoupdate_planned_day.png differ diff --git a/needles/cockpit/autoupdate_planned_time.json b/needles/cockpit/autoupdate_planned_time.json new file mode 100644 index 00000000..377c212c --- /dev/null +++ b/needles/cockpit/autoupdate_planned_time.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 797, + "ypos": 330, + "width": 50, + "height": 18, + "type": "match" + } + ], + "properties": [], + "tags": [ + "autoupdate_planned_time" + ] +} \ No newline at end of file diff --git a/needles/cockpit/autoupdate_planned_time.png b/needles/cockpit/autoupdate_planned_time.png new file mode 100644 index 00000000..f230dd66 Binary files /dev/null and b/needles/cockpit/autoupdate_planned_time.png differ diff --git a/needles/cockpit/cockpit_software_updates.json b/needles/cockpit/cockpit_software_updates.json new file mode 100644 index 00000000..8c1107fd --- /dev/null +++ b/needles/cockpit/cockpit_software_updates.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "width": 62, + "type": "match", + "ypos": 554, + "height": 22, + "xpos": 192 + } + ], + "properties": [], + "tags": [ + "cockpit_software_updates" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_software_updates.png b/needles/cockpit/cockpit_software_updates.png new file mode 100644 index 00000000..3596b3dd Binary files /dev/null and b/needles/cockpit/cockpit_software_updates.png differ diff --git a/needles/cockpit/cockpit_updates_all_install.json b/needles/cockpit/cockpit_updates_all_install.json new file mode 100644 index 00000000..bfc567e6 --- /dev/null +++ b/needles/cockpit/cockpit_updates_all_install.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 844, + "ypos": 362, + "height": 18, + "type": "match", + "width": 71 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_all_install" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_all_install.png b/needles/cockpit/cockpit_updates_all_install.png new file mode 100644 index 00000000..8246375a Binary files /dev/null and b/needles/cockpit/cockpit_updates_all_install.png differ diff --git a/needles/cockpit/cockpit_updates_auto.json b/needles/cockpit/cockpit_updates_auto.json new file mode 100644 index 00000000..677158ff --- /dev/null +++ b/needles/cockpit/cockpit_updates_auto.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "height": 34, + "type": "match", + "ypos": 190, + "width": 48, + "xpos": 468 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_auto" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_auto.png b/needles/cockpit/cockpit_updates_auto.png new file mode 100644 index 00000000..010073f4 Binary files /dev/null and b/needles/cockpit/cockpit_updates_auto.png differ diff --git a/needles/cockpit/cockpit_updates_auto_on.json b/needles/cockpit/cockpit_updates_auto_on.json new file mode 100644 index 00000000..149b9da2 --- /dev/null +++ b/needles/cockpit/cockpit_updates_auto_on.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "type": "match", + "width": 48, + "xpos": 613, + "ypos": 268, + "height": 27 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_auto_on" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_auto_on.png b/needles/cockpit/cockpit_updates_auto_on.png new file mode 100644 index 00000000..932e2fce Binary files /dev/null and b/needles/cockpit/cockpit_updates_auto_on.png differ diff --git a/needles/cockpit/cockpit_updates_available.json b/needles/cockpit/cockpit_updates_available.json new file mode 100644 index 00000000..3c41539b --- /dev/null +++ b/needles/cockpit/cockpit_updates_available.json @@ -0,0 +1,15 @@ +{ + "properties": [], + "tags": [ + "cockpit_updates_available" + ], + "area": [ + { + "xpos": 264, + "ypos": 259, + "width": 185, + "height": 28, + "type": "match" + } + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_available.png b/needles/cockpit/cockpit_updates_available.png new file mode 100644 index 00000000..e4784aef Binary files /dev/null and b/needles/cockpit/cockpit_updates_available.png differ diff --git a/needles/cockpit/cockpit_updates_check.json b/needles/cockpit/cockpit_updates_check.json new file mode 100644 index 00000000..8d6c1fc8 --- /dev/null +++ b/needles/cockpit/cockpit_updates_check.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 835, + "ypos": 191, + "height": 22, + "type": "match", + "width": 142 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_check" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_check.png b/needles/cockpit/cockpit_updates_check.png new file mode 100644 index 00000000..acc081b4 Binary files /dev/null and b/needles/cockpit/cockpit_updates_check.png differ diff --git a/needles/cockpit/cockpit_updates_console_update.json b/needles/cockpit/cockpit_updates_console_update.json new file mode 100644 index 00000000..0c7d9b61 --- /dev/null +++ b/needles/cockpit/cockpit_updates_console_update.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 304, + "ypos": 309, + "width": 143, + "height": 17, + "type": "match" + } + ], + "properties": [], + "tags": [ + "cockpit_updates_console_update" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_console_update.png b/needles/cockpit/cockpit_updates_console_update.png new file mode 100644 index 00000000..496616c6 Binary files /dev/null and b/needles/cockpit/cockpit_updates_console_update.png differ diff --git a/needles/cockpit/cockpit_updates_dnf_install-20190911.json b/needles/cockpit/cockpit_updates_dnf_install-20190911.json new file mode 100644 index 00000000..cba7c192 --- /dev/null +++ b/needles/cockpit/cockpit_updates_dnf_install-20190911.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "xpos": 909, + "height": 17, + "ypos": 554, + "type": "match", + "width": 43 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_dnf_install" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_dnf_install-20190911.png b/needles/cockpit/cockpit_updates_dnf_install-20190911.png new file mode 100644 index 00000000..a3331698 Binary files /dev/null and b/needles/cockpit/cockpit_updates_dnf_install-20190911.png differ diff --git a/needles/cockpit/cockpit_updates_dnf_install.json b/needles/cockpit/cockpit_updates_dnf_install.json new file mode 100644 index 00000000..6fd26ad9 --- /dev/null +++ b/needles/cockpit/cockpit_updates_dnf_install.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "ypos": 554, + "height": 17, + "xpos": 909, + "width": 43, + "type": "match" + } + ], + "properties": [], + "tags": [ + "cockpit_updates_dnf_install" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_dnf_install.png b/needles/cockpit/cockpit_updates_dnf_install.png new file mode 100644 index 00000000..8b88fd3e Binary files /dev/null and b/needles/cockpit/cockpit_updates_dnf_install.png differ diff --git a/needles/cockpit/cockpit_updates_reconnect.json b/needles/cockpit/cockpit_updates_reconnect.json new file mode 100644 index 00000000..6196d760 --- /dev/null +++ b/needles/cockpit/cockpit_updates_reconnect.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "ypos": 450, + "height": 21, + "xpos": 635, + "width": 94, + "type": "match" + } + ], + "properties": [], + "tags": [ + "cockpit_updates_reconnect" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_reconnect.png b/needles/cockpit/cockpit_updates_reconnect.png new file mode 100644 index 00000000..4d29f00d Binary files /dev/null and b/needles/cockpit/cockpit_updates_reconnect.png differ diff --git a/needles/cockpit/cockpit_updates_restart_confirm.json b/needles/cockpit/cockpit_updates_restart_confirm.json new file mode 100644 index 00000000..bad9aab8 --- /dev/null +++ b/needles/cockpit/cockpit_updates_restart_confirm.json @@ -0,0 +1,15 @@ +{ + "properties": [], + "tags": [ + "cockpit_updates_restart_confirm" + ], + "area": [ + { + "xpos": 576, + "ypos": 260, + "width": 46, + "height": 15, + "type": "match" + } + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_restart_confirm.png b/needles/cockpit/cockpit_updates_restart_confirm.png new file mode 100644 index 00000000..9a5f2d7c Binary files /dev/null and b/needles/cockpit/cockpit_updates_restart_confirm.png differ diff --git a/needles/cockpit/cockpit_updates_restart_ignore-20190919.json b/needles/cockpit/cockpit_updates_restart_ignore-20190919.json new file mode 100644 index 00000000..328f3532 --- /dev/null +++ b/needles/cockpit/cockpit_updates_restart_ignore-20190919.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "ypos": 376, + "height": 19, + "xpos": 543, + "type": "match", + "width": 51 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_restart_ignore" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_restart_ignore-20190919.png b/needles/cockpit/cockpit_updates_restart_ignore-20190919.png new file mode 100644 index 00000000..8894b4b3 Binary files /dev/null and b/needles/cockpit/cockpit_updates_restart_ignore-20190919.png differ diff --git a/needles/cockpit/cockpit_updates_restart_ignore.json b/needles/cockpit/cockpit_updates_restart_ignore.json new file mode 100644 index 00000000..bb457a2b --- /dev/null +++ b/needles/cockpit/cockpit_updates_restart_ignore.json @@ -0,0 +1,15 @@ +{ + "properties": [], + "tags": [ + "cockpit_updates_restart_ignore" + ], + "area": [ + { + "xpos": 519, + "ypos": 260, + "width": 43, + "height": 16, + "type": "match" + } + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_restart_ignore.png b/needles/cockpit/cockpit_updates_restart_ignore.png new file mode 100644 index 00000000..e93c6c01 Binary files /dev/null and b/needles/cockpit/cockpit_updates_restart_ignore.png differ diff --git a/needles/cockpit/cockpit_updates_security_install.json b/needles/cockpit/cockpit_updates_security_install.json new file mode 100644 index 00000000..c215f0ad --- /dev/null +++ b/needles/cockpit/cockpit_updates_security_install.json @@ -0,0 +1,15 @@ +{ + "properties": [], + "tags": [ + "cockpit_updates_security_install" + ], + "area": [ + { + "xpos": 619, + "ypos": 267, + "width": 93, + "height": 16, + "type": "match" + } + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_security_install.png b/needles/cockpit/cockpit_updates_security_install.png new file mode 100644 index 00000000..c7600fa9 Binary files /dev/null and b/needles/cockpit/cockpit_updates_security_install.png differ diff --git a/needles/cockpit/cockpit_updates_updated.json b/needles/cockpit/cockpit_updates_updated.json new file mode 100644 index 00000000..a65c4502 --- /dev/null +++ b/needles/cockpit/cockpit_updates_updated.json @@ -0,0 +1,15 @@ +{ + "area": [ + { + "width": 75, + "type": "match", + "ypos": 329, + "height": 60, + "xpos": 637 + } + ], + "properties": [], + "tags": [ + "cockpit_updates_updated" + ] +} \ No newline at end of file diff --git a/needles/cockpit/cockpit_updates_updated.png b/needles/cockpit/cockpit_updates_updated.png new file mode 100644 index 00000000..548086d8 Binary files /dev/null and b/needles/cockpit/cockpit_updates_updated.png differ diff --git a/templates b/templates index e7885b9f..e17b2e65 100755 --- a/templates +++ b/templates @@ -843,6 +843,17 @@ }, test_suite => { name => "server_cockpit_basic" }, }, + { + machine => { name => "64bit" }, + prio => 30, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "Server-dvd-iso", + version => "*", + }, + test_suite => { name => "server_cockpit_updates" }, + }, { machine => { name => "64bit" }, prio => 30, @@ -5281,6 +5292,20 @@ { key => "+HDD_1", value => "disk_%MACHINE%_cockpit.qcow2" }, ], }, + { + name => "server_cockpit_updates", + settings => [ + { key => "POSTINSTALL", value => "server_cockpit_updates server_cockpit_autoupdate" }, + { key => "USER_LOGIN", value => "false" }, + { key => "ROOT_PASSWORD", value => "weakpassword" }, + # to understand the '+' values in this test and the next, + # see the `jobs_from_update` docstring in fedora_openqa + # schedule.py + { key => "+START_AFTER_TEST", value => "server_cockpit_default" }, + { key => "BOOTFROM", value => "c" }, + { key => "+HDD_1", value => "disk_%MACHINE%_cockpit.qcow2" }, + ], + }, { name => "realmd_join_cockpit", settings => [ diff --git a/tests/realmd_join_cockpit.pm b/tests/realmd_join_cockpit.pm index 2a3fe1ce..cb090c43 100644 --- a/tests/realmd_join_cockpit.pm +++ b/tests/realmd_join_cockpit.pm @@ -4,6 +4,7 @@ use testapi; use lockapi; use utils; use tapnet; +use cockpit; sub run { my $self = shift; diff --git a/tests/server_cockpit_autoupdate.pm b/tests/server_cockpit_autoupdate.pm new file mode 100644 index 00000000..45b6ae37 --- /dev/null +++ b/tests/server_cockpit_autoupdate.pm @@ -0,0 +1,44 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use packagetest; +use cockpit; + +sub run { + my $self=shift; + bypass_1691487; + + # Start Cockpit + start_cockpit(1); + + # Navigate to the Update screen + select_cockpit_update(); + + # Switch on automatic updates + assert_and_click 'cockpit_updates_auto', '', 120; + assert_and_click 'cockpit_updates_dnf_install', '', 120; + assert_screen 'cockpit_updates_auto_on'; + + # Check the default automatic settings Everyday at 6 o'clock. + assert_screen 'autoupdate_planned_day'; + assert_screen 'autoupdate_planned_time'; + + # Quit Cockpit + send_key "ctrl-q"; + sleep 3; + + # Check that the dnf-automatic service has started + assert_script_run "systemctl is-active dnf-automatic-install.timer"; + + # Check that it is scheduled correctly + validate_script_output "systemctl show dnf-automatic-install.timer | grep TimersCalendar", sub {$_ =~ "06:00:00" }; +} + +sub test_flags { + return { always_rolllback => 1 }; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/server_cockpit_basic.pm b/tests/server_cockpit_basic.pm index b8a071a1..4899eda7 100644 --- a/tests/server_cockpit_basic.pm +++ b/tests/server_cockpit_basic.pm @@ -2,6 +2,7 @@ use base "installedtest"; use strict; use testapi; use utils; +use cockpit; sub run { my $self=shift; diff --git a/tests/server_cockpit_default.pm b/tests/server_cockpit_default.pm index 054f14b7..6a168bc8 100644 --- a/tests/server_cockpit_default.pm +++ b/tests/server_cockpit_default.pm @@ -2,6 +2,7 @@ use base "installedtest"; use strict; use testapi; use utils; +use cockpit; sub run { my $self = shift; diff --git a/tests/server_cockpit_updates.pm b/tests/server_cockpit_updates.pm new file mode 100644 index 00000000..1f3a6c34 --- /dev/null +++ b/tests/server_cockpit_updates.pm @@ -0,0 +1,87 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use packagetest; +use cockpit; + +sub run { + my $self=shift; + bypass_1691487; + + my $cockdate = "0"; + # Remove a package, disable repositories and enable test repositories, install the package + # from that repository to make the system outdated and verify that that package was + # correctly installed. + prepare_test_packages; + verify_installed_packages; + + # Start Cockpit + start_cockpit(1); + # Navigate to update screen + select_cockpit_update(); + + + # If security updates are available, install them first, + # so that we test the most buttons in one go. + # After updates, ignore restart because we do not need + # restarting the machine to continue. Also, we would have + # to deal with much more complicated workflow. + # + if (check_screen('cockpit_updates_security_install',1)) { + assert_and_click 'cockpit_updates_security_install'; + sleep 60; # wait until things are installed + assert_and_click 'cockpit_updates_restart_ignore'; + wait_still_screen 2; + } + + + # Install the rest of the updates, or any updates + # that have not been previously installed. + assert_and_click 'cockpit_updates_all_install'; + my $run = 0; + while ($run < 40) { + # When Cockpit packages are also included in the updates + # the user is forced to reconnect, i.e. to restart the Web Application + # and relog for further interaction. We will check if reconnection is + # needed and if so, we will restart Firefox and login again. + # + if (check_screen("cockpit_updates_reconnect", 1)) { + send_key "ctrl-q"; + sleep 5; + start_cockpit(1); + select_cockpit_update(); + $run = 50; + + } + # Ignore rebooting the system because we want to finish the test instead. + elsif (check_screen('cockpit_updates_restart_ignore', 1)) { + assert_and_click 'cockpit_updates_restart_ignore'; + $run = 50; + } + else { + sleep 10; + $run = $run + 1; + } + } + # Check that the system is updated + assert_screen 'cockpit_updates_updated'; + + # Switch off Cockpit + send_key "ctrl-q"; + + # Wait a couple of seconds for the terminal to settle down, the command was + # entered incorrectly which resulted in a failure. + sleep 5; + + # Verify that the test package was updated correctly. + verify_updated_packages; +} + +sub test_flags { + return { always_rollback => 1 }; +} + +1; + +# vim: set sw=4 et: