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

Consolidate package installs with retries #170

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ use Exporter;
use testapi;
use File::Basename qw(basename);

our @EXPORT = qw(get_log clear_root_console switch_to_root_console switch_to_x11 wait_for_desktop ensure_unlocked_desktop wait_for_container_log prepare_firefox_autoconfig disable_packagekit);
our @EXPORT = qw(get_log install_packages clear_root_console switch_to_root_console switch_to_x11 wait_for_desktop ensure_unlocked_desktop wait_for_container_log prepare_firefox_autoconfig disable_packagekit);

sub get_log ($cmd, $name) {
my $ret = script_run "$cmd | tee $name";
upload_logs($name) unless $ret;
}

sub install_packages($packages, $timeout = undef) {
$timeout //= 600;
assert_script_run(qq{retry -e -s 30 -r 7 -- sh -c "zypper -n --gpg-auto-import-keys ref && zypper --no-cd -n in $packages"}, $timeout);
okurz marked this conversation as resolved.
Show resolved Hide resolved
}

sub clear_root_console {
enter_cmd 'clear';
enter_cmd 'cd';
Expand Down
6 changes: 3 additions & 3 deletions tests/install/openqa_webui.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sub install_from_repos {
$add_repo = "zypper -n ar -p 95 -f obs://devel:openQA/$repo openQA";
assert_script_run($_) foreach (split /\n/, $add_repo);
my $proxy_pkg = (check_var('OPENQA_WEB_PROXY', 'nginx')) ? 'nginx' : '';
assert_script_run('retry -e -s 30 -- sh -c "zypper -n --gpg-auto-import-keys ref && zypper --no-cd -n in openQA-local-db '.$proxy_pkg.'"', 600);
install_packages("openQA-local-db $proxy_pkg");
my $proxy_args = '';
if (my $proxy = get_var('OPENQA_WEB_PROXY')) { $proxy_args = "--proxy=$proxy" }
assert_script_run "/usr/share/openqa/script/configure-web-proxy $proxy_args";
Expand Down Expand Up @@ -60,12 +60,12 @@ sub install_from_git {
}

sub install_containers {
assert_script_run('retry -s 30 -- zypper -n in docker git', timeout => 600);
install_packages('docker git');
assert_script_run('systemctl start docker');
}

sub install_from_bootstrap {
assert_script_run('zypper --no-cd -n in openQA-bootstrap');
install_packages('openQA-bootstrap');
assert_script_run('skip_suse_specifics=1 skip_suse_tests=1 /usr/share/openqa/script/openqa-bootstrap', timeout => 1200);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/install/openqa_worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use utils;

sub run {
diag('worker setup');
assert_script_run('retry -e -s 30 -r 7 -- sh -c "zypper -n --gpg-auto-import-keys ref && zypper --no-cd -n in openQA-worker"', 3800);
install_packages('openQA-worker', 3800);
diag('Login once with fake authentication on openqa webUI to actually create preconfigured API keys for worker authentication');
assert_script_run('curl http://localhost/login');
diag('adding temporary, preconfigured API keys to worker config');
Expand Down
2 changes: 1 addition & 1 deletion tests/install/test_distribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sub run {
# changes within the 10 minutes refresh dead-time applied by default in
# /etc/zypp/zypp.conf so we need to refresh explicitly with retries in
# case of problems.
assert_script_run('retry -e -s 30 -- sh -c "zypper ref && zypper -n in os-autoinst-distri-opensuse-deps"', 600);
install_packages('os-autoinst-distri-opensuse-deps');
clear_root_console;
# prepare for next test
enter_cmd 'logout';
Expand Down