From 2196c186bfc0fe3b19c3caf90a81e05cd877df5f Mon Sep 17 00:00:00 2001 From: Michele Pagot Date: Fri, 25 Oct 2024 14:22:13 +0200 Subject: [PATCH] Tune cloud_netconfig and ipaddr2 test code (#20485) Increase some timeout for zypper. Split some multiline commands. Split the sanity test module. Add few more documentation about settings. --- lib/sles4sap/ipaddr2.pm | 11 ++--- .../sles4sap/cloud-components/ipaddr2.yml | 3 +- tests/sles4sap/cloud_netconfig/deploy.pm | 11 ++--- tests/sles4sap/cloud_netconfig/sanity.pm | 11 ++--- tests/sles4sap/ipaddr2/sanity_cluster.pm | 49 +++++++++++++++++++ .../ipaddr2/{sanity.pm => sanity_os.pm} | 0 6 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 tests/sles4sap/ipaddr2/sanity_cluster.pm rename tests/sles4sap/ipaddr2/{sanity.pm => sanity_os.pm} (100%) diff --git a/lib/sles4sap/ipaddr2.pm b/lib/sles4sap/ipaddr2.pm index c790ae6756bc..9490de19e25b 100644 --- a/lib/sles4sap/ipaddr2.pm +++ b/lib/sles4sap/ipaddr2.pm @@ -957,11 +957,10 @@ sub ipaddr2_cloudinit_sanity { 'zypper se -s -i cloud-init', 'cloud-init -v', 'cloud-init status --wait --long', - 'sudo systemctl status \ - cloud-init-local.service \ - cloud-init.service \ - cloud-config.service \ - cloud-final.service') { + 'sudo systemctl status cloud-init-local.service', + 'sudo systemctl status cloud-init.service', + 'sudo systemctl status cloud-config.service', + 'sudo systemctl status cloud-final.service') { ipaddr2_ssh_internal(id => $id, cmd => $_, bastion_ip => $args{bastion_ip}); @@ -1533,7 +1532,7 @@ sub ipaddr2_configure_web_server { $args{bastion_ip} //= ipaddr2_bastion_pubip(); ipaddr2_ssh_internal(id => $args{id}, cmd => $_, - timeout => 360, + timeout => 600, bastion_ip => $args{bastion_ip}) for (@nginx_cmds); } diff --git a/schedule/sles4sap/cloud-components/ipaddr2.yml b/schedule/sles4sap/cloud-components/ipaddr2.yml index 4f9f160365a1..bf42f58ba337 100644 --- a/schedule/sles4sap/cloud-components/ipaddr2.yml +++ b/schedule/sles4sap/cloud-components/ipaddr2.yml @@ -8,6 +8,7 @@ schedule: - boot/boot_to_desktop - sles4sap/ipaddr2/deploy - sles4sap/ipaddr2/configure - - sles4sap/ipaddr2/sanity + - sles4sap/ipaddr2/sanity_os + - sles4sap/ipaddr2/sanity_cluster - sles4sap/ipaddr2/test_move_resource - sles4sap/ipaddr2/destroy diff --git a/tests/sles4sap/cloud_netconfig/deploy.pm b/tests/sles4sap/cloud_netconfig/deploy.pm index 554f2c8ec8b7..af3391617a1f 100644 --- a/tests/sles4sap/cloud_netconfig/deploy.pm +++ b/tests/sles4sap/cloud_netconfig/deploy.pm @@ -128,13 +128,7 @@ sub run { my $ret; # check that the VM is reachable using both public IP addresses foreach (1 .. 2) { - $az_cmd = join(' ', - 'az network public-ip show', - "--resource-group $rg", - '--name', DEPLOY_PREFIX . "-pub_ip-$_", - '--query "ipAddress"', - '-o tsv'); - $vm_ip = script_output($az_cmd); + $vm_ip = az_network_publicip_get(resource_group => $rg, name => DEPLOY_PREFIX . "-pub_ip-$_"); $ssh_cmd = 'ssh cloudadmin@' . $vm_ip; my $start_time = time(); @@ -162,7 +156,8 @@ sub run { 'sudo', 'registercloudguest', '--force-new', '-r', "\"$reg_code\"", - '-e "testing@suse.com"')); + '-e "testing@suse.com"'), + timeout => 600); assert_script_run(join(' ', $ssh_cmd, 'sudo', 'SUSEConnect -s')); } } diff --git a/tests/sles4sap/cloud_netconfig/sanity.pm b/tests/sles4sap/cloud_netconfig/sanity.pm index 5f033d4b11d8..6600e373086e 100644 --- a/tests/sles4sap/cloud_netconfig/sanity.pm +++ b/tests/sles4sap/cloud_netconfig/sanity.pm @@ -51,13 +51,8 @@ sub run { my $vm_ip; my $ssh_cmd; my $ret; - $az_cmd = join(' ', - 'az network public-ip show', - "--resource-group $rg", - '--name', DEPLOY_PREFIX . "-pub_ip-1", - '--query "ipAddress"', - '-o tsv'); - $vm_ip = script_output($az_cmd); + + $vm_ip = az_network_publicip_get(resource_group => $rg, name => DEPLOY_PREFIX . "-pub_ip-1"); $ssh_cmd = 'ssh ' . $vm_user . '@' . $vm_ip; # print (no check for the moment) the OS release description @@ -65,7 +60,7 @@ sub run { record_info('TEST STEP', 'machine is ssh reachable OK'); # Check that cloud-netconfig is installed - assert_script_run("$ssh_cmd sudo zypper ref"); # Needed in the PAYG images + assert_script_run("$ssh_cmd sudo zypper ref", timeout => 600); # Needed in the PAYG images assert_script_run("$ssh_cmd zypper se -s -i cloud-netconfig"); assert_script_run("$ssh_cmd cat /etc/default/cloud-netconfig"); assert_script_run("$ssh_cmd sudo journalctl |grep -E 'cloud-netconfig\\['"); diff --git a/tests/sles4sap/ipaddr2/sanity_cluster.pm b/tests/sles4sap/ipaddr2/sanity_cluster.pm new file mode 100644 index 000000000000..59dd02181456 --- /dev/null +++ b/tests/sles4sap/ipaddr2/sanity_cluster.pm @@ -0,0 +1,49 @@ +# Copyright SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +# Summary: Check that deployed resource in the cloud are as expected +# Maintainer: QE-SAP , Michele Pagot +# Summary: Check that deployed resource in the cloud are as expected at OS level: +# Check packages, connectivity between nodes, network configuration +# +# This test module can be configured with these variables: +# - PUBLIC_CLOUD_PROVIDER: This setting is needed by other test modules usually scheduled with this one. +# Variable here is only validated and only value 'AZURE' is supported at the moment. +use strict; +use warnings; +use Mojo::Base 'publiccloud::basetest'; +use testapi; +use serial_terminal qw( select_serial_terminal ); +use sles4sap::ipaddr2 qw( + ipaddr2_bastion_pubip + ipaddr2_cluster_sanity + ipaddr2_deployment_logs + ipaddr2_infra_destroy + ipaddr2_cloudinit_logs +); + +sub run { + my ($self) = @_; + + die('Azure is the only CSP supported for the moment') + unless check_var('PUBLIC_CLOUD_PROVIDER', 'AZURE'); + + select_serial_terminal; + + my $bastion_ip = ipaddr2_bastion_pubip(); + ipaddr2_cluster_sanity(bastion_ip => $bastion_ip); +} + +sub test_flags { + return {fatal => 1, publiccloud_multi_module => 1}; +} + +sub post_fail_hook { + my ($self) = shift; + ipaddr2_deployment_logs() if check_var('IPADDR2_DIAGNOSTIC', 1); + ipaddr2_cloudinit_logs() unless check_var('IPADDR2_CLOUDINIT', 0); + ipaddr2_infra_destroy(); + $self->SUPER::post_fail_hook; +} + +1; diff --git a/tests/sles4sap/ipaddr2/sanity.pm b/tests/sles4sap/ipaddr2/sanity_os.pm similarity index 100% rename from tests/sles4sap/ipaddr2/sanity.pm rename to tests/sles4sap/ipaddr2/sanity_os.pm