Skip to content

Commit 9b1e55e

Browse files
Add aggregate repos to ibsm modules
1 parent 1c079b9 commit 9b1e55e

4 files changed

Lines changed: 46 additions & 8 deletions

File tree

lib/sles4sap.pm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use Mojo::Base 'opensusebasetest';
1313
use strict;
1414
use warnings;
1515
use testapi;
16+
use bmwqemu ();
1617
use serial_terminal qw(select_serial_terminal);
1718
use utils;
1819
use hacluster qw(get_hostname ha_export_logs pre_run_hook save_state wait_until_resources_started script_output_retry_check);
@@ -72,6 +73,7 @@ our @EXPORT = qw(
7273
load_ase_env
7374
upload_ase_logs
7475
modify_selinux_setenforce
76+
get_test_repos
7577
);
7678

7779
=head1 SYNOPSIS
@@ -1452,6 +1454,28 @@ sub modify_selinux_setenforce {
14521454
}
14531455
}
14541456

1457+
=head2 get_test_repos
1458+
1459+
Constructs an array of repos to be added to SUTs.
1460+
1461+
=cut
1462+
1463+
sub get_test_repos {
1464+
# In Incidents there is INCIDENT_REPO instead of MAINT_TEST_REPO
1465+
# Those two variables contain list of repositories separated by comma
1466+
set_var('MAINT_TEST_REPO', get_var('INCIDENT_REPO')) if get_var('INCIDENT_REPO');
1467+
my @repos = split(/,/, get_var('MAINT_TEST_REPO'));
1468+
# Add aggregate repos to @repos, if they are provided
1469+
# Test repos are expected to end in '_TEST_REPOS'
1470+
my @test_repos = grep { /_TEST_REPOS$/ } keys %bmwqemu::vars;
1471+
for my $repo (@test_repos) {
1472+
if (my $value = get_var($repo)) {
1473+
push @repos, split(/,/, $value);
1474+
}
1475+
}
1476+
return @repos;
1477+
}
1478+
14551479
sub post_run_hook {
14561480
my ($self) = @_;
14571481

t/17_sles4sap.t

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ sub undef_vars {
1919
_SECRET_SAP_MASTER_PASSWORD
2020
ASCS_PRODUCT_ID
2121
INSTANCE_ID
22-
ASSET_0);
22+
ASSET_0
23+
BALAMB_TEST_REPOS
24+
WINHILL_TEST_REPOS);
2325
}
2426

2527
subtest '[prepare_swpm]' => sub {
@@ -296,5 +298,20 @@ subtest '[download_hana_assets_from_server]' => sub {
296298
ok((any { /wget.*MY_DOWNLOAD_URL/ } @calls), 'wget call');
297299
};
298300

301+
subtest '[get_test_repos]' => sub {
302+
my $mockObject = sles4sap->new();
303+
my $sles4sap = Test::MockModule->new('sles4sap', no_auto => 1);
304+
305+
set_var('BALAMB_TEST_REPOS', 'Squall,Seifer');
306+
set_var('WINHILL_TEST_REPOS', 'Quistis,Rinoa');
307+
$sles4sap->redefine(set_var => sub { return; });
308+
309+
my @repos = $mockObject->get_test_repos();
310+
undef_vars();
311+
312+
ok((any { /.*Squall.*/ } @repos), 'Returns the correct variable from the first repo');
313+
ok((any { /.*Quistis.*/ } @repos), 'Returns the correct variable from the second repo');
314+
};
315+
299316

300317
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 sles4sap;
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 = sles4sap::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 sles4sap;
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 = sles4sap::get_test_repos();
2322
my $count = 0;
2423
my @zypper_cmd;
2524

0 commit comments

Comments
 (0)