Skip to content

Commit

Permalink
SDAF run on prem code
Browse files Browse the repository at this point in the history
  • Loading branch information
lpalovsky committed Nov 15, 2024
1 parent 6ba2d1b commit 5cd929b
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,57 @@ sub verify_ssh_proxy_connection {
}
}
}

=head2 inventory_to_redirection
inventory_to_redirection(inventory_data=>HASHREF);
Reads parsed and referenced SDAF inventory data
=over
=item * B<inventory_data> SDAF inventory content in referenced perl data structure.
=back
=cut

sub inventory_to_redirection {
my (%args) = @_;
my %infrastructure;

for my $instance_type (keys(%{$args{inventory_data}})) {
my $hosts = $args{inventory_data}->{$instance_type}{hosts};
for my $hostname (keys %$hosts) {

}
}

return \%infrastructure;
}

=head2 get_instance_type
get_instance_type(inventory_data=>HASHREF);
Reads parsed and referenced SDAF inventory data
=over
=item * B<inventory_data> SDAF inventory content in referenced perl data structure.
=back
=cut

sub get_instance_type {
my (%args) = @_;
my %infrastructure;

for my $instance_type (keys(%{$args{inventory_data}})) {
my $hosts = $args{inventory_data}->{$instance_type}{hosts};
for my $hostname (keys %$hosts) {
my $section = ''
}
}

return \%infrastructure;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
name: sap_deployment_automation_framework
description: |
Hana SR test scenario executed on deployment created by 'SAP Deployment automation framework'
vars:
TEST_CONTEXT: 'OpenQA::Test::RunArgs'
schedule:
- boot/boot_to_desktop
- sles4sap/sap_deployment_automation_framework/connect_to_deployer
- sles4sap/sap_deployment_automation_framework/prepare_ssh_config
- sles4sap/sap_deployment_automation_framework/cleanup
#- sles4sap/sap_deployment_automation_framework/compile_redirection_data
- sles4sap/redirection_tests/hanasr_stop_primary
#- sles4sap/sap_deployment_automation_framework/cleanup
69 changes: 35 additions & 34 deletions t/29_sdaf_inventory_tools.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,38 @@ use testapi;
use sles4sap::sap_deployment_automation_framework::inventory_tools;
use Data::Dumper;

my $mock_inventory_data = {
'QES_PAS' => {
'hosts' => {
'Freddie' => {
'ansible_connection' => 'ssh',
'connection_type' => 'key',
'virtual_host' => 'Mercury',
'ansible_user' => 'freddie',
'vm_name' => 'FreddieMercury',
'become_user' => 'root',
'ansible_host' => '10.10.10.2',
'os_type' => 'linux'
}
},
'vars' => undef
},
'QES_DB' => {
'vars' => undef,
'hosts' => {
'John' => {
'ansible_connection' => 'ssh',
'connection_type' => 'key',
'virtual_host' => 'Deacon',
'ansible_user' => 'john',
'vm_name' => 'JohnDeacon',
'become_user' => 'john',
'ansible_host' => '10.10.10.3',
'os_type' => 'linux'
}
}
}
};

subtest '[prepare_ssh_config] ' => sub {
my $mock = Test::MockModule->new('sles4sap::sap_deployment_automation_framework::inventory_tools', no_auto => 1);
Expand Down Expand Up @@ -43,39 +75,6 @@ subtest '[prepare_ssh_config] ' => sub {
$db_host_B_content = join(' ', @_) if join(' ', @_) =~ /entry_name Freddie/;
return; });

my $mock_inventory_data = {
'QES_PAS' => {
'hosts' => {
'Freddie' => {
'ansible_connection' => 'ssh',
'connection_type' => 'key',
'virtual_host' => 'Mercury',
'ansible_user' => 'freddie',
'vm_name' => 'FreddieMercury',
'become_user' => 'root',
'ansible_host' => '10.10.10.2',
'os_type' => 'linux'
}
},
'vars' => undef
},
'QES_DB' => {
'vars' => undef,
'hosts' => {
'John' => {
'ansible_connection' => 'ssh',
'connection_type' => 'key',
'virtual_host' => 'Deacon',
'ansible_user' => 'john',
'vm_name' => 'JohnDeacon',
'become_user' => 'john',
'ansible_host' => '10.10.10.3',
'os_type' => 'linux'
}
}
}
};

prepare_ssh_config(inventory_data => $mock_inventory_data, jump_host_ip => '127.0.0.1', jump_host_user => 'Freddie');
note("\n --> $jump_config_content");
ok($jump_config_content =~ /entry_name deployer_jump/, 'Jump host: entry_name');
Expand All @@ -101,9 +100,11 @@ subtest '[prepare_ssh_config] ' => sub {
ok($db_host_B_content =~ /identity_file/, 'DB host A: identity_file');
ok($db_host_B_content =~ /proxy_jump deployer_jump/, 'DB host A: proxy_jump');
ok($db_host_B_content =~ /strict_host_key_checking no/, 'DB host A: strict_host_key_checking');
};

subtest '[inventory_to_redirection] ' => sub {
my $mock = Test::MockModule->new('sles4sap::sap_deployment_automation_framework::inventory_tools', no_auto => 1);

};


done_testing;
43 changes: 43 additions & 0 deletions tests/sles4sap/redirection_tests/hanasr_stop_primary.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SUSE's openQA tests

Check failure on line 1 in tests/sles4sap/redirection_tests/hanasr_stop_primary.pm

View workflow job for this annotation

GitHub Actions / CI: Running static tests with perl v5.32

File tests/sles4sap/redirection_tests/hanasr_stop_primary.pm needs tidying
#
# Copyright SUSE LLC
# SPDX-License-Identifier: FSFAP
# Maintainer: QE-SAP <[email protected]>
# Summary:

use parent 'sles4sap::sap_deployment_automation_framework::basetest';

use warnings;
use strict;
use testapi;
use serial_terminal qw(select_serial_terminal);
use sles4sap::console_redirection;

sub test_flags {
return {fatal => 1, publiccloud_multi_module => 1};
}

sub run {
my ($self, $run_args) = @_;
my %inventory = %{ $run_args->{sdaf_inventory} };
use Data::Dumper;
record_info('Inventory', Dumper(\%inventory));

for my $instance_type (keys(%inventory)) {
my $hosts = $inventory{$instance_type}{hosts};
for my $hostname (keys %$hosts) {
my $ip_addr = $hosts->{$hostname}{ansible_host};
my $user = $hosts->{$hostname}{ansible_user};
connect_target_to_serial(destination_ip=>$ip_addr, ssh_user=>$user);
record_info(script_output('sudo crm status'));
assert_script_run('hostname');
assert_script_run("echo \$(hostname) > /tmp/hostname");
upload_logs('/tmp/hostname');
disconnect_target_from_serial();
}
}


}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sub run {
disconnect_target_from_serial();

# Share inventory data between all tests
$self->{sdaf_inventory} = $inventory_data;
$run_args->{sdaf_inventory} = $inventory_data;

my @workload_key_vault = @{az_keyvault_list(
resource_group => generate_resource_group_name(deployment_type => 'workload_zone'))};
Expand Down

0 comments on commit 5cd929b

Please sign in to comment.