From 54a93f21e5ba668ddfad3b1e796e3a5a07216de6 Mon Sep 17 00:00:00 2001 From: Trevor Cooper Date: Sat, 2 Jul 2022 21:59:24 -0700 Subject: [PATCH] add dnf_contentdir library function and implement is sample tests --- lib/utils.pm | 17 ++++++++++++++++- tests/_collect_data.pm | 3 +++ tests/base_update_cli.pm | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/utils.pm b/lib/utils.pm index 397d253a..95bb3da5 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -8,7 +8,7 @@ use Exporter; use feature "switch"; 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 repo_setup setup_workaround_repo cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop 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 get_release_number get_code_name 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 register_application get_registered_applications solidify_wallpaper/; +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 dnf_contentdir setup_workaround_repo cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop 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 get_release_number get_code_name 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 register_application get_registered_applications solidify_wallpaper/; # We introduce this global variable to hold the list of applications that have # registered during the apps_startstop_test when they have sucessfully run. @@ -628,6 +628,21 @@ sub repo_setup { assert_script_run "rm -f /etc/yum.repos.d/fedora-cisco-openh264.repo"; } +sub _dnf_contentdir_reset { + # Restore default repository contentdir + script_run 'printf "pub/rocky\n" > /etc/dnf/vars/contentdir'; +} + +sub _dnf_contentdir_set { + # Point at staging repositories by modifying contentdir + script_run 'printf "stg/rocky\n" > /etc/dnf/vars/contentdir'; +} + +sub dnf_contentdir { + # Modify the Rocky Linux repository baseurl's if needed + get_var("DNF_CONTENTDIR") ? _dnf_contentdir_set : _dnf_contentdir_reset +} + sub console_initial_setup { # Handle console initial-setup. Currently used only for ARM disk # image tests. diff --git a/tests/_collect_data.pm b/tests/_collect_data.pm index 866a858a..2f21e9cd 100644 --- a/tests/_collect_data.pm +++ b/tests/_collect_data.pm @@ -1,10 +1,13 @@ use base "installedtest"; use strict; use testapi; +use utils; sub run { my $self = shift; $self->root_console(tty=>4); + # support switching to stg repos + dnf_contentdir(); assert_script_run 'top -i -n20 -b > /var/tmp/top.log', 120; upload_logs '/var/tmp/top.log'; unless (get_var("CANNED")) { diff --git a/tests/base_update_cli.pm b/tests/base_update_cli.pm index 66221d08..2fc25078 100644 --- a/tests/base_update_cli.pm +++ b/tests/base_update_cli.pm @@ -2,11 +2,14 @@ use base "installedtest"; use strict; use testapi; use packagetest; +use utils; sub run { my $self = shift; # switch to TTY3 for both, graphical and console tests $self->root_console(tty=>3); + # support switching to stg repos + dnf_contentdir(); # enable test repos and install test packages prepare_test_packages; # check rpm agrees they installed good