From 3723bc7f4db5233746ae9d9ddfeab6643ab2a2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= Date: Thu, 19 Sep 2024 12:07:01 +0200 Subject: [PATCH] Support for Product Increments in PublicCloud Maintenance tests It skips repo validation as there arent incidents that can be validated. Added workaround for problems with wget and skips *.repo file validation It excepts only one repository in MAINT_TEST_REPO variable --- lib/publiccloud/utils.pm | 4 +++ tests/publiccloud/download_repos.pm | 24 ++++++++++++----- tests/publiccloud/transfer_repos.pm | 40 ++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/lib/publiccloud/utils.pm b/lib/publiccloud/utils.pm index 178e3657215d..2bdc3e4e9e0a 100644 --- a/lib/publiccloud/utils.pm +++ b/lib/publiccloud/utils.pm @@ -146,6 +146,10 @@ sub register_openstack { # Validation for update repos sub validate_repo { my ($maintrepo) = @_; + if (is_sle_micro('>=6.0')) { + record_info("Product Increments", "Can't validate repository"); + return 1; + } if ($maintrepo =~ /\/(PTF|Maintenance):\/(\d+)/g) { my ($incident, $type) = ($2, $1); die "We did not detect incident number for URL \"$maintrepo\". We detected \"$incident\"" unless $incident =~ /\d+/; diff --git a/tests/publiccloud/download_repos.pm b/tests/publiccloud/download_repos.pm index ce3ec939e6e0..36da9339d964 100644 --- a/tests/publiccloud/download_repos.pm +++ b/tests/publiccloud/download_repos.pm @@ -13,6 +13,7 @@ use warnings; use testapi; use strict; use utils; +use version_utils 'is_sle_micro'; use publiccloud::ssh_interactive "select_host_console"; use publiccloud::utils "validate_repo"; @@ -60,24 +61,32 @@ sub run { my $count = scalar @repos; my $check_empty_repos = get_var('PUBLIC_CLOUD_IGNORE_EMPTY_REPO', 0) == 0; die "No test repositories" if ($check_empty_repos && $count == 0); - my $ret = 0; - my $reject = "'robots.txt,*.ico,*.png,*.gif,*.css,*.js,*.htm*'"; + my $reject = "'robots.txt,*.ico,*.png,*.gif,*.css,*.js,*.htm*,*.mirrorlist'"; my $regex = "'s390x\\/|ppc64le\\/|kernel*debuginfo*.rpm|src\\/'"; - my ($incident, $type); + set_var("PUBLIC_CLOUD_EMBARGOED_UPDATES_DETECTED", 0); + + # workaround for buggy wget + my $cutdirs; + if (is_sle_micro(">=6.0")) { + $cutdirs = '--cut-dirs=5'; + } + for my $maintrepo (@repos) { unless (validate_repo($maintrepo)) { set_var("PUBLIC_CLOUD_EMBARGOED_UPDATES_DETECTED", 1); next; } + script_run("echo 'Downloading $maintrepo ...' >> ~/repos/qem_download_status.txt"); my ($parent) = $maintrepo =~ 'https?://(.*)$'; my ($domain) = $parent =~ '^([a-zA-Z.]*)'; - $ret = script_run "wget --no-clobber -r --reject $reject --reject-regex=$regex --domains $domain --no-parent $maintrepo/", timeout => 600; + + $ret = script_run "wget $cutdirs --no-clobber -r --reject $reject --reject-regex=$regex --domains $domain --no-parent $maintrepo/", timeout => 600; if ($ret !~ /0|8/) { # softfailure, if repo doesn't exist (anymore). This is required for cloning jobs, because the original test repos could be empty already - record_info('Softfail', "Download failed (rc=$ret):\n$maintrepo", result => 'softfail'); + record_info('Softfail', "Download /failed (rc=$ret):\n$maintrepo", result => 'softfail'); script_run("echo 'Download failed for $maintrepo ...' >> ~/repos/qem_download_status.txt"); } else { assert_script_run("echo -en '\\n" . ('#' x 80) . "\\n# $maintrepo:\\n' >> /tmp/repos.list.txt"); @@ -85,6 +94,9 @@ sub run { if (script_run("ls $parent/*.repo") == 0) { assert_script_run(sprintf(q(sed -i '1 s/]/_%s]/' %s/*.repo), random_string(4), $parent)); assert_script_run("find $parent >> /tmp/repos.list.txt"); + } elsif (is_sle_micro(">=6.0")) { + $parent =~ s/ibs\/SUSE:\/ALP:\/Products:\/Marble:\///; + assert_script_run("find $parent >> /tmp/repos.list.txt"); } else { record_info('Softfail', "No .repo file found in $parent. This directory will be removed.", result => 'softfail'); assert_script_run("echo 'No .repo found for $maintrepo' >> ~/repos/qem_download_status.txt"); @@ -97,7 +109,7 @@ sub run { upload_logs('/tmp/repos.list.txt'); upload_logs('qem_download_status.txt'); # Failsafe 2: Ensure the repos are not empty (i.e. size >= 100 kB) - my $size = script_output('du -s ~/repos | awk \'{print$1}\''); + my $size = script_output(q(du -s ~/repos | awk '{print $1}')); # we will not die if repos are empty due to embargoed updates filtering die "Empty test repositories" if (!get_var("PUBLIC_CLOUD_EMBARGOED_UPDATES_DETECTED") && $check_empty_repos && $size < 100); } diff --git a/tests/publiccloud/transfer_repos.pm b/tests/publiccloud/transfer_repos.pm index a96574492058..b2e8de0d38c0 100644 --- a/tests/publiccloud/transfer_repos.pm +++ b/tests/publiccloud/transfer_repos.pm @@ -16,12 +16,14 @@ use strict; use utils; use publiccloud::ssh_interactive "select_host_console"; use maintenance_smelt qw(is_embargo_update); +use version_utils qw(is_sle_micro); sub run { my ($self, $args) = @_; select_host_console(); # select console on the host, not the PC instance - my $remote = $args->{my_instance}->username . '@' . $args->{my_instance}->public_ip; + my $instance = $args->{my_instance}; + my $remote = $instance->username . '@' . $args->{my_instance}->public_ip; my @addons = split(/,/, get_var('SCC_ADDONS', '')); my $skip_mu = get_var('PUBLIC_CLOUD_SKIP_MU', 0); my $repodir = "/opt/repos/"; @@ -31,7 +33,7 @@ sub run { } else { assert_script_run('du -sh ~/repos'); my $timeout = 2400; - $args->{my_instance}->retry_ssh_command(cmd => "which rsync || sudo zypper -n in rsync", timeout => 420, retry => 6, delay => 60); + $instance->retry_ssh_command(cmd => "which rsync || sudo zypper -n in rsync", timeout => 420, retry => 6, delay => 60); # In Incidents there is INCIDENT_REPO instead of MAINT_TEST_REPO # Those two variables contain list of repositories separated by comma @@ -48,18 +50,27 @@ sub run { my @repos; my ($incident, $type); for my $maintrepo (@all_repos) { - ($incident, $type) = ($2, $1) if ($maintrepo =~ /\/(PTF|Maintenance):\/(\d+)/g); - push(@repos, $maintrepo) unless (is_embargo_update($incident, $type)); + if (is_sle_micro(">=6.0")) { + push(@repos, $maintrepo); + } else { + ($incident, $type) = ($2, $1) if ($maintrepo =~ /\/(PTF|Maintenance):\/(\d+)/g); + push(@repos, $maintrepo) unless (is_embargo_update($incident, $type)); } } s/https?:\/\/// for @repos; # Create list of directories for rsync + # hold last processed repo in sub scope; for PI its only one repo and we need reuse this var + my $slmrepo; foreach my $repo (@repos) { + if (is_sle_micro(">=6.0")) { + $repo =~ s/ibs\/SUSE:\/ALP:\/Products:\/Marble:\///; + $slmrepo = $repo; + } assert_script_run("echo $repo | tee -a /tmp/transfer_repos.txt"); } # VM repos.dir support preparation - $args->{my_instance}->ssh_assert_script_run("sudo mkdir $repodir;sudo chmod 777 $repodir"); + $instance->ssh_assert_script_run("sudo mkdir $repodir;sudo chmod 777 $repodir"); # Mitigate occasional CSP network problems (especially one CSP is prone to those issues!) # Delay of 2 minutes between the tries to give their network some time to recover after a failure # For rsync the ~/repos/./ means that the --relative will take efect after. @@ -69,16 +80,21 @@ sub run { # --recursive (-r), --update (-u), --archive (-a), --human-readable (-h), --rsh (-e) script_retry("rsync --timeout=$timeout -ruahd -e ssh --files-from /tmp/transfer_repos.txt ~/repos/./ '$remote:$repodir'", timeout => $timeout + 10, retry => 3, delay => 120); - my $total_size = $args->{my_instance}->ssh_script_output(cmd => "du -hs $repodir"); + my $total_size = $instance->ssh_script_output(cmd => "du -hs $repodir"); record_info("Repo size", "Total repositories size: $total_size"); - $args->{my_instance}->ssh_assert_script_run("find $repodir -name '*.rpm' -exec du -h '{}' + | sort -h > /tmp/rpm_list.txt", timeout => 60); - $args->{my_instance}->upload_log('/tmp/rpm_list.txt'); + $instance->ssh_assert_script_run("find $repodir -name '*.rpm' -exec du -h '{}' + | sort -h > /tmp/rpm_list.txt", timeout => 60); + $instance->upload_log('/tmp/rpm_list.txt'); - $args->{my_instance}->ssh_assert_script_run("sudo find $repodir -name *.repo -exec sed -i 's,http://,$repodir,g' '{}' \\;"); - $args->{my_instance}->ssh_assert_script_run("sudo find $repodir -name *.repo -exec zypper ar -p10 '{}' \\;"); - $args->{my_instance}->ssh_assert_script_run("sudo find $repodir -name *.repo -exec echo '{}' \\;"); + if (is_sle_micro(">=6.0")) { + $instance->ssh_assert_script_run("sudo zypper ar -p10 " . $repodir . $slmrepo . " ToTest"); + } + else { + $instance->ssh_assert_script_run("sudo find $repodir -name *.repo -exec sed -i 's,http://,$repodir,g' '{}' \\;"); + $instance->ssh_assert_script_run("sudo find $repodir -name *.repo -exec zypper ar -p10 '{}' \\;"); + $instance->ssh_assert_script_run("sudo find $repodir -name *.repo -exec echo '{}' \\;"); + } - $args->{my_instance}->ssh_assert_script_run("zypper lr -P"); + $instance->ssh_assert_script_run("zypper lr -P"); } }