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 6, 2025
1 parent 666879c commit 9b5c84b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ 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 (get_var('PUBLIC_CLOUD_IMAGE_LOCATION')) {
$params{SDAF_SOURCE_IMAGE_ID} = get_required_var('SDAF_SOURCE_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 @@ -893,6 +894,8 @@ Execute command on host group using ansible. Returns execution output.
=item * B<command>: Command to be executed
=item * B<verbose>: verbose ansible output
=back
=cut

Expand All @@ -903,9 +906,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",
$args{verbose} ? '-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
2 changes: 2 additions & 0 deletions t/27_sdaf_configure_tfvars.t
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ subtest '[set_image_parameters]' => sub {
$ms_sdaf->redefine(data_url => sub { return 'capuccino'; });
$ms_sdaf->redefine(validate_components => sub { return 'mocha'; });

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 @@ -6,6 +6,7 @@
# Summary: Deployment of the SAP systems zone using SDAF automation

use parent 'sles4sap::sap_deployment_automation_framework::basetest';
use Mojo::Base 'publiccloud::basetest';

use strict;
use warnings;
Expand Down Expand Up @@ -58,6 +59,8 @@ sub test_flags {
}

sub run {
my ($self) = @_;

serial_console_diag_banner('Module sdaf_deploy_sap_systems.pm : start');
select_serial_terminal();
my $env_code = get_required_var('SDAF_ENV_CODE');
Expand All @@ -75,6 +78,11 @@ sub run {
load_os_env_variables();

my @installed_components = split(',', get_required_var('SDAF_DEPLOYMENT_SCENARIO'));
# This section is only needed by Azure tests using images uploaded
if (get_var('PUBLIC_CLOUD_IMAGE_LOCATION')) {
my $provider = $self->provider_factory();
set_var('SDAF_SOURCE_IMAGE_ID', $self->{provider}->get_blob_uri(get_var('PUBLIC_CLOUD_IMAGE_LOCATION')));
}
prepare_tfvars_file(deployment_type => 'sap_system', components => \@installed_components);

# Custom VM sizing since default VMs are way too large for functional testing
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",
verbose => 1
);
}

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 9b5c84b

Please sign in to comment.