Skip to content

Commit b22f059

Browse files
Add aggregate repos to ibsm modules
Related ticket: https://jira.suse.com/browse/TEAM-9981
1 parent 1c079b9 commit b22f059

5 files changed

Lines changed: 55 additions & 9 deletions

File tree

lib/qam.pm

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use version_utils qw(is_sle is_transactional);
2020
our @EXPORT
2121
= qw(capture_state check_automounter is_patch_needed add_test_repositories disable_test_repositories enable_test_repositories
2222
add_extra_customer_repositories ssh_add_test_repositories remove_test_repositories advance_installer_window get_patches check_patch_variables add_repo_if_not_present
23-
has_published_assets);
23+
has_published_assets get_test_repos);
2424
use constant ZYPPER_PACKAGE_COL => 1;
2525
use constant OLD_ZYPPER_STATUS_COL => 4;
2626
use constant ZYPPER_STATUS_COL => 5;
@@ -249,4 +249,23 @@ sub has_published_assets {
249249
return scalar grep { m/^PUBLISH_/ } keys %bmwqemu::vars;
250250
}
251251

252+
# Return list of all available repos
253+
sub get_test_repos {
254+
# In Incidents there is INCIDENT_REPO instead of MAINT_TEST_REPO
255+
# Those two variables contain list of repositories separated by comma
256+
set_var('MAINT_TEST_REPO', get_var('INCIDENT_REPO')) if get_var('INCIDENT_REPO');
257+
my @repos = split(/,/, get_var('MAINT_TEST_REPO'));
258+
# Add aggregate repos to @repos, if they are provided
259+
# Test repos are expected to end in '_TEST_REPOS'
260+
# These vars are set by qem-bot, e.g.
261+
# https://github.com/openSUSE/qem-bot/blob/ecb7acc8badccce85969e05f368455390b1ab6eb/openqabot/types/aggregate.py#L104
262+
my @test_repos = grep { /_TEST_REPOS$/ } keys %bmwqemu::vars;
263+
for my $repo (@test_repos) {
264+
if (my $value = get_var($repo)) {
265+
push @repos, split(/,/, $value);
266+
}
267+
}
268+
return @repos;
269+
}
270+
252271
1;

t/17_sles4sap.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,4 @@ subtest '[download_hana_assets_from_server]' => sub {
296296
ok((any { /wget.*MY_DOWNLOAD_URL/ } @calls), 'wget call');
297297
};
298298

299-
300299
done_testing;

t/33_qam.t

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
use Test::Warnings;
5+
use Test::MockModule;
6+
use List::Util qw(any none);
7+
use testapi;
8+
use qam;
9+
10+
sub undef_vars {
11+
set_var($_, undef) for qw(
12+
BALAMB_TEST_REPOS
13+
WINHILL_TEST_REPOS
14+
);
15+
}
16+
17+
subtest '[get_test_repos]' => sub {
18+
set_var('BALAMB_TEST_REPOS', 'Squall,Seifer');
19+
set_var('WINHILL_TEST_REPOS', 'Quistis,Rinoa');
20+
21+
my $qam_mock = Test::MockModule->new('qam', no_auto => 1);
22+
$qam_mock->redefine('set_var', sub { return; });
23+
24+
my @repos = $qam_mock->get_test_repos();
25+
26+
undef_vars();
27+
28+
ok( (any { /.*Squall.*/ } @repos), 'Got "Squall" from BALAMB_TEST_REPOS' );
29+
};
30+
31+
done_testing;

tests/publiccloud/validate_repos.pm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use warnings;
1313
use testapi;
1414
use strict;
1515
use utils;
16+
use qam;
1617
use publiccloud::ssh_interactive "select_host_console";
1718
use publiccloud::utils "validate_repo";
1819

@@ -25,10 +26,7 @@ sub run {
2526
record_info('Skip validation', 'Skipping maintenance update validation (triggered by setting)');
2627
return;
2728
} else {
28-
# In Incidents there is INCIDENT_REPO instead of MAINT_TEST_REPO
29-
# Those two variables contain list of repositories separated by comma
30-
set_var('MAINT_TEST_REPO', get_var('INCIDENT_REPO')) unless get_var('MAINT_TEST_REPO');
31-
my @repos = split(/,/, get_var('MAINT_TEST_REPO'));
29+
my @repos = get_test_repos();
3230
# Failsafe: Fail if there are no test repositories, otherwise we have the wrong template link
3331
my $count = scalar @repos;
3432
my $check_empty_repos = get_var('PUBLIC_CLOUD_IGNORE_EMPTY_REPO', 0) == 0;

tests/sles4sap/publiccloud/cluster_add_repos.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use strict;
88
use warnings;
99
use base 'sles4sap_publiccloud_basetest';
1010
use sles4sap_publiccloud;
11+
use qam;
1112
use testapi;
1213

1314
sub test_flags {
@@ -17,9 +18,7 @@ sub test_flags {
1718
sub run {
1819
my ($self, $run_args) = @_;
1920
$self->import_context($run_args);
20-
21-
set_var('MAINT_TEST_REPO', get_var('INCIDENT_REPO')) if get_var('INCIDENT_REPO');
22-
my @repos = split(/,/, get_var('MAINT_TEST_REPO'));
21+
my @repos = get_test_repos();
2322
my $count = 0;
2423
my @zypper_cmd;
2524

0 commit comments

Comments
 (0)