Skip to content

Commit

Permalink
Schedule SDAF test in PCloud Latest HA+SAP JP
Browse files Browse the repository at this point in the history
Schedule SDAF test in Public Cloud / Latest HA+SAP Job Group
TEAM-9689 - [SDAF] Schedule SDAF test in Public Cloud / Latest HA+SAP Job Group
  • Loading branch information
lilyeyes committed Mar 5, 2025
1 parent 666879c commit 89b5901
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use Carp qw(croak);
use utils qw(file_content_replace);
use sles4sap::sap_deployment_automation_framework::deployment qw(get_os_variable);
use sles4sap::sap_deployment_automation_framework::deployment_connector qw(find_deployment_id);
use Mojo::Base qw(publiccloud::basetest publiccloud::azure);
use publiccloud::utils 'is_azure';

=head1 SYNOPSIS
Expand Down Expand Up @@ -144,12 +146,18 @@ sub set_image_parameters {
my @variable_names = qw(SDAF_IMAGE_PUBLISHER SDAF_IMAGE_OFFER SDAF_IMAGE_SKU SDAF_IMAGE_VERSION);
# This maps a variable name from array @variable names to value from delimited 'PUBLIC_CLOUD_IMAGE_ID' parameter
# Order is important here
@params{@variable_names} = split(':', get_required_var('PUBLIC_CLOUD_IMAGE_ID'));

# Add all remaining parameters with static values
$params{SDAF_IMAGE_OS_TYPE} = 'LINUX'; # this can be modified in case of non linux images
$params{SDAF_SOURCE_IMAGE_ID} = ''; # for supplying uploaded image - not implemented yet
$params{SDAF_IMAGE_TYPE} = 'marketplace';
if (is_azure() && get_var('PUBLIC_CLOUD_IMAGE_LOCATION')) {
my $provider = publiccloud::basetest::provider_factory();
$params{SDAF_SOURCE_IMAGE_ID} = $provider->get_image_id();; # for supplying uploaded image
$params{SDAF_IMAGE_TYPE} = 'custom';
}
else {
@params{@variable_names} = split(':', get_required_var('PUBLIC_CLOUD_IMAGE_ID'));
$params{SDAF_IMAGE_TYPE} = 'marketplace';
}

foreach (keys(%params)) {
set_var($_, $params{$_});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ our @EXPORT = qw(
load_os_env_variables
sdaf_cleanup
sdaf_execute_playbook
ansible_execute_command
ansible_show_status
playbook_settings
$output_log_file
Expand Down Expand Up @@ -903,9 +904,10 @@ sub ansible_execute_command {
my @cmd = ('ansible', $args{host_group},
"--private-key=$args{sdaf_config_root_dir}/sshkey",
"--inventory=$args{sap_sid}_hosts.yaml",
'-vvv',
'--module-name=shell');

return script_output(join(' ', @cmd, "--args=\"$args{command}\"", '2> /dev/null'));
return script_output(join(' ', @cmd, "--args=\"$args{command}\""));
}

=head2 playbook_settings
Expand Down
4 changes: 4 additions & 0 deletions t/27_sdaf_configure_tfvars.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use Test::Warnings;
use Test::MockModule;
use testapi;
use sles4sap::sap_deployment_automation_framework::configure_tfvars;
use publiccloud::utils 'is_azure';

sub undef_variables {
# undefines OpenQA variables
Expand Down Expand Up @@ -67,7 +68,10 @@ subtest '[set_image_parameters]' => sub {
$ms_sdaf->redefine(set_netweaver_parameters => sub { return 'americano'; });
$ms_sdaf->redefine(data_url => sub { return 'capuccino'; });
$ms_sdaf->redefine(validate_components => sub { return 'mocha'; });
$ms_sdaf->redefine(is_azure => sub { return 0; });

set_var('PUBLIC_CLOUD_IMAGE_LOCATION', '');
set_var('SDAF_SOURCE_IMAGE_ID', '');
set_var('PUBLIC_CLOUD_IMAGE_ID', 'suse:sles-sap-15-sp6:gen2:latest');
prepare_tfvars_file(deployment_type => 'sap_system');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use parent 'sles4sap::sap_deployment_automation_framework::basetest';
use strict;
use warnings;
use sles4sap::sap_deployment_automation_framework::deployment;
use sles4sap::sap_deployment_automation_framework::naming_conventions
qw(get_sdaf_config_path convert_region_to_short get_workload_vnet_code);
use sles4sap::sap_deployment_automation_framework::naming_conventions qw(get_sdaf_config_path convert_region_to_short get_workload_vnet_code);
use sles4sap::console_redirection qw(connect_target_to_serial disconnect_target_from_serial);
use sles4sap::sap_deployment_automation_framework::configure_tfvars qw(validate_components);
use serial_terminal qw(select_serial_terminal);
use testapi;
use publiccloud::utils 'is_byos';

=head1 SYNOPSIS
Expand Down Expand Up @@ -68,8 +68,7 @@ sub run {
vnet_code => get_workload_vnet_code(),
env_code => get_required_var('SDAF_ENV_CODE'),
sdaf_region_code => convert_region_to_short(get_required_var('PUBLIC_CLOUD_REGION')),
sap_sid => get_required_var('SAP_SID')
);
sap_sid => get_required_var('SAP_SID'));
# setup = combination of all components chosen for installation
my @setup = split(/,/, get_required_var('SDAF_DEPLOYMENT_SCENARIO'));
validate_components(components => \@setup);
Expand All @@ -86,6 +85,27 @@ sub run {
# Some playbooks use azure cli
az_login();

# Register SUTs before executing playbooks
if (is_byos() || get_var('PUBLIC_CLOUD_FORCE_REGISTRATION')) {
# Execute playbook 'pb_get-sshkey.yaml' for sshkey
$sles4sap::sap_deployment_automation_framework::basetest::serial_regexp_playbook = 1;
sdaf_execute_playbook(playbook_filename => 'pb_get-sshkey.yaml', timeout => 90, sdaf_config_root_dir => $sdaf_config_root_dir);
$sles4sap::sap_deployment_automation_framework::basetest::serial_regexp_playbook = 0;

# Register SUTs
my $sap_sid = get_required_var('SAP_SID');
my $scc_reg_code = get_required_var('SCC_REGCODE_SLES4SAP');
assert_script_run("cd $sdaf_config_root_dir");
record_info(
'Register SUTs',
ansible_execute_command(
command => "sudo registercloudguest -r $scc_reg_code",
host_group => "${sap_sid}_DB",
sdaf_config_root_dir => "$sdaf_config_root_dir",
sap_sid => "$sap_sid"
));
}

for my $playbook_options (@execute_playbooks) {
$sles4sap::sap_deployment_automation_framework::basetest::serial_regexp_playbook = 1;
sdaf_execute_playbook(%{$playbook_options}, sdaf_config_root_dir => $sdaf_config_root_dir);
Expand Down

0 comments on commit 89b5901

Please sign in to comment.