Skip to content

Commit

Permalink
Control SDAF version to use latest -1
Browse files Browse the repository at this point in the history
TEAM-9683 - [SDAF][research] Mechanism to control SDAF version
  • Loading branch information
lilyeyes committed Dec 2, 2024
1 parent 03c40ff commit e8f036b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/sles4sap/sap_deployment_automation_framework/deployment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package sles4sap::sap_deployment_automation_framework::deployment;

use strict;
use warnings;
use version;
use testapi;
use Exporter qw(import);
use Carp qw(croak);
Expand Down Expand Up @@ -562,8 +563,28 @@ sub prepare_sdaf_project {
assert_script_run("cd $deployment_dir");
assert_script_run('mkdir -p ' . log_dir());

# Calculate SDAF version used for deployment and picks latest -1
# SDAF_GIT_AUTOMATION_BRANCH variable will override calculated value
my $branch = get_var('SDAF_GIT_AUTOMATION_BRANCH');
if (!$branch || $branch eq 'latest') {
my $tags = script_output("curl -s https://github.com/Azure/sap-automation/tags | grep /releases/tag/ | grep data-view-component | cut -d '/' -f6 | cut -d '\"' -f1");
record_info("Releases: $tags");
my @releases = split('\n', $tags);
my $branch_expected = $releases[1];
if ($branch eq 'latest') {
$branch_expected = $releases[0];
}
my $branch_er = version->new('v3.11.0.3');
$branch_expected = version->new("$branch_expected");
if ($branch_expected <= $branch_er) {
die "Version $branch_expected older or equal than $branch_er missing features";
}
$branch = $branch_expected;
}
record_info("Release: $branch");

git_clone(get_required_var('SDAF_GIT_AUTOMATION_REPO'),
branch => get_var('SDAF_GIT_AUTOMATION_BRANCH'),
branch => $branch,
depth => '1',
single_branch => 'yes',
output_log_file => log_dir() . '/git_clone_automation.txt');
Expand Down
4 changes: 4 additions & 0 deletions t/20_sdaf_deployment_library.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ subtest '[prepare_sdaf_project]' => sub {
$ms_sdaf->redefine(git_clone => sub { return; });
$ms_sdaf->redefine(get_workload_vnet_code => sub { return 'SAP04'; });
$ms_sdaf->redefine(log_dir => sub { return '/tmp/openqa_logs'; });
$ms_sdaf->redefine(script_output => sub { return "v4\nv5"; });
$ms_sdaf->redefine(assert_script_run => sub {
push(@git_commands, join('', $_[0])) if grep(/git/, $_[0]);
return 1; });
Expand All @@ -55,6 +56,7 @@ subtest '[prepare_sdaf_project]' => sub {
return '/some/useless/path'; });
set_var('SDAF_GIT_AUTOMATION_REPO', 'https://github.com/Azure/sap-automation.git');
set_var('SDAF_GIT_TEMPLATES_REPO', 'https://github.com/Azure/sap-automation-samples.git');
set_var('SDAF_GIT_AUTOMATION_BRANCH', 'latest');

prepare_sdaf_project(%arguments);

Expand Down Expand Up @@ -84,6 +86,7 @@ subtest '[prepare_sdaf_project] Check directory creation' => sub {
$ms_sdaf->redefine(record_soft_failure => sub { return; });

$ms_sdaf->redefine(record_info => sub { return; });
$ms_sdaf->redefine(script_output => sub { return "v4\nv5"; });
$ms_sdaf->redefine(assert_script_run => sub { push(@mkdir_commands, $_[0]) if grep(/mkdir/, @_); return 1; });
$ms_sdaf->redefine(deployment_dir => sub { return '/tmp/SDAF'; });
$ms_sdaf->redefine(get_tfvars_path => sub { return $tfvars_file; });
Expand All @@ -93,6 +96,7 @@ subtest '[prepare_sdaf_project] Check directory creation' => sub {

set_var('SDAF_GIT_AUTOMATION_REPO', 'https://github.com/Azure/sap-automation/tree/main');
set_var('SDAF_GIT_TEMPLATES_REPO', 'https://github.com/Azure/SAP-automation-samples/tree/main');
set_var('SDAF_GIT_AUTOMATION_BRANCH', 'latest');

prepare_sdaf_project(%arguments);
is $mkdir_commands[0], 'mkdir -p /tmp/openqa_logs', 'Create logging directory';
Expand Down

0 comments on commit e8f036b

Please sign in to comment.